Re: IceDesign GUI designer
Posted: Thu Jan 04, 2024 11:10 pm
My answer didn't make it clear with my poor english but yes, no worries, that's how I understood it
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
PostEvent(#PB_Event_SizeWindow, #WinTest, 0)
Code: Select all
EnableExplicit
;- Enumerations
Enumeration Window
#WinTest
EndEnumeration
Enumeration Gadgets
#WinTest_Img_1
#WinTest_Cont_1
#WinTest_Btn_scherm_1
#WinTest_Btn_scherm_2
#WinTest_Btn_Licentie_kopen
#WinTest_Btn_Listrik_niet_starten
EndEnumeration
Enumeration Image
#WinTest_Imag_0
EndEnumeration
Enumeration Font
#WinTest_Font_0
EndEnumeration
CompilerIf #PB_Compiler_IsMainFile
Structure GadgetImages
Image.i
PressedImage.i
Width.i
Height.i
EndStructure
CompilerEndIf
;- Load Images
UsePNGImageDecoder()
CatchImage(#WinTest_Imag_0, ?WinTest_Imag_0)
;- Load Fonts
LoadFont(#WinTest_Font_0, "", 12, #PB_Font_Bold)
;- Declare
Declare Event_WinTest_Btn_scherm_1()
Declare Event_WinTest_Btn_scherm_2()
Declare Event_WinTest_Btn_Licentie_kopen()
Declare Event_WinTest_Btn_Listrik_niet_starten()
CompilerIf #PB_Compiler_IsMainFile : Declare ResizeGadgetImage(Gadget, OriginalImage, OriginalPressedImage = #PB_Ignore) : CompilerEndIf
Declare Resize_WinTest()
Declare Open_WinTest(X = 0, Y = 0, Width = 900, Height = 820)
CompilerIf #PB_Compiler_IsMainFile : XIncludeFile "WinTest_Lang.pb" : CompilerEndIf
Procedure Event_WinTest_Btn_scherm_1()
Select EventType()
Case #PB_EventType_LeftClick
EndSelect
EndProcedure
Procedure Event_WinTest_Btn_scherm_2()
Select EventType()
Case #PB_EventType_LeftClick
EndSelect
EndProcedure
Procedure Event_WinTest_Btn_Licentie_kopen()
Select EventType()
Case #PB_EventType_LeftClick
EndSelect
EndProcedure
Procedure Event_WinTest_Btn_Listrik_niet_starten()
Select EventType()
Case #PB_EventType_LeftClick
EndSelect
EndProcedure
CompilerIf #PB_Compiler_IsMainFile
Procedure ResizeGadgetImage(Gadget, OriginalImage, OriginalPressedImage = #PB_Ignore)
Protected Image, Width, Height
Static NewMap GadgetImage.GadgetImages()
If IsGadget(Gadget) And IsImage(OriginalImage)
Width = DesktopScaledX(GadgetWidth(Gadget)) : Height = DesktopScaledY(GadgetHeight(Gadget))
If Width > 0 And Height > 0
If GadgetImage(Str(Gadget))\Width <> Width Or GadgetImage(Str(Gadget))\Height <> Height
GadgetImage()\Width = Width : GadgetImage()\Height = Height
Image = CopyImage(OriginalImage, #PB_Any)
If Image
ResizeImage(Image, Width, Height)
Select GadgetType(Gadget)
Case #PB_GadgetType_ButtonImage
SetGadgetAttribute(Gadget, #PB_Button_Image, ImageID(Image))
Case #PB_GadgetType_Image
SetGadgetState(Gadget, ImageID(Image))
EndSelect
If GadgetImage()\Image And IsImage(GadgetImage()\Image)
FreeImage(GadgetImage()\Image)
EndIf
GadgetImage()\Image = Image
EndIf
If GadgetType(Gadget) = #PB_GadgetType_ButtonImage And IsImage(OriginalPressedImage)
Image = CopyImage(OriginalPressedImage, #PB_Any)
If Image
ResizeImage(Image, Width, Height)
SetGadgetAttribute(Gadget, #PB_Button_PressedImage, ImageID(Image))
If GadgetImage()\PressedImage And IsImage(GadgetImage()\PressedImage)
FreeImage(GadgetImage()\PressedImage)
EndIf
GadgetImage()\PressedImage = Image
EndIf
EndIf
EndIf ; If GadgetImage(Str(Gadget))\Width <> Width Or GadgetImage(Str(Gadget))\Height <> Height
EndIf ; If Width > 0 And Height > 0
EndIf ; If IsGadget(Gadget) And IsImage(OriginalImage)
EndProcedure
CompilerEndIf
Procedure Resize_WinTest()
Protected ScaleX.f, ScaleY.f
Static WinTest_WidthIni, WinTest_HeightIni
If WinTest_WidthIni = 0
WinTest_WidthIni = WindowWidth(#WinTest) : WinTest_HeightIni = WindowHeight(#WinTest)
EndIf
ScaleX = WindowWidth(#WinTest) / WinTest_WidthIni : ScaleY = WindowHeight(#WinTest) / WinTest_HeightIni
ResizeGadget(#WinTest_Img_1, ScaleX * 70, ScaleY * 10, ScaleX * 750, ScaleY * 140)
ResizeGadgetImage(#WinTest_Img_1, #WinTest_Imag_0)
ResizeGadget(#WinTest_Cont_1, ScaleX * 20, ScaleY * 170, ScaleX * 3, ScaleY * 380)
ResizeGadget(#WinTest_Btn_scherm_1, ScaleX * 10, ScaleY * 720, ScaleX * 430, ScaleY * 40)
ResizeGadget(#WinTest_Btn_scherm_2, ScaleX * 460, ScaleY * 720, ScaleX * 430, ScaleY * 40)
ResizeGadget(#WinTest_Btn_Licentie_kopen, ScaleX * 10, ScaleY * 770, ScaleX * 430, ScaleY * 40)
ResizeGadget(#WinTest_Btn_Listrik_niet_starten, ScaleX * 460, ScaleY * 770, ScaleX * 430, ScaleY * 40)
EndProcedure
Procedure Open_WinTest(X = 0, Y = 0, Width = 900, Height = 820)
If OpenWindow(#WinTest, X, Y, Width, Height, "", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
SetWindowColor(#WinTest, RGB(0, 64, 128))
ImageGadget(#WinTest_Img_1, 70, 10, 750, 140, ImageID(#WinTest_Imag_0))
ContainerGadget(#WinTest_Cont_1, 20, 170, 3, 380, #PB_Container_BorderLess)
SetGadgetColor(#WinTest_Cont_1, #PB_Gadget_BackColor, RGB(0, 0, 255))
CloseGadgetList() ; #WinTest_Cont_1
ButtonGadget(#WinTest_Btn_scherm_1, 10, 720, 430, 40, GetInterfaceLang("WinTest_Btn_scherm_1"), #PB_Button_MultiLine)
SetGadgetFont(#WinTest_Btn_scherm_1, FontID(#WinTest_Font_0))
ButtonGadget(#WinTest_Btn_scherm_2, 460, 720, 430, 40, GetInterfaceLang("WinTest_Btn_scherm_2"))
SetGadgetFont(#WinTest_Btn_scherm_2, FontID(#WinTest_Font_0))
ButtonGadget(#WinTest_Btn_Licentie_kopen, 10, 770, 430, 40, GetInterfaceLang("WinTest_Btn_Licentie_kopen"))
SetGadgetFont(#WinTest_Btn_Licentie_kopen, FontID(#WinTest_Font_0))
DisableGadget(#WinTest_Btn_Licentie_kopen, #True)
ButtonGadget(#WinTest_Btn_Listrik_niet_starten, 460, 770, 430, 40, GetInterfaceLang("WinTest_Btn_Listrik_niet_starten"))
SetGadgetFont(#WinTest_Btn_Listrik_niet_starten, FontID(#WinTest_Font_0))
BindGadgetEvent(#WinTest_Btn_scherm_1, @Event_WinTest_Btn_scherm_1())
BindGadgetEvent(#WinTest_Btn_scherm_2, @Event_WinTest_Btn_scherm_2())
BindGadgetEvent(#WinTest_Btn_Licentie_kopen, @Event_WinTest_Btn_Licentie_kopen())
BindGadgetEvent(#WinTest_Btn_Listrik_niet_starten, @Event_WinTest_Btn_Listrik_niet_starten())
BindEvent(#PB_Event_SizeWindow, @Resize_WinTest(), #WinTest)
PostEvent(#PB_Event_SizeWindow, #WinTest, 0)
EndIf
EndProcedure
CompilerIf #PB_Compiler_IsMainFile
ExamineDesktops()
Open_WinTest()
Debug DesktopUnscaledX((DesktopWidth(0)-760)/2)
Debug DesktopUnscaledY((DesktopHeight(0)-640)/2)
Debug DesktopUnscaledX(760)
Debug DesktopUnscaledY(640)
;if dpi > 100% this window may be larger than the desktop so resize it according to dpi settings
;ResizeWindow(#WinTest,DesktopUnscaledX((DesktopWidth(0)-760)/2),DesktopUnscaledY((DesktopHeight(0)-640)/2),DesktopUnscaledX(760),DesktopUnscaledY(640))
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
CompilerEndIf
;- DataSection
DataSection
WinTest_Imag_0: : IncludeBinary "C:\Users\willi\Mijn Drive\BAS_PUREBASIC\LISTRIK2\BUTTONS\desktop.png"
EndDataSection
Code: Select all
; Size of work area without taskbar
Define DesktopRect.RECT
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @DesktopRect.RECT, 0)
If DesktopUnscaledX(DesktopRect\right - DesktopRect\left) < 900
ResizeWindow(#WinTest, #PB_Ignore, #PB_Ignore, DesktopUnscaledX(DesktopRect\right - DesktopRect\left), #PB_Ignore)
EndIf
If DesktopUnscaledY(DesktopRect\bottom - DesktopRect\top) < 820
ResizeWindow(#WinTest, #PB_Ignore, #PB_Ignore, #PB_Ignore, DesktopUnscaledY(DesktopRect\bottom - DesktopRect\top))
EndIf
Code: Select all
; Desktop size, including taskbar
If DesktopUnscaledX(DesktopWidth(0)) < 900
ResizeWindow(#WinTest, #PB_Ignore, #PB_Ignore, DesktopUnscaledX(DesktopWidth(0)), #PB_Ignore)
EndIf
If DesktopUnscaledY(DesktopHeight(0)) < 820
ResizeWindow(#WinTest, #PB_Ignore, #PB_Ignore, #PB_Ignore, DesktopUnscaledY(DesktopHeight(0)))
EndIf
Code: Select all
Static WinTest_WidthIni, WinTest_HeightIni
If WinTest_WidthIni = 0
WinTest_WidthIni = WindowWidth(#WinTest) : WinTest_HeightIni = WindowHeight(#WinTest)
EndIf
Code: Select all
Protected WinTest_WidthIni = 900, WinTest_HeightIni = 820
Code: Select all
SendMessage_(GadgetID(#Gadget), #WM_SETREDRAW, #False, 0)
ResizeGadget.....
ResizeGadget.....
SendMessage_(GadgetID(#Gadget), #WM_SETREDRAW, #True, 0)
RedrawWindow_(GadgetID(#Gadget), #Null, #Null, #RDW_INVALIDATE | #RDW_ERASE | #RDW_ALLCHILDREN | #RDW_UPDATENOW)
InvalidateRect does not immediately redraw the window. It simply "schedules" a future redraw for a specific rectangular area of the window. Using InvalidateRect you may schedule as many areas as you want, making them accumulate in some internal buffer. The actual redrawing for all accumulated scheduled areas will take place later, when the window has nothing else to do. (Of course, if the window is idle at the moment when you issue the InvalidateRect call, the redrawing will take place immediately).
You can also force an immediate redraw for all currently accumulated invalidated areas by calling UpdateWindow. But, again, if you are not in a hurry, explicitly calling UpdateWindow is not necessary, since once the window is idle it will perform a redraw for all currently invalidated areas automatically.
RedrawWindow, on the other hand, is a function with a much wider and flexible set of capabilities. It can be used to perform invalidation scheduling (i.e. the same thing InvalidateRect does) or it can be used to forcefully perform immediate redrawing of the specified area, without doing any "scheduling". In the latter case calling RedrawWindow is virtually equivalent to calling InvalidateRect and then immediately calling UpdateWindow.
Code: Select all
CompilerIf #PB_Compiler_Version < 610 : If InitScintilla() : CompilerEndIf ; And the same for the EndIf
Code: Select all
EnableExplicit
XIncludeFile "test1.pb" ; A First Window Form with: #Window_1 And #Button_1
XIncludeFile "test2.pb" ; A Second Window Form with: #Window_2 And #Button_2
Open_Window_1()
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #Button_1 ;
Open_Window_2()
CloseWindow(#Window_1)
Case #Button_2
Open_Window_1()
CloseWindow(#Window_2)
EndSelect
EndSelect
ForEver
Yes thank you i use this example or i let icedesign to create a temp source and i am able to copy and paste in main source, sorry if maybe my request could seem a little senseless, and how the solution is very simple, but I am far from the programming for 10 years and I am very rusty, and I decided to start again from about ten days ago, the first thing that I did it was to buy Icedesign because PureForm has become obsolete, I never liked the original form designer of the PureBasic, I also have purevision but Icedesign convinces me more, thanks for your great jobChrisR wrote: Thu Feb 29, 2024 5:29 pm Otherwise, with IceDesign or other Designers, it's best not to touch the generated code, let the tool do it only.
This way, if you modify the form, you don't have to worry about recreating the code as a replacement.
And to do this, use the "Compile IsMainFile" option in the settings and Create a Main .pb source file with all the forms included and the event loop, ex:
Code: Select all
EnableExplicit XIncludeFile "test1.pb" ; A First Window Form with: #Window_1 And #Button_1 XIncludeFile "test2.pb" ; A Second Window Form with: #Window_2 And #Button_2 Open_Window_1() Repeat Select WaitWindowEvent() Case #PB_Event_CloseWindow Break Case #PB_Event_Menu Select EventMenu() EndSelect Case #PB_Event_Gadget Select EventGadget() Case #Button_1 ; Open_Window_2() CloseWindow(#Window_1) Case #Button_2 Open_Window_1() CloseWindow(#Window_2) EndSelect EndSelect ForEver