IceDesign GUI designer

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: IceDesign GUI designer

Post by VB6_to_PBx »

ChrisR wrote: Fri Apr 05, 2024 2:23 pm Yes, yes, I understand the need for the Tab Order, I've made a note of it in my Todo.
I haven't really thought yet about how to do it, how to present it... I'll take a look but I'll let it mature, no rush, slowly, slowly :wink:

For now, it's pretty easy to do it with a macro and SetWindowPos() Api, ex:

Code: Select all

EnableExplicit

Enumeration Window
  #Window_0
EndEnumeration

Enumeration Gadgets
  #Txt_1
  #String_1
  #Btn_OK
  #Txt_2
  #String_2
  #Txt_3
  #String_3
EndEnumeration

Macro SetTabOrder(_Gadget_)
  SetWindowPos_(GadgetID(_Gadget_), #HWND_BOTTOM, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE)
EndMacro
    
Procedure Open_Window_0(X = 0, Y = 0, Width = 300, Height = 140)
  If OpenWindow(#Window_0, X, Y, Width, Height, "Tab order", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
    TextGadget(#Txt_1, 20, 22, 60, 22, "Text_1")
    StringGadget(#String_1, 80, 20, 120, 24, "String_1")
    ButtonGadget(#Btn_OK, 220, 24, 60, 96, "OK")
    TextGadget(#Txt_2, 20, 62, 60, 22, "Text_2")
    StringGadget(#String_2, 80, 60, 120, 24, "String_2")
    TextGadget(#Txt_3, 20, 102, 60, 22, "Text_3")
    StringGadget(#String_3, 80, 100, 120, 24, "String_3")
    ; Comment/uncomment to use the Gadget creation order or the one defined below
    SetTabOrder(#String_1) : SetTabOrder(#String_2) : SetTabOrder(#String_3) : SetTabOrder(#Btn_OK)
    SetActiveGadget(#String_1)
    ProcedureReturn #True
  EndIf
EndProcedure

If Open_Window_0()
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

ChrisR , i don't know how difficult this would be to use in your Designer ???

Travel thru Gadgets ( example 5)

Code: Select all

EnableExplicit

;- Global
Global.i Window_0
Global.i WW, EW, EM, EG, ET, AG   ;<<--- WW= WaitWindowEvent()  EW= EventWindow()  EM= EventMenu()  EG= EventGadget()  ET= EventType()  AG= GetActiveGadget()
Global.i Gad = 10                 ;<<--- Gad = Array contains the total number of User input Gadgets , such as :  StringGadgets and ComboBoxGadgets in GUI
Global.i Dim G(Gad)               ;<<--- G(Gad) Gadget's numerical numbering system using #PB_Any, SetGadgetData, and GetGadgetData for all User Inputs and Choices             

;========================================================
;-[ Keyboard Shortcut Constants ]
;========================================================
#KeyReturn=10013 : #KeyEscape=10027 : #KeyPageUp=10033 : #KeyPageDown=10034 : #KeyEnd=10035 : #KeyHome=10036 : #KeyUp=10038 : #KeyDown=10040

;- Declare
Declare Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)

Procedure Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)
  Window_0 = OpenWindow(#PB_Any, X, Y, Width, Height, "Title", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)

  ;=====================================================================
  ;- Add Keyboard Shortcuts to travel thru Inputs
  ;=====================================================================
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Return,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Escape,#KeyEscape)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageDown,#KeyPageDown)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageUp,#KeyPageUp)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab | #PB_Shortcut_Shift,#KeyEscape)

  G(1) = StringGadget(#PB_Any, 128, 89, 144, 29,"String_1")
         SetGadgetData(G(1),1)

  G(4) = ComboBoxGadget(#PB_Any, 133, 247, 137, 31)  ;<<--- 4 is out of desired Gadget TAB Order
         AddGadgetItem(G(4), -1, "Combo_4")
         SetGadgetState(G(4), 0)
         SetGadgetData(G(4),4)

  G(2) = ComboBoxGadget(#PB_Any, 129, 147, 141, 27)
         AddGadgetItem(G(2), -1, "Combo_2")
         SetGadgetState(G(2), 0)
         SetGadgetData(G(2),2)

  G(3) = ComboBoxGadget(#PB_Any, 128, 198, 145, 27)
         AddGadgetItem(G(3), -1, "Combo_3")
         SetGadgetState(G(3), 0)
         SetGadgetData(G(3),3)

  SetActiveGadget(G(1))

EndProcedure

;- Main Program
Open_Window_0()

;- Event Loop
Repeat
  WW = WaitWindowEvent(10) ;<<--- Wait until a new Window or Gadget Event occurs.  ( 10 = the timeout in milliseconds or 1000 milliseconds = 1 second ) 
  EW = EventWindow()       ;<<--- In Programs with more than one Form or Window, which Window did the Event occur on
  EM = EventMenu()         ;<<--- Which Menu did the Event occur on
  EG = EventGadget()       ;<<--- Which Gadget did the Event occur on ( #PB_Any Number , a Numerical Number , or Constant #Name of the Gadget )
  ET = EventType()         ;<<--- What sort of Event Type occurred
  AG = GetActiveGadget()   ;<<--- Get the Active Gadget's Numerical Number or Constant #Name that has the current Focus

  Select WW
  Case #PB_Event_Menu
       Select EM
       Case #KeyPageDown, #KeyReturn
             Select GetGadgetData(AG)
             Case 1 To 3 : SetActiveGadget(G(GetGadgetData(AG) + 1))
             Case 4 : SetActiveGadget(G(1))
             EndSelect
       Case #KeyPageUp, #KeyEscape
             Select GetGadgetData(AG)
             Case 1 : SetActiveGadget(G(4))
             Case 2 To 4 : SetActiveGadget(G(GetGadgetData(AG) - 1))
             EndSelect
       EndSelect
  EndSelect
Until WW = #PB_Event_CloseWindow : End







 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: IceDesign GUI designer

Post by ChrisR »

Hi VB6_to_PBx,
It works well for enter and escape, not so easy and unusual for PageUp Down on a laptop keyboard.
It seems rather specific to me to integrate it, I'm not sure that everyone wants this behavior.
For example on a button or on a String with an input check.

To change both the tab Order and include automatic advance with Enter (or return to the previous entry with Esc), it can also be done like this:

Code: Select all

EnableExplicit

Enumeration Window
  #Window_0
EndEnumeration

Enumeration Gadgets
  #Txt_1
  #String_1
  #Btn_OK
  #Txt_2
  #String_2
  #Txt_3
  #String_3
EndEnumeration

Enumeration Shortcuts
  #Shortcut_Return
  #Shortcut_Escape
EndEnumeration

Define InputData.INPUT
InputData\type =#INPUT_KEYBOARD

Macro SetTabOrder(_Gadget_)
  SetWindowPos_(GadgetID(_Gadget_), #HWND_BOTTOM, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE)
EndMacro

Macro SendTabKey()
  InputData\ki\wVk = #VK_TAB
  InputData\ki\dwFlags = 0
  SendInput_(1, @InputData, SizeOf(INPUT)) : Delay(10)
  InputData\ki\dwFlags = #KEYEVENTF_KEYUP
  SendInput_(1, @InputData, SizeOf(INPUT)) : Delay(10)
EndMacro

Macro SendBackTabKey()
  InputData\ki\wVk = #VK_SHIFT
  InputData\ki\dwFlags = 0
  SendInput_(1, @InputData, SizeOf(INPUT)) : Delay(10)
  SendTabKey()
  InputData\ki\wVk = #VK_SHIFT
  InputData\ki\dwFlags = #KEYEVENTF_KEYUP
  SendInput_(1, @InputData, SizeOf(INPUT)) : Delay(10)
EndMacro

Procedure Open_Window_0(X = 0, Y = 0, Width = 300, Height = 140)
  If OpenWindow(#Window_0, X, Y, Width, Height, "Tab order", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
    TextGadget(#Txt_1, 20, 22, 60, 22, "Text_1")
    StringGadget(#String_1, 80, 20, 120, 24, "String_1")
    ButtonGadget(#Btn_OK, 220, 24, 60, 96, "OK")
    TextGadget(#Txt_2, 20, 62, 60, 22, "Text_2")
    StringGadget(#String_2, 80, 60, 120, 24, "String_2")
    TextGadget(#Txt_3, 20, 102, 60, 22, "Text_3")
    StringGadget(#String_3, 80, 100, 120, 24, "String_3")

    ; Comment/uncomment to use the Gadget creation order or the one defined below
    SetTabOrder(#String_1) : SetTabOrder(#String_2) : SetTabOrder(#String_3) : SetTabOrder(#Btn_OK)
    AddKeyboardShortcut(#Window_0,#PB_Shortcut_Return,#Shortcut_Return)
    AddKeyboardShortcut(#Window_0,#PB_Shortcut_Escape,#Shortcut_Escape)
    SetActiveGadget(#String_1)
    ProcedureReturn #True
  EndIf
EndProcedure

If Open_Window_0()
  Repeat
    Select WaitWindowEvent(0)
      Case #PB_Event_CloseWindow
        Break
      Case #PB_Event_Menu
        Select EventMenu()
          Case #Shortcut_Return
            SendTabKey()   ;If GadgetType(GetActiveGadget()) <> #PB_GadgetType_Button : SendTabKey() :EndIf
          Case #Shortcut_Escape
            SendBackTabKey()   ;;If GadgetType(GetActiveGadget()) <> #PB_GadgetType_Button : SendBackTabKey() : EndIf
        EndSelect
    EndSelect
  ForEver
EndIf
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: IceDesign GUI designer

Post by VB6_to_PBx »

ChrisR ... thank you for another method !

i forgot to Post about this :

with PureBasic's built-in Form Designer
all the Variables get listed sideways or horizontally

and with ICE Designer , all the Variables get listed vertically

example :
Enumeration Gadgets
#Txt_1
#String_1
#Btn_OK
#Txt_2
#String_2
#Txt_3
#String_3
EndEnumeration

my current PureBasic commerical Software has 16 Windows + has 476 Gadgets that are 90+% StringGadgets and ComboBoxGadgets
with a few OptionGadgets ... my next version will have 2 more Windows with around 600 Gadgets total (StringGadgets and ComboBoxGadgets)

listing 476 Gadgets either Vertically or Horizontally is pretty long list :D

by using this Method : with Array + #PB_Any, SetGadgetData, and GetGadgetData

Code: Select all

Global.i Gad = 10                 ;<<--- Gad = Array contains the total number of User input Gadgets , such as :  StringGadgets and ComboBoxGadgets in GUI
Global.i Dim G(Gad)               ;<<--- G(Gad) Gadget's numerical numbering system using #PB_Any, SetGadgetData, and GetGadgetData for all User Inputs and Choices    
   
you don't need to create such a huge long Variable List for the majority of User's Inputs + Choices
you greatly decrease the Variable List length
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: IceDesign GUI designer

Post by ChrisR »

IceDesign has been updated in version 2.1.0
  • Added the WebViewGadget.
  • KeepWindowsSize: Added an option in settings to keep Windows position, size and state (Normal, Minimize, Maximize) between run for the generated form.
  • Added options in settings for sorting enumerations and for the number of enumerations per line, to avoid too much scrolling.
    Example here with 6 sorted enumerations per line :

    Code: Select all

    Enumeration Gadgets
      #Check_1 : #Check_2 : #Check_3 : #Check_4 : #Check_5 : #Check_6
      #String_1 : #String_2 : #String_3 : #String_4 : #String_5 : #String_6
      #Txt_1 : #Txt_2 : #Txt_3 : #Txt_4 : #Txt_5 : #Txt_6
    EndEnumeration
    ;or if variables are used
    Global Check_1, Check_2, Check_3, Check_4, Check_5, Check_6
    Global String_1, String_2, String_3, String_4, String_5, String_6
    Global Txt_1, Txt_2, Txt_3, Txt_4, Txt_5, Txt_6
  • Tab Order: Added a "Tab Order" property for all focusable Gadgets.
    The tab order value is free, there is no check if the same number is already used and there are no renumberings.
    The tab order is sorted on this number first, then position Y and position X.
    FYI, It would be quite difficult to select the tab order and display it in the design area, in multi-level mode, only the current level is active and drawn in IceDesign.
    The Tab Order is done using the macro SetTabOrder(#Gadget1) : SetTabOrder(#Gadget2)
    And the order in which Gadgets are created remains unchanged (level,tab,position Y then X), it allows to keep TextGadgets next to strings... and avoid having to open and close containers.
williamvanhoecke
User
User
Posts: 65
Joined: Wed Jun 07, 2017 10:13 pm

Re: IceDesign GUI designer

Post by williamvanhoecke »

Thanks Chris
User avatar
le_magn
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Aug 24, 2005 12:11 pm
Location: Italia

Re: IceDesign GUI designer

Post by le_magn »

Thanks :)
Image
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: IceDesign GUI designer

Post by VB6_to_PBx »

thanks ChrisR for this new Update
i just sent you a Donation
Transaction ID: 2P440924SS045931U
:)
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
williamvanhoecke
User
User
Posts: 65
Joined: Wed Jun 07, 2017 10:13 pm

Re: IceDesign GUI designer

Post by williamvanhoecke »

Chris,
FYI: in the latest version you changed

Enumeration Window
to
Enumeration Windows

This messes up proper numeration.
now I am forced to recompile all windows in my project because conficts
recompiling also means re-doing all manual adjustments :mrgreen:
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: IceDesign GUI designer

Post by ChrisR »

@VB6_to_PBx6
Thank you very much for the donation, it's much appreciated.
I will use it for the next outing with my wife to make up for the time spent on my computer, too much for her taste :wink:

@williamvanhoecke
Oops, you're right about Enumeration Windows.
I changed it when sorting enumerations, enumerations by lines, thinking it would be better with the extra s, like Enumeration Gadgets
I thought about going back to ensure backward compatibility, but I wasn't in front of my computer and i completely forgot then, sorry :oops:
Maybe it's not too late to go back or else leave it as it is, what do you think?
williamvanhoecke
User
User
Posts: 65
Joined: Wed Jun 07, 2017 10:13 pm

Re: IceDesign GUI designer

Post by williamvanhoecke »

Chris,
My commercial project has 34 different windows
I don't know how many users of IceDesign there are but as I recall there was at least one other user that has a lot of windows in one project.
If some just recompiles some of the windows it will create same problems as I had.
I manually removed the 's' from 'windows'.

I think you should go back to window without s
Thanks
williamvanhoecke
User
User
Posts: 65
Joined: Wed Jun 07, 2017 10:13 pm

Re: IceDesign GUI designer

Post by williamvanhoecke »

Chris,
My commercial project has 34 different windows
I don't know how many users of IceDesign there are but as I recall there was at least one other user that has a lot of windows in one project.
If some just recompiles some of the windows it will create same problems as I had.
I manually removed the 's' from 'windows'.

I think you should go back to window without s

I think that the more users there are, backword compatibility becomes more important.

Thanks
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: IceDesign GUI designer

Post by ChrisR »

IceDesign has been updated in version 2.1.1

Fix "Enumeration Window" without the s at the end, to be as before.
williamvanhoecke
User
User
Posts: 65
Joined: Wed Jun 07, 2017 10:13 pm

Re: IceDesign GUI designer

Post by williamvanhoecke »

Thanks Chris
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: IceDesign GUI designer

Post by Michael Vogel »

Chris, I like your IceDesigner, thank you for your work.

I would be able to write a list of thousand feature requests:
- a zoom 200%-function for precise editing
- a configurable offset for duplicate/paste (or additional duplicate below and duplicate right functions)
- editable default prefixes instead of the static #Window_, #Txt_, #Edit_, #String_,...
- and 997 more :lol:

But the main reason for this post is that I don't understand the lock and proportional flags - maybe in this thread are some hints here and there, but I'm still confused.

Just two examples I was failing, first a very simple one:
I'd like to lock the height of all buttons and button #1 should also keep it's width. Only the width of button #2 and #3 should be resized to fill the space when changing the window size.

Here's the designer file with the thre buttons but I don't know how to set the flags correctly:

Code: Select all

[
   {
      "Level"           : 0,
      "Gadget"          : 2,
      "Model"           : "OpenWindow",
      "Type"            : 0,
      "Name"            : "#Window_0",
      "Container"       : 1,
      "ParentGadget"    : 0,
      "TabIndex"        : -65535,
      "X"               : 0,
      "Y"               : 0,
      "Width"           : 320,
      "Height"          : 135,
      "Group"           : 0,
      "Caption"         : "#Titl:Title",
      "Option1"         : "#Tool:000",
      "Option2"         : "#Boun:0|0|0|0",
      "Option3"         : "#Setg:1|2|1|1|1|0|0|1|0|0|0|1|255|1|0|||1|0|2|0|1|32||1|1|0|",
      "FontText"        : "",
      "FrontColor"      : "#Nooo",
      "BackColor"       : "",
      "Lock"            : 0,
      "Disable"         : 0,
      "Hide"            : 0,
      "BindGadget"      : "#Nooo",
      "TabOrder"        : "#Nooo",
      "ToolTip"         : "#Nooo",
      "LockPosition"    : 9,
      "ProportionalSize": 0,
      "Constants"       : "Window_SystemMenu(x)|Window_MinimizeGadget(x)|Window_MaximizeGadget(x)|Window_SizeGadget(x)|Window_Invisible|Window_TitleBar|Window_Tool|Window_BorderLess|Window_ScreenCentered(x)|Window_WindowCentered|Window_Maximize|Window_Minimize|Window_NoGadgets|Window_NoActivate",
      "Key"             : "00-655350003800009"
   },
   {
      "Level"           : 1,
      "Gadget"          : 38240976,
      "Model"           : "ButtonGadget",
      "Type"            : 1,
      "Name"            : "#Btn_1",
      "Container"       : 0,
      "ParentGadget"    : 2,
      "TabIndex"        : -65535,
      "X"               : 5,
      "Y"               : 45,
      "Width"           : 100,
      "Height"          : 24,
      "Group"           : 0,
      "Caption"         : "#Text:Button_1",
      "Option1"         : "",
      "Option2"         : "",
      "Option3"         : "",
      "FontText"        : "",
      "FrontColor"      : "#Nooo",
      "BackColor"       : "#Nooo",
      "Lock"            : 0,
      "Disable"         : 0,
      "Hide"            : 0,
      "BindGadget"      : "0",
      "TabOrder"        : "0",
      "ToolTip"         : "",
      "LockPosition"    : 12,
      "ProportionalSize": 0,
      "Constants"       : "Button_Right|Button_Left|Button_Default|Button_MultiLine|Button_Toggle|#BS_Bottom|#BS_Flat|#BS_Top",
      "Key"             : "01-655350004500005"
   },
   {
      "Level"           : 1,
      "Gadget"          : 38242800,
      "Model"           : "ButtonGadget",
      "Type"            : 1,
      "Name"            : "#Btn_2",
      "Container"       : 0,
      "ParentGadget"    : 2,
      "TabIndex"        : -65535,
      "X"               : 110,
      "Y"               : 45,
      "Width"           : 100,
      "Height"          : 24,
      "Group"           : 0,
      "Caption"         : "#Text:Button_2",
      "Option1"         : "",
      "Option2"         : "",
      "Option3"         : "",
      "FontText"        : "",
      "FrontColor"      : "#Nooo",
      "BackColor"       : "#Nooo",
      "Lock"            : 0,
      "Disable"         : 0,
      "Hide"            : 0,
      "BindGadget"      : "0",
      "TabOrder"        : "0",
      "ToolTip"         : "",
      "LockPosition"    : 33,
      "ProportionalSize": 4,
      "Constants"       : "Button_Right|Button_Left|Button_Default|Button_MultiLine|Button_Toggle|#BS_Bottom|#BS_Flat|#BS_Top",
      "Key"             : "01-655350004500110"
   },
   {
      "Level"           : 1,
      "Gadget"          : 38243568,
      "Model"           : "ButtonGadget",
      "Type"            : 1,
      "Name"            : "#Btn_3",
      "Container"       : 0,
      "ParentGadget"    : 2,
      "TabIndex"        : -65535,
      "X"               : 215,
      "Y"               : 45,
      "Width"           : 100,
      "Height"          : 24,
      "Group"           : 0,
      "Caption"         : "#Text:Button_3",
      "Option1"         : "",
      "Option2"         : "",
      "Option3"         : "",
      "FontText"        : "",
      "FrontColor"      : "#Nooo",
      "BackColor"       : "#Nooo",
      "Lock"            : 0,
      "Disable"         : 0,
      "Hide"            : 0,
      "BindGadget"      : "0",
      "TabOrder"        : "0",
      "ToolTip"         : "",
      "LockPosition"    : 9,
      "ProportionalSize": 0,
      "Constants"       : "Button_Right|Button_Left|Button_Default|Button_MultiLine|Button_Toggle|#BS_Bottom|#BS_Flat|#BS_Top",
      "Key"             : "01-655350004500215"
   }
]

Second example, manually tuned to get the following result when resizing the window:
- at the top, only the combobox gadgets will be resized
- at the bottom, the lower listview gadget should keep it's height, only the upper listview will be resized

Some flickering is given, not sure, if this could be done a little bit better when using the IceDesigner only.

Code: Select all

; Define

	EnableExplicit

	Enumeration
		#Win
		#StatusBar
		#ProgressBar
		#FrmInput
		#TxtSearch
		#CmbSearch
		#ChkCase
		#TxtNearby
		#CmbNearby
		#TrkNearby
		#BtnSearch
		#TxtPath
		#CmbPath
		#FrmResult
		#ListFiles
		#ListSource
	EndEnumeration

	#WinDefaultWidth=540
	#WinDefaultHeight=430

	#PB_DpiBits=		16
	#PB_DpiScale=		1<<#PB_DpiBits
	#PB_ShortcutFlag=	1<<16

	Structure WinType
		StatusbarHeight.i
		DpiScale.i
	EndStructure

	Global Win.WinType

	Macro ScaleUp(value)
		(((value)*Win\DpiScale)>>#PB_DpiBits)
	EndMacro
	Macro ScaleDown(value)
		(((value)<<#PB_DpiBits)/Win\DpiScale)
	EndMacro

; EndDefine

Procedure WinUpdate()

	Protected Width=#WinDefaultWidth
	Protected Height=#WinDefaultHeight
	Protected ScaleX.f,ScaleY.f

	With Win

		If \StatusBarHeight=0
			\StatusBarHeight=StatusBarHeight(#StatusBar)
			ResizeGadget(#ProgressBar,#PB_Ignore,#PB_Ignore,#PB_Ignore,\StatusbarHeight-8)
		EndIf

		Height-\StatusBarHeight

		ScaleX=WindowWidth(#Win)/Width
		ScaleY=(WindowHeight(#Win)-\StatusBarHeight)/Height

		Width=WindowWidth(#Win)
		Height=WindowHeight(#Win)

		ResizeGadget(#FrmInput,10,10,ScaleX*520,120)
		ResizeGadget(#CmbSearch,80,35,Width-170,26)
		ResizeGadget(#ChkCase,Width-75,35,60,26)
		ResizeGadget(#CmbNearby,80,65,Width-170,26)
		ResizeGadget(#TrkNearby,Width-80,65,60,26)
		ResizeGadget(#BtnSearch,Width-80,94,60,28)
		ResizeGadget(#CmbPath,80,95,Width-170,26)
		ResizeGadget(#FrmResult,10,135,ScaleX*520,Height-164)
		ResizeGadget(#ListFiles,20,155,Width-40,Height-299)
		ResizeGadget(#ListSource,20,Height-119-\StatusBarHeight,Width-40,104)

	EndWith

EndProcedure
Procedure WinInit(X=0,Y=0,Width=#WinDefaultWidth,Height=#WinDefaultHeight)

	Win\DpiScale=GetDeviceCaps_(GetDC_(0),#LOGPIXELSX)<<#PB_DpiBits/96;	12 Bit (statt Fließkommaberechnung)

	If OpenWindow(#Win,X,Y,Width,Height,"SearchTool",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)

		If CreateStatusBar(#StatusBar,WindowID(#Win))
			AddStatusBarField(ScaleUp(200))
			AddStatusBarField(#PB_Ignore)
			StatusBarText(#StatusBar,1,"Ok")
			ProgressBarGadget(#ProgressBar,10,4,180,ScaleUp(16),0,100)
			SetParent_(GadgetID(#ProgressBar),StatusBarID(#StatusBar))
		EndIf

		FrameGadget(#FrmInput,10,10,520,120,"Input")
		TextGadget(#TxtSearch,20,35,60,26,"Search:",#SS_CENTERIMAGE|#SS_NOTIFY)
		ComboBoxGadget(#CmbSearch,80,35,370,26,#PB_ComboBox_Editable)
		AddGadgetItem(#CmbSearch,-1,"CmbSearch")
		SetGadgetState(#CmbSearch,0)
		GadgetToolTip(#CmbSearch,"Text to search for...")
		CheckBoxGadget(#ChkCase,465,35,60,26,"Case")
		GadgetToolTip(#ChkCase,"Case sensitive search")
		TextGadget(#TxtNearby,20,65,60,26,"Nearby:",#SS_CENTERIMAGE|#SS_NOTIFY)
		ComboBoxGadget(#CmbNearby,80,65,370,26,#PB_ComboBox_Editable)
		AddGadgetItem(#CmbNearby,-1,"CmbNearby")
		SetGadgetState(#CmbNearby,0)
		GadgetToolTip(#CmbNearby,"Additional text which must be 'nearby' the search text")
		TrackBarGadget(#TrkNearby,460,65,60,26,0,2)
		SetGadgetState(#TrkNearby,1)
		GadgetToolTip(#TrkNearby,"Number of lines above/below to be scanned")
		ButtonGadget(#BtnSearch,460,94,60,28,"Search",#PB_Button_Default)
		GadgetToolTip(#BtnSearch,"Start search")
		TextGadget(#TxtPath,20,95,60,26,"Directory:",#SS_CENTERIMAGE|#SS_NOTIFY)
		ComboBoxGadget(#CmbPath,80,95,370,26,#PB_ComboBox_Editable)
		AddGadgetItem(#CmbPath,-1,"CmbPath")
		SetGadgetState(#CmbPath,0)
		GadgetToolTip(#CmbPath,"Limit search to given sub path")
		FrameGadget(#FrmResult,10,141,520,260,"Result")
		ListIconGadget(#ListFiles,20,161,500,125,"Path",120)
		AddGadgetColumn(#ListFiles,1,"Filename",400)
		AddGadgetColumn(#ListFiles,2,"File date",100)
		AddGadgetItem(#ListFiles,-1,"ListFiles")
		GadgetToolTip(#ListFiles,"Select to view code lines, double click to load the source file...")
		ListIconGadget(#ListSource,20,288,500,104,"Line",120)
		AddGadgetColumn(#ListSource,1,"Code",400)
		AddGadgetItem(#ListSource,-1,"ListSource")
		GadgetToolTip(#ListSource,"Double click to copy the selected line into the clipboard")
		WindowBounds(#Win,400,400,2000,1200)

		BindEvent(#PB_Event_SizeWindow,@WinUpdate(),#Win)
		PostEvent(#PB_Event_SizeWindow,#Win,0)
		HideWindow(#Win,0)
		SetActiveGadget(#CmbSearch)
		ProcedureReturn #True
	EndIf

EndProcedure

If WinInit()

	Repeat
		Select WaitWindowEvent()
			Case#PB_Event_CloseWindow
			Break

		Case #PB_Event_Gadget
			Select EventGadget()
			Case #TxtPath
				Debug "*"
			Case #ChkCase
				Debug "-"
			Case #BtnSearch;Search
				Debug "!"
			EndSelect

		EndSelect
	ForEver
EndIf
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: IceDesign GUI designer

Post by Caronte3D »

I think you should put buttons 2 and 3 inside a container.

Something like that:

Code: Select all

[
   {
      "Level"           : 0,
      "Gadget"          : 2,
      "Model"           : "OpenWindow",
      "Type"            : 0,
      "Name"            : "#Window_0",
      "Container"       : 1,
      "ParentGadget"    : 0,
      "TabIndex"        : -65535,
      "X"               : 0,
      "Y"               : 0,
      "Width"           : 455,
      "Height"          : 121,
      "Group"           : 0,
      "Caption"         : "#Titl:Title",
      "Option1"         : "#Tool:000",
      "Option2"         : "#Boun:0|0|0|0",
      "Option3"         : "#Setg:1|2|1|1|1|0|0|0|0|0|0|1|255|1|0|||1|0|2|0|1|32|",
      "FontText"        : "",
      "FrontColor"      : "#Nooo",
      "BackColor"       : "",
      "Lock"            : 0,
      "Disable"         : 0,
      "Hide"            : 0,
      "BindGadget"      : "#Nooo",
      "ToolTip"         : "#Nooo",
      "LockPosition"    : 9,
      "ProportionalSize": 0,
      "Constants"       : "Window_SystemMenu(x)|Window_MinimizeGadget(x)|Window_MaximizeGadget(x)|Window_SizeGadget(x)|Window_Invisible|Window_TitleBar|Window_Tool|Window_BorderLess|Window_ScreenCentered(x)|Window_WindowCentered|Window_Maximize|Window_Minimize|Window_NoGadgets|Window_NoActivate",
      "Key"             : "00-655350003100008"
   },
   {
      "Level"           : 1,
      "Gadget"          : 248893856,
      "Model"           : "ContainerGadget",
      "Type"            : 11,
      "Name"            : "#Cont_1",
      "Container"       : 1,
      "ParentGadget"    : 2,
      "TabIndex"        : -65535,
      "X"               : 136,
      "Y"               : 0,
      "Width"           : 300,
      "Height"          : 120,
      "Group"           : 0,
      "Caption"         : "",
      "Option1"         : "",
      "Option2"         : "",
      "Option3"         : "",
      "FontText"        : "#Nooo",
      "FrontColor"      : "#Nooo",
      "BackColor"       : "",
      "Lock"            : 0,
      "Disable"         : 0,
      "Hide"            : 0,
      "BindGadget"      : "#Nooo",
      "ToolTip"         : "",
      "LockPosition"    : 45,
      "ProportionalSize": 0,
      "Constants"       : "Container_BorderLess(x)|Container_Flat|Container_Raised|Container_Single|Container_Double",
      "Key"             : "01-655350000000136"
   },
   {
      "Level"           : 1,
      "Gadget"          : 248891552,
      "Model"           : "ButtonGadget",
      "Type"            : 1,
      "Name"            : "#Btn_1",
      "Container"       : 0,
      "ParentGadget"    : 2,
      "TabIndex"        : -65535,
      "X"               : 21,
      "Y"               : 40,
      "Width"           : 115,
      "Height"          : 45,
      "Group"           : 0,
      "Caption"         : "#Text:Button_1",
      "Option1"         : "",
      "Option2"         : "",
      "Option3"         : "",
      "FontText"        : "",
      "FrontColor"      : "#Nooo",
      "BackColor"       : "#Nooo",
      "Lock"            : 0,
      "Disable"         : 0,
      "Hide"            : 0,
      "BindGadget"      : "0",
      "ToolTip"         : "",
      "LockPosition"    : 9,
      "ProportionalSize": 0,
      "Constants"       : "Button_Right|Button_Left|Button_Default|Button_MultiLine|Button_Toggle|#BS_Bottom|#BS_Flat|#BS_Top",
      "Key"             : "01-655350004000021"
   },
   {
      "Level"           : 2,
      "Gadget"          : 248890592,
      "Model"           : "ButtonGadget",
      "Type"            : 1,
      "Name"            : "#Btn_1_1_1_1_1",
      "Container"       : 0,
      "ParentGadget"    : 248893856,
      "TabIndex"        : -65535,
      "X"               : 2,
      "Y"               : 40,
      "Width"           : 150,
      "Height"          : 45,
      "Group"           : 0,
      "Caption"         : "#Text:Button_2",
      "Option1"         : "",
      "Option2"         : "",
      "Option3"         : "",
      "FontText"        : "",
      "FrontColor"      : "#Nooo",
      "BackColor"       : "#Nooo",
      "Lock"            : 0,
      "Disable"         : 0,
      "Hide"            : 0,
      "BindGadget"      : "0",
      "ToolTip"         : "",
      "LockPosition"    : 8,
      "ProportionalSize": 5,
      "Constants"       : "Button_Right|Button_Left|Button_Default|Button_MultiLine|Button_Toggle|#BS_Bottom|#BS_Flat|#BS_Top",
      "Key"             : "02-655350004000002"
   },
   {
      "Level"           : 2,
      "Gadget"          : 248894240,
      "Model"           : "ButtonGadget",
      "Type"            : 1,
      "Name"            : "#Btn_1_1_1_2_1",
      "Container"       : 0,
      "ParentGadget"    : 248893856,
      "TabIndex"        : -65535,
      "X"               : 154,
      "Y"               : 40,
      "Width"           : 146,
      "Height"          : 45,
      "Group"           : 0,
      "Caption"         : "#Text:Button_2",
      "Option1"         : "",
      "Option2"         : "",
      "Option3"         : "",
      "FontText"        : "",
      "FrontColor"      : "#Nooo",
      "BackColor"       : "#Nooo",
      "Lock"            : 0,
      "Disable"         : 0,
      "Hide"            : 0,
      "BindGadget"      : "0",
      "ToolTip"         : "",
      "LockPosition"    : 8,
      "ProportionalSize": 5,
      "Constants"       : "Button_Right|Button_Left|Button_Default|Button_MultiLine|Button_Toggle|#BS_Bottom|#BS_Flat|#BS_Top",
      "Key"             : "02-655350004000154"
   }
]
Post Reply