It is currently Mon Oct 21, 2019 4:08 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Gadget arrays?
PostPosted: Wed Oct 02, 2019 5:42 am 
Offline
Enthusiast
Enthusiast

Joined: Sun Apr 06, 2008 12:54 pm
Posts: 374
Location: Brisbane, Qld, Australia
Having started with PureBasic in the days before Form Designer was available, I hard-coded my form layouts. But I've decided it's time I had a look at Form Designer, and what I've found so far I like. However, something I need often is to have arrays of gadgets within a ScrollAreaGadget. These typically include a mixture of string gadgets, combobox gadgets and possibly also a button gadget. I know I can set up one row of these in Form Designer, then select them all, then and copy and paste them multiple times. But all these gadgets will have unique names. What I want is to have the generated code create gadget arrays, and a loop that contains just one subscripted instance of each gadget in the row. This is necessary to simplify populating and processing the rows. Is this possible using Form Designer?

_________________
Mike
www.showcuesystems.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Gadget arrays?
PostPosted: Thu Oct 03, 2019 10:26 am 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1969
Location: Germany
I don't know any designer who can create arrays.

But if you use constants (not PB_Any) you can use the tab order.
The FormDesigner can handle this if you change the order of the gadgets in the OpenWindow procedure.
Switch to code view and sort the gadgets. Then switch back to Designer View and save it so that the designer can recreate the enumeration.

Code:
;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;

Enumeration FormWindow
  #Window_0
EndEnumeration

Enumeration FormGadget
  #Text_0
  #Text_1
  #Text_2
  #String_0
  #String_1
  #String_2
EndEnumeration


Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
  OpenWindow(#Window_0, x, y, width, height, "", #PB_Window_SystemMenu)
  TextGadget(#Text_0, 10, 10, 80, 30, "")
  TextGadget(#Text_1, 10, 50, 80, 30, "")
  TextGadget(#Text_2, 10, 90, 80, 20, "")
  StringGadget(#String_0, 100, 10, 120, 30, "")
  StringGadget(#String_1, 100, 50, 120, 30, "")
  StringGadget(#String_2, 100, 90, 120, 30, "")
EndProcedure

Code:
IncludeFile "Form1.pbf"

Global Dim sVal.s(3)
sVal(0) = "String 1"
sVal(1) = "String 2"
sVal(2) = "String 3"

Procedure Main()
  Protected i, index
 
  OpenWindow_0()
 
  If WindowID(#Window_0)
   
    For i = #String_0 To #String_2
      index = i - #String_0
      SetGadgetText(i, sVal(index))
    Next
   
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
         
      EndSelect
    ForEver
   
  EndIf
 
EndProcedure : Main()

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: Gadget arrays?
PostPosted: Fri Oct 04, 2019 2:07 am 
Offline
Enthusiast
Enthusiast

Joined: Sun Apr 06, 2008 12:54 pm
Posts: 374
Location: Brisbane, Qld, Australia
Thanks, mk-soft. That's very helpful. Being able to reorder the gadgets in the OpenWindow procedure and having Form Designer accept the new order is definitely a workable solution.

_________________
Mike
www.showcuesystems.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye