Upgrade from GTK 2 to GTK 3

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Upgrade from GTK 2 to GTK 3

Post by Guimauve »

Hello everyone,

This wishlist is more for Linux than anything else, anyway ...
  • 1. Upgrade from GTK 2 to GTK 3 for the Gadget library will be nice.
  • 2. Add GtkSwitch Gadget
  • 3. Add GtkSpinner Gadget
Maybe for PB V4.70.

Best regards.
Guimauve
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: Upgrade from GTK 2 to GTK 3

Post by Kukulkan »

+1

But I like to see a cross-platform layouting engine, too. It is annoying to create linux programs that most times looking like crap on other systems because the size of the gadgets, fonts, frames etc. is not the same than on yours...

Kukulkan
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: Upgrade from GTK 2 to GTK 3

Post by Guimauve »

Kukulkan wrote:But I like to see a cross-platform layouting engine, too. It is annoying to create linux programs that most times looking like crap on other systems because the size of the gadgets, fonts, frames etc. is not the same than on yours
This will be impossible just because End-Users can change the system default font. So the GUI look will change from one platform to the other. For example on Windows, I can be wrong, the default Font is "Trebuchet MS", on Linux Mint 12, I use "Mint Spirit" as default font.

So my program don't have the same look on Windows and on Linux. Sending the font you use for your GUI along with your program is the only way out.

Best regards
Guimauve
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Upgrade from GTK 2 to GTK 3

Post by Trond »

Guimauve wrote:
Kukulkan wrote:But I like to see a cross-platform layouting engine, too. It is annoying to create linux programs that most times looking like crap on other systems because the size of the gadgets, fonts, frames etc. is not the same than on yours
This will be impossible just because End-Users can change the system default font. So the GUI look will change from one platform to the other. For example on Windows, I can be wrong, the default Font is "Trebuchet MS", on Linux Mint 12, I use "Mint Spirit" as default font.
He wants gadgets to scale automatically with the font size.
naw
Enthusiast
Enthusiast
Posts: 573
Joined: Fri Apr 25, 2003 4:57 pm

Re: Upgrade from GTK 2 to GTK 3

Post by naw »

Maybe there is a way to determine the default font height and average width in pixels to determine relative sizing and positioning of gadgets in an appropriately sized window?
Ta - N
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: Upgrade from GTK 2 to GTK 3

Post by Kukulkan »

He wants gadgets to scale automatically with the font size.
Yes, this is what I talk about. There are some layout engines like the one delivered with wxwidgets (http://docs.wxwidgets.org/stable/wx_siz ... eroverview). It allows you to create dialogs that resize to the needed size and keep the layout usable even with scaled fonts and other layout styles. It is very handy for people with bad eyes, too...

But you have to drop the idea to set positions pixel-wise. It is more something like "place this button right from that one, but keep it in the window bounds respecting font size and caption".

Kukulkan
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Upgrade from GTK 2 to GTK 3

Post by Foz »

I started writing a dynamic cross platform form designer to address this just using pure pb gadgets, but as I switched from Linux back to Windows, development stopped.

Essentially, it was a system where you told it what controls you wanted and in what order, but the background code did all the positioning based on the control sizes. Naturally, window sizing and resizing is automatically handled for you.

This was made possible by virtual "Vertical" and "Horizontal" containers - gadgets added, would be added in vertical or horizontal orientation. For example this bit of xml:

Code: Select all

<Window Name = "Window1" Text = "Dynamic Test!">
  <VBox SizingVertically = "1" SizingHorizontally = "1" Name = "Container_frmShowOff">
    <GBox SizingVertically = "1" SizingHorizontally = "1" Name = "frmShowOff" Text = "Collection Address">
      <VBox SizingVertically = "1" SizingHorizontally = "1" Name = "Items_vbox_frmShowOff">
        <HBox SizingVertically = "0" SizingHorizontally = "1" Name = "Items_hbox1_frmShowOff">
          <Text SizingVertically = "2" SizingHorizontally = "0" Text = "Name :"/>
          <String SizingVertically = "2" SizingHorizontally = "1" Name = "Collection_strName"/>
        </HBox>
        <HBox SizingVertically = "0" SizingHorizontally = "1">
          <Text SizingVertically = "2" SizingHorizontally = "0" Text = "Line 1 :"/>
          <String SizingVertically = "2" SizingHorizontally = "1" Name = "Collection_strLine1"/>
        </HBox>
      </VBox>
      <Spacer SizingVertically = "0" SizingHorizontally = "1" Name = "Spacer1"/>
      <Button SizingVertically = "1" SizingHorizontally = "1" Name = "ButtonMax1" Text = "Click!"/>
    </GBox>
  </VBox>
</Window>
produces this form:
Image

It had three main issues that remaining that I had to address:
Group Boxes - it's a container graphically and yet not a container.
Tables - I haven't a clue on how to write this one, espcially as spanning rows and columns is essential to make it useful.
Code Integration - I haven't decided on the best method of making a "window" for working on later. Should I read the code directly? Stick to xml? What about event wiring?

Is this what you are basically after?
User avatar
greyhoundcode
Enthusiast
Enthusiast
Posts: 112
Joined: Sun Dec 30, 2007 7:24 pm

Re: Upgrade from GTK 2 to GTK 3

Post by greyhoundcode »

That's interesting Foz, rather similar in concept to XAML, XUL or even HTML - I've often thought that a good library leveraging the capabilities of something like Gecko would be an awesome platform for developing UIs (which is pretty much what XUL does of course).

How far did you get with this?
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Upgrade from GTK 2 to GTK 3

Post by Foz »

My inspiration came from a little program called "xulpix" which is a mozilla gui designer.

My issue with a separate xml file was that while it could produce decently designed forms, linking events between the xml and the pb code turned into a nightmare.

So I transformed it into straight pb code, with the idea that the designer would "read" the raw pb code and overwrite it - in the same way as other form designers work as well as handle gadget events.

This bit of code was hand written, and I was up to the point of creating a designer to read first, and then write out the code:

Code: Select all

XIncludeFile "purevd.pbi"

; Test template

;{-- purevd start
Declare btnOk_Click()
Declare btnCancel_Click()

Procedure InitialiseGadgets()
  Protected rv.i, WinID.i, tmpID.i
  NewList Contain.i()
  
  ; AddGadget(pName.s, pParentID.i, pGadgetType.i, pText.s, pDesiredWidth.i, pDesiredHeight.i, pFlexWidthType.b, pFlexHeightType.b, pFlags.i = 0, pPath.s = "")
  
  ; add the window
  AddElement(Contain())
  Contain() = AddGadget("winMain", -1, -1, #PB_GadgetType_Window, "Main Window", 600, 400, 0, 0, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
  WinID = Contain()
  
  ; All controls to be added here is in a verticle arrangement (vbox)
  tmpID = Contain()
  AddElement(Contain())
  Contain() = AddGadget("Container_frmShowOff", tmpID, WinID, #PB_GadgetType_VBox, "", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  ; add a frame
  tmpID = Contain()
  AddElement(Contain())
  Contain() = AddGadget("frmShowOff", tmpID, WinID, #PB_GadgetType_Frame3D, "Showing Off", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  ; All controls to be added here is in a verticle arrangement (vbox)
  tmpID = Contain()
  AddElement(Contain())
  Contain() = AddGadget("Items_vbox_frmShowOff", tmpID, WinID, #PB_GadgetType_VBox, "", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  ; All controls to be added here is in a horizontal arrangement (hbox)
  tmpID = Contain()
  AddElement(Contain())
  Contain() = AddGadget("Items_hbox1_frmShowOff", tmpID, WinID, #PB_GadgetType_HBox, "", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  ; add a text gadget set to minimum size
  AddGadget("txtShowOff1", Contain(), WinID, #PB_GadgetType_Text, "Name", #PB_Any, #PB_Any, #Sizing_MinimumSize, #Sizing_Centre)
  ; add a string gadget set to fill the rest of the frame
  AddGadget("strShowOff1", Contain(), WinID, #PB_GadgetType_String, "<Name goes here>", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Centre)
  
  DeleteElement(Contain()) ; back up to frame
  
  ; add another set of controls in a horizontal arrangement (hbox)
  tmpID = Contain()
  AddElement(Contain())
  Contain() = AddGadget("Items_hbox2_frmShowOff", tmpID, WinID, #PB_GadgetType_HBox, "", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  ; add a text gadget set to minimum size
  AddGadget("txtShowOff2", Contain(), WinID, #PB_GadgetType_Text, "E-mail", #PB_Any, #PB_Any, #Sizing_MinimumSize, #Sizing_Centre)
  ; add a string gadget set to fill the rest of the frame
  AddGadget("strShowOff2", Contain(), WinID, #PB_GadgetType_String, "<Password goes here>", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Centre)
  
  
   DeleteElement(Contain()) ; back up to frame vbox
   DeleteElement(Contain()) ; back up to frame
   DeleteElement(Contain()) ; back up to window vbox
  
  AddGadget("spacer1", Contain(), WinID, #PB_GadgetType_Spacer, "", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  AddGadget("btnOk", Contain(), WinID, #PB_GadgetType_Button, "OK", 100, 100, #Sizing_Fixed, #Sizing_Fixed)
  AddGadget("btnCancel", Contain(), WinID, #PB_GadgetType_Button, "Cancel", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
EndProcedure

Procedure GadgetEventSelection(pWindowEvent, pGadgetEvent, pTypeEvent)
  ForEach gl()
    If pWindowEvent = gl()\WindowID And gl()\ID = pGadgetEvent
      Break
    EndIf
  Next
  
  Select gl()\Name
    Case "btnOk"
      If pTypeEvent = #PB_EventType_LeftClick
        btnOK_Click()
      EndIf
    Case "btnCancel"
      If pTypeEvent = #PB_EventType_LeftClick
        btnCancel_Click()
      EndIf
  EndSelect
  
EndProcedure

Procedure MenuEventSelection(pWindowEvent, pMenuEvent)
  ForEach gl()
    If pWindowEvent = gl()\WindowID And gl()\ID = pMenuEvent
      Break
    EndIf
  Next
  
  Select gl()\Name
  EndSelect
EndProcedure

;}-- purevd end

Procedure btnOk_Click()
  MessageRequester("Main", "Name:" + GetGadgetText(GetGadgetID("winMain", "strShowOff1")) + Chr(13)+Chr(10) + "Email:" + GetGadgetText(GetGadgetID("winMain", "strShowOff2")))
EndProcedure

Procedure btnCancel_Click()
  MessageRequester("Main", "Cancel")
EndProcedure

InitialiseGadgets()
EventLoop()
Post Reply