Voila un code simplifié qui permet d'obtenir un sidebar coulissant en cliquant sur l'icone ᐊ ou ᐅ situé en haut à droite du sidebar.
Comme vous allez le voir, il ne sera pas possible de fermer ce sidebar à cause du ListIconGadget().
Code : Tout sélectionner
EnableExplicit
Enumeration Police
#fontGlobal
#fontMenuTitle
#fontUnicode
EndEnumeration
Enumeration Window
#mf
EndEnumeration
Enumeration Timer
#mfMenuTimer
EndEnumeration
Enumeration Gadget
#mfSidebar
#mfTitle
#mfMenu
#mfClose
#mfList
EndEnumeration
;Flag SideBar
; 1: Close
; -1: Open
Global MenuState.i = -1
Global SideBarColor = RGB(188, 143, 143)
;Summary
Declare Start()
Declare MenuSelect()
Declare MenuOpenClose()
Declare Resize()
Declare Exit()
Start()
Procedure Start()
Protected n
LoadFont(#FontGlobal, "Arial", 10)
LoadFont(#fontMenuTitle, "Arial", 13)
LoadFont(#fontUnicode, "Arial", 22)
SetGadgetFont(#PB_Default, FontID(#FontGlobal))
OpenWindow(#mf, 0, 0, 800, 600, "Sidebar", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
;Content
ListIconGadget(#mfList, 60, 10, 730, 580, "Clients", 200, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(#mfList, 1, "Compte", 300)
;Ajout d'items test
For n = 0 To 10
AddGadgetItem(#mfList, -1, "Client " + n + Chr(10) + Str(411000 + n))
Next
SetGadgetState(#mfList, 0)
;SideBar
ContainerGadget(#mfSidebar, 0, 0, 200, 600)
SetGadgetColor(#mfSidebar, #PB_Gadget_BackColor, SideBarColor)
;Menu
HyperLinkGadget(#mfMenu, 170, 10, 25, 26, Chr($140A), RGB(0, 0, 0))
SetGadgetColor(#mfMenu, #PB_Gadget_FrontColor, RGB(255, 255, 255))
SetGadgetColor(#mfMenu, #PB_Gadget_BackColor, SideBarColor)
SetGadgetFont(#mfMenu, FontID(#fontUnicode))
;Close
HyperLinkGadget(#mfClose, 10, 550, 50, 22, "X Close", RGB(0, 0, 0))
SetGadgetColor(#mfClose, #PB_Gadget_FrontColor, RGB(105, 105, 105))
SetGadgetColor(#mfClose, #PB_Gadget_BackColor, SideBarColor)
CloseGadgetList()
;Timer
AddWindowTimer(#mf, #mfMenuTimer, 2)
;SideBar close and resize
MenuSelect()
Resize()
;Triggers
BindEvent(#PB_Event_CloseWindow, @Exit())
BindEvent(#PB_Event_SizeWindow, @Resize())
BindEvent(#PB_Event_Timer, @MenuOpenClose())
BindGadgetEvent(#mfMenu, @MenuSelect())
BindGadgetEvent(#mfclose, @Exit())
Repeat : WaitWindowEvent() : ForEver
EndProcedure
Procedure MenuSelect()
MenuState * -1
If MenuState = -1
SetGadgetText(#mfMenu, Chr($140A)) ;ᐊ
GadgetToolTip(#mfMenu, "Close Sidebar")
Else
SetGadgetText(#mfMenu, Chr($1405)) ;ᐅ
GadgetToolTip(#mfMenu, "Open Sidebar")
EndIf
SetActiveGadget(#mfMenu)
EndProcedure
Procedure MenuOpenClose()
Static Left.i
If Left > -150 And MenuState = 1
Left - 5
ResizeGadget(#mfSidebar, left, #PB_Ignore, #PB_Ignore, #PB_Ignore)
EndIf
If Left <> 0 And MenuState = -1
Left + 5
ResizeGadget(#mfSidebar, left, #PB_Ignore, #PB_Ignore, #PB_Ignore)
EndIf
EndProcedure
Procedure Resize()
Protected WindowHeight = WindowHeight(#mf)
ResizeGadget(#mfSidebar, #PB_Ignore, #PB_Ignore, #PB_Ignore, WindowHeight)
ResizeGadget(#mfClose, #PB_Ignore, WindowHeight - 40, #PB_Ignore, #PB_Ignore)
EndProcedure
Procedure Exit()
End
EndProcedure