un petit code qui pourrait être utile à ceux qui veulent réaliser un zoom sur un gadget editor (+marge) :
Code : Tout sélectionner
Procedure SetZoom(Z.l=100)
Shared zoom.l,Page_W,Page_H
zoom = z
SendMessage_(GadgetID(0), #EM_SETZOOM, z, 100)
newH.d = Page_H * zoom/100
If newH < WindowHeight(0)
H = Int(newH)
Else
H = WindowHeight(0)
EndIf
newW.d = Page_W * zoom/100
If newW < WindowWidth(0)
W = Int(newW)
Else
W = WindowWidth(0)
EndIf
X1 = WindowWidth(0)/2 - W/2
ResizeGadget(0,X1,40,W, H-70)
EndProcedure
Procedure SetEditor()
Shared Page_W,Page_H
Page_W = 400
Page_H = 300
EditorGadget(0, WindowWidth(0)/2 - Page_W/2, 40, Page_W, Page_H)
For a = 0 To 5
AddGadgetItem(0, a, "Line "+Str(a))
Next
EndProcedure
Procedure SetMargin(PageW,PageH, LeftM, TopM, RightM, BottomM)
Shared zoom.l
r.RECT
r\left = LeftM * zoom/100
r\top = TopM * zoom/100
r\right = (PageW - RightM) * zoom/100
r\bottom = (PageH - BottomM) * zoom/100
width = r\right - r\left
height = r\bottom - r\top
SendMessage_(GadgetID(0), #EM_SETRECTNP, 0, r)
EndProcedure
If OpenWindow(0, 0, 0, 800,600, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetEditor()
setzoom()
SetMargin(400,300,20,20,20,20)
CreateMenu(0,WindowID(0))
MenuTitle("zoom")
MenuItem(0,"Zoom 50")
MenuItem(1,"Zoom 100")
MenuItem(2,"Zoom 120")
MenuItem(3,"Zoom 150")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Menu
Select EventMenu()
Case 0
SetZoom(50)
Case 1
SetZoom()
Case 2
SetZoom(120)
Case 3
SetZoom(150)
EndSelect
EndSelect
ForEver
EndIf