Re: [Module] Extended ToolBar-Gadget (all OS / DPI)
Posted: Tue Jun 21, 2022 3:20 pm
Update: Toolbar::Disable()
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Procedure _MouseLeaveHandler()
Define.i GNum = EventGadget()
If FindMapElement(TBEx(), Str(GNum))
TBEx()\Buttons\Focus = #NoFocus
TBEx()\LastFocus = -1 ; added
DisableToolTip_()
Draw_()
EndIf
EndProcedure
Code: Select all
; Focus
TBEx()\Items()\State = #Focus
TBEx()\Buttons\Focus = ItemIndex
TBEx()\LastFocus = TBEx()\Buttons\Focus
If LastButtonFocus = ItemIndex : Continue : EndIf ; added
; Tooltip available
If TBEx()\Items()\ToolTip
TBEx()\ToolTip = ItemIndex
GadgetToolTip(TBEx()\CanvasNum, TBEx()\Items()\ToolTip)
Else
DisableToolTip_()
EndIf
If TBEx()\Buttons\State <> #Click : DrawSingleButton_(ItemIndex) : EndIf
EndIf
Default
TBEx()\Items()\State = #False
TBEx()\Buttons\Focus = #NoFocus
TBEx()\LastFocus = -1 ; added
Code: Select all
Procedure _MouseLeaveHandler()
Define.i GNum = EventGadget()
If FindMapElement(TBEx(), Str(GNum))
TBEx()\Buttons\Focus = #NoFocus
TBEx()\LastFocus = #PB_Default
ForEach TBEx()\Items()
TBEx()\Items()\State = #False
Next
DisableToolTip_()
Draw_()
EndIf
EndProcedure
Code: Select all
Case #EventType_ImageButton ;{ ImageButton clicked & released
If TBEx()\Buttons\Focus = btIndex And TBEx()\Event\btIndex = btIndex
If TBEx()\Items()\PopupMenu = #NotValid ; Button without Popupmenu
TBEx()\Event\Num = TBEx()\Items()\Event
TBEx()\Event\ID = TBEx()\Items()\EventID
If IsWindow(TBEx()\Window\Num)
If TBEx()\PostEvent = #Event_Menu
PostEvent(#PB_Event_Menu, TBEx()\Window\Num, TBEx()\Items()\Event, #EventType_ImageButton, btIndex)
Else
PostEvent(#PB_Event_Gadget, TBEx()\Window\Num, TBEx()\CanvasNum, #EventType_ImageButton, btIndex)
PostEvent(#Event_Gadget, TBEx()\Window\Num, TBEx()\CanvasNum, #EventType_ImageButton, btIndex)
EndIf
EndIf
; TBEx()\Items()\State = #False
DrawSingleButton_(btIndex)
Code: Select all
;{ Draw background
Select TBEx()\Items()\State
Case #Focus
BackColor = BlendColor_(TBEx()\Color\Focus, TBEx()\Color\Back, 20)
BorderColor = BlendColor_(TBEx()\Color\Focus, TBEx()\Color\Back)
Case #Click
BackColor = BlendColor_(TBEx()\Color\Focus, TBEx()\Color\Back, 32)
BorderColor = BlendColor_(TBEx()\Color\Focus, TBEx()\Color\Back)
TBEx()\Items()\State = #Focus
Default
BackColor = TBEx()\Color\Back
BorderColor = #PB_Default
EndSelect
Code: Select all
TBEx()\Items()\State = #Focus
Code: Select all
X = GadgetX(TBEx()\CanvasNum, #PB_Gadget_ScreenCoordinate) + TBEx()\Items()\X
Y = GadgetY(TBEx()\CanvasNum, #PB_Gadget_ScreenCoordinate) + TBEx()\Items()\Y + GetButtonY_(#True)
Code: Select all
Global RootMenuClosed
Procedure PopupCallback(hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_INITMENUPOPUP
If RootMenuClosed = 0
RootMenuClosed = wParam
Debug "- Menu opened -"
EndIf
Case #WM_UNINITMENUPOPUP
If wParam = RootMenuClosed
RootMenuClosed = 0
Debug "- Menu closed -"
EndIf
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure