Code: Select all
Procedure zoomIn()
ScintillaSendMessage(0,#SCI_ZOOMIN,0,0) ;make larger one point per click
SetActiveGadget(0)
EndProcedure
Procedure zoomOut()
ScintillaSendMessage(0,#SCI_ZOOMOUT,0,0) ;make smaller one point per click
SetActiveGadget(0)
EndProcedure
Procedure zoom20()
ScintillaSendMessage(0,#SCI_SETZOOM,20,0) ;set zoom to +20 points
SetActiveGadget(0)
EndProcedure
Procedure zoomReset()
ScintillaSendMessage(0,#SCI_SETZOOM,0,0) ;remove zoom ie. zoom=0
SetActiveGadget(0)
EndProcedure
If OpenWindow(0, 0, 0, 400, 200, "ScintillaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If InitScintilla()
ScintillaGadget(0, 10, 10, 250, 180, 0)
ScintillaSendMessage(0,#SCI_USEPOPUP,1,0) ;this turns on the default popup menu
zi=ButtonGadget(#PB_Any,280,10,100,25,"Zoom In")
zo=ButtonGadget(#PB_Any,280,50,100,25,"Zoom Out")
z20=ButtonGadget(#PB_Any,280,90,100,25,"Zoom x 20")
zr=ButtonGadget(#PB_Any,280,130,100,25,"Reset Zoom")
SetActiveGadget(0)
; Set the initial text to the ScintillaGadget
*Text=UTF8("This is a simple ScintillaGadget")
ScintillaSendMessage(0, #SCI_SETTEXT, 0, *Text)
FreeMemory(*Text) ; The buffer made by UTF8() has to be freed, to avoid memory leak
; Adding a second line of text with linebreak before
Text$ = Chr(10) + "This is a second line"
*Text=UTF8(Text$)
ScintillaSendMessage(0, #SCI_APPENDTEXT, Len(Text$), *Text)
FreeMemory(*Text)
;Set a margin with line numbers
ScintillaSendMessage(0,#SCI_SETMARGINWIDTHN,0,20)
EndIf
Repeat
EventID=WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case zi
zoomIn()
Case zo
zoomOut()
Case z20
zoom20()
Case zr
zoomReset()
EndSelect
EndSelect
Until EventID=#PB_Event_CloseWindow
EndIf