Page 1 of 1

ScintillaGadget

Posted: Sat Oct 27, 2007 4:08 am
by michaeled314
Could someone please give me a working example for ScintillaGadget function for PB 4.10 Beta 4

Posted: Sat Oct 27, 2007 9:36 am
by Comtois
A small one

Code: Select all

;http://www.purebasic.fr/german/viewtopic.php?t=13234, merci ts-soft.

EnableExplicit

If InitScintilla("scintilla.dll") = #False
  MessageRequester("Erreur","Scintilla.DLL n'a pas pu ĂȘtre chargĂ©",0)
  End
EndIf

Enumeration; Gadgets
  #SciID
EndEnumeration

Procedure ScintillaCallBack(EditorGadget.l, *scinotify.SCNotification)
  If *scinotify\nmhdr\code = #SCN_STYLENEEDED
    ScintillaSendMessage(EditorGadget, #SCI_LINEFROMPOSITION, ScintillaSendMessage(EditorGadget, #SCI_GETENDSTYLED))
 EndIf
EndProcedure

Procedure CreatePBSource()
  Protected WFlags.l = #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SystemMenu | #PB_Window_SizeGadget
  Protected temp.s
  If OpenWindow(1, #PB_Ignore, 0, 640, 480, "Tests avec Scintilla", WFlags)
    CreateGadgetList(WindowID(1))
    ScintillaGadget(#SciID, 20, 20, 600, 440, @ScintillaCallBack())
   
    ScintillaSendMessage(#SciID, #SCI_STYLESETBACK, #STYLE_DEFAULT, $BEFCFD) ; Couleur de fond
    temp = "Lucida BlackLetter"
    ScintillaSendMessage(#SciID, #SCI_STYLESETFONT, #STYLE_DEFAULT, @temp) ; Police
    ScintillaSendMessage(#SciID, #SCI_STYLESETSIZE, #STYLE_DEFAULT, 24)    ; Taille police
    ScintillaSendMessage(#SciID, #SCI_STYLECLEARALL)
    ScintillaSendMessage(#SciID, #SCI_STYLESETFORE, 0, $FF0000)            ;Couleur du texte
    ScintillaSendMessage(#SciID, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
    ScintillaSendMessage(#SciID, #SCI_SETMARGINWIDTHN, 0, 40) ; Largeur Marge
    ScintillaSendMessage(#SciID, #SCI_STYLESETBACK, #STYLE_LINENUMBER, #Gray) ;Couleur de la marge
    ScintillaSendMessage(#SciID, #SCI_STYLESETFORE, #STYLE_LINENUMBER, #Yellow) ;Couleur Texte de la marge
    ProcedureReturn 1
  EndIf
  ProcedureReturn 0
EndProcedure

If CreatePBSource()
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow : Break
    EndSelect
  ForEver
EndIf