Re: Object Theme Library (for Dark or Light Theme)
Posted: Fri Nov 24, 2023 5:09 pm
Nah, it's definitely not trash. Don't know why I have problems, but there will be a solution.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Protected low, high
SendMessage_(lParam, #EM_GETSEL, @low, @high)
If low Or high
SendMessage_(lParam, #EM_SETSEL, -1, 0) ; Deselect the ComboBox editable string if not the active Gadget
EndIf
An inevitable disappointment when you've spent a bit of time on it and realize that it won't be used at all if it crashes for some people, build Windows version probably here.
Code: Select all
#Dialog = 0
#Xml1 = 1
#Xml2 = 2
; Note: For ObjectTheme ComboBox, #CBS_HASSTRINGS | #CBS_OWNERDRAWFIXED flags should be added to have the drop-down list painted.
; But I don't know how they could be added with XML dialog, they must be added at creation time but the Dialog library does not accept them.
; And it does not work if they are added later With SetWindowLongPtr_()
XIncludeFile "ObjectTheme.pbi"
UseModule ObjectTheme
XML1$ = "<window id='1' name='test1' text='test1' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
" <panel>" +
" <tab text='Premier Onglet'>" +
" <vbox expand='item:2'>" +
" <hbox>" +
" <button id='0' text='Bouton 1'/>" +
" <checkbox id='1' text='Case à cocher 1'/>" +
" <button id='2' text='Bouton 2'/>" +
" </hbox>" +
" <editor id='3' text='Contenu...' height='150'/>" +
" </vbox>" +
" </tab>" +
" <tab text='Second Onglet'>" +
" <vbox expand='No'>" +
" <combobox id='4' Height='28' flags='#PB_ComboBox_Editable'/>" +
" <string id='5' text='String' height='24'/>" +
" <progressbar id='6' height='25' min='1' max='100' value='66'/>" +
" <trackbar id='7' invisible='No' Flags='#PB_TrackBar_Ticks' height='25' min='1' max='100' value='66'/>"+
" <hbox>" +
" <option id='8' text='option 1' name='option1'/>"+
" <option id='9' text='option 2' name='option2'/>"+
" </hbox>" +
" </vbox>" +
" </tab>" +
" </panel>" +
"</window>"
XML2$ = "<window id='2' name='test2' text='Gridbox' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
" <gridbox columns='5' rowexpand='yes'>" +
" <button text='Bouton 1' />" +
" <button text='Bouton 2' />" +
" <button text='Bouton 3' colspan='3' />" +
" <button text='Bouton 4' rowspan='2' />" +
" <button text='Bouton 5' />" +
" <button text='Bouton 6' />" +
" <button text='Bouton 7' />" +
" <button text='Bouton 8' />" +
" <button text='Bouton 9' />" +
" <button text='Bouton 10' />" +
" </gridbox>" +
" </window>"
If ParseXML(#Xml1, XML1$) And XMLStatus(#Xml1) = #PB_XML_Success
If ParseXML(#Xml2, XML2$) And XMLStatus(#Xml2) = #PB_XML_Success
If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml1, "test1")
For i = 1 To 5
AddGadgetItem(4, -1,"Combo Element : " + Str(i))
Next
SetGadgetState(4, 0)
SetGadgetState(8, 1)
SetObjectTheme(#ObjectTheme_DarkBlue)
SetGadgetColor(6, #PB_Gadget_FrontColor, $005636) ; Or SetObjectColor(6, #PB_Gadget_FrontColor, $005636). To do after SetObjectTheme
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
If EventWindow() = 1
OpenXMLDialog(#Dialog, #Xml2, "test2")
CloseWindow(1)
SetObjectTheme(#ObjectTheme_DarkBlue) ; For dynamic Dialog, SetObjectTheme() must be added after each OpenXMLDialog()
Else
Break
EndIf
Case #PB_Event_Gadget
EndSelect
ForEver
Else
Debug "Dialog error: " + DialogError(#Dialog)
EndIf
Else
Debug "XML2 error: " + XMLError(#Xml2) + " (Line: " + XMLErrorLine(#Xml2) + ")"
EndIf
Else
Debug "XML1 error: " + XMLError(#Xml1) + " (Line: " + XMLErrorLine(#Xml1) + ")"
EndIf