Code : Tout sélectionner
;nico, mesa
Global Window_0
Global Editor_0, TrackBar_0, TrackBar_1, TrackBar_2, Frame3D_0, Option_0, Option_1, Option_2, Spin_0, Spin_1, Spin_2, Spin_3, TrackBar_3, Text_0, Text_1, Text_1_Copy1, Text_1_Copy2
; text.settextex
;
; #ST_SELECTION=2
; text\flags=#ST_SELECTION
; text\codepage=#CP_ACP
;
; Texte.s="{\rtf\tab "
Procedure LOWORD(Value)
ProcedureReturn Value & $FFFF
EndProcedure
Procedure HIWORD(Value)
ProcedureReturn (Value >> 16) & $FFFF
EndProcedure
Procedure MAKELONG(low, high)
ProcedureReturn low | (high<<16)
EndProcedure
Procedure.f initTaquetTab()
Value=GetDialogBaseUnits_()
baseunitX=LOWORD(Value)
baseunitY=HIWORD(Value)
;The horizontal base unit returned by GetDialogBaseUnits is equal to the average
;width, in pixels, of the characters in the system font;
;the vertical base unit is equal To the height, in pixels, of the font.
hdc = GetDC_(GetDesktopWindow_())
If hdc
Ecrdpihz.l = GetDeviceCaps_(hdc, #LOGPIXELSX)
EndIf
; If hdc
; Ecrdpivt.l = GetDeviceCaps_(hdc, #LOGPIXELSY)
; EndIf
ReleaseDC_(GetDesktopWindow_(), hdc)
; 1 horizontal Dialog Template Unit = (DPI écran / 96 * baseunitX)/4
; 1 vertical Dialog Template Unit = (DPI écran / 96 * baseunitY)/8
pixelX.f = (Ecrdpihz/96)*baseunitX/4
; pixelY.f = (Ecrdpihz/96)*baseunitX/8
ProcedureReturn pixelX
EndProcedure
Global facteur.f=initTaquetTab() ; transforme un nombre de caractère en dialog template units
Global taquetperso
Global Dim taquetpersos(10)
Procedure InitWindow_0()
Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "Editor [Windows seulement]", #PB_Window_SystemMenu)
Editor_0 = EditorGadget(#PB_Any, 10, 150, 570, 200)
AddGadgetItem(Editor_0, -1, "Texte$")
TrackBar_0 = TrackBarGadget(#PB_Any, 10, 120, 100, 20, 0, 30)
TrackBar_1 = TrackBarGadget(#PB_Any, 480, 120, 100, 20, 0, 30)
TrackBar_2 = TrackBarGadget(#PB_Any, 120, 120, 330, 20, 0, 100)
Frame3D_0 = Frame3DGadget(#PB_Any, 10, 10, 580, 80, "Tabulations")
Option_0 = OptionGadget(#PB_Any, 20, 30, 180, 20, "Tabulations pré-définies")
SetGadgetState(Option_0, 1)
Option_1 = OptionGadget(#PB_Any, 20, 60, 150, 20, "Tabulations perso")
Option_2 = OptionGadget(#PB_Any, 360, 30, 170, 20, "Multi tabulations perso")
Spin_0 = SpinGadget(#PB_Any, 200, 50, 50, 30, 0, 100, #PB_Spin_Numeric)
SetGadgetState(Spin_0, 30)
Spin_1 = SpinGadget(#PB_Any, 360, 60, 60, 26, 0, 100, #PB_Spin_Numeric)
Spin_2 = SpinGadget(#PB_Any, 430, 60, 60, 26, 0, 100, #PB_Spin_Numeric)
Spin_3 = SpinGadget(#PB_Any, 500, 60, 60, 26, 0, 100, #PB_Spin_Numeric)
SetGadgetState(Spin_1, 5)
SetGadgetState(Spin_2, 20)
SetGadgetState(Spin_3, 50)
TrackBar_3 = TrackBarGadget(#PB_Any, 10, 360, 570, 20, 0, 500)
Text_0 = TextGadget(#PB_Any, 270, 380, 60, 20, "ZOOM")
Text_1 = TextGadget(#PB_Any, 30, 100, 60, 20, "Marge")
Text_1_Copy1 = TextGadget(#PB_Any, 510, 100, 60, 20, "Marge")
Text_1_Copy2 = TextGadget(#PB_Any, 250, 100, 120, 20, "Zone d'affichage")
EndProcedure
Procedure Window_0_Events(event)
Select event
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Gadget
Select EventGadget()
Case TrackBar_0
SendMessage_(GadgetID(Editor_0), #EM_SETMARGINS, #EC_LEFTMARGIN, MAKELONG(GetGadgetState(TrackBar_0),0))
Case TrackBar_1
SendMessage_(GadgetID(Editor_0), #EM_SETMARGINS, #EC_RIGHTMARGIN, MAKELONG(0,GetGadgetState(TrackBar_1)))
Case TrackBar_2
offset=GetGadgetState(TrackBar_2)
r.RECT
r\left = offset
r\top = offset
r\right = GadgetWidth(Editor_0)+offset
r\bottom = GadgetHeight(Editor_0)+offset
SendMessage_(GadgetID(Editor_0), #EM_SETRECT, 0, r)
Case TrackBar_3
SendMessage_(GadgetID(Editor_0), #EM_SETZOOM, 100+GetGadgetState(TrackBar_3), 100)
Case Option_0
SendMessage_(GadgetID(Editor_0),#EM_SETTABSTOPS,0,0)
InvalidateRect_(GadgetID(Editor_0), 0, 1)
Case Option_1
taquetperso=GetGadgetState(Spin_0) * facteur
SendMessage_(GadgetID(Editor_0),#EM_SETTABSTOPS,1,@taquetperso)
InvalidateRect_(GadgetID(Editor_0), 0, 1)
Case Option_2
taquetpersos(0)=GetGadgetState(Spin_1) * facteur
taquetpersos(1)=GetGadgetState(Spin_2) * facteur
taquetpersos(2)=GetGadgetState(Spin_3) * facteur
SendMessage_(GadgetID(Editor_0),#EM_SETTABSTOPS,2,@taquetpersos())
InvalidateRect_(GadgetID(Editor_0), 0, 1)
;EndSelect
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
InitWindow_0()
Repeat
event = WaitWindowEvent()
Until Window_0_Events(event) = #False