PureBasic Forum
http://forums.purebasic.com/english/

Gadgets Height on each OS
http://forums.purebasic.com/english/viewtopic.php?f=12&t=72894
Page 1 of 1

Author:  marcoagpinto [ Wed May 29, 2019 4:14 am ]
Post subject:  Gadgets Height on each OS

Hello!

Since depending on the OS the height of the gadgets change, I created this little snippet that will show the height size.

Just select a font and run it on your target OSes.

Code:
    Enumeration
      #WINDOW_MAIN
      #BUTTON
      #TEXT
      #STRING
      #COMBOBOX
      #CHECKBOX
      #RADIOBUTTON
      #SPIN
    EndEnumeration

   
   
    Procedure GadgetFit(gadget)
 
      x=GadgetX(gadget)
      y=GadgetY(gadget)
      w=GadgetWidth(gadget)
      h=GadgetHeight(gadget)
      w_new=GadgetWidth(gadget,#PB_Gadget_RequiredSize)
      h_new=GadgetHeight(gadget,#PB_Gadget_RequiredSize)
 
      If w<>w_new Or h<>h_new
        ResizeGadget(gadget,x,y,w_new,h_new)     
      EndIf
 
    EndProcedure
   
   
   
    ; Open a Window
    If OpenWindow(#WINDOW_MAIN,0,0,1024,600,"Gadgets Height on each OS",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)=#False : MessageRequester("Error", "Can't open a window.", #PB_MessageRequester_Error) : EndIf
   
   
    t=LoadFont(1,"Arial",10,#PB_Font_HighQuality) ;Load Arial Font, Size 10
    If t=#False : MessageRequester("Error", "Can't load Arial font.",#PB_MessageRequester_Error) : EndIf   
    SetGadgetFont(#PB_Default,FontID(1))   
   
   
    x=10
    y=10
   
   
    ; Button Gadget
    ButtonGadget(#BUTTON,x,y,200,200,"ZXp")
    GadgetFit(#BUTTON)
    Debug "Button Gadget:"+Str(GadgetHeight(#BUTTON))
   
    x+100
   
    ; Text Gadget
    TextGadget(#TEXT,x,y,200,200,"ZXp")
    GadgetFit(#TEXT)
    Debug "Text Gadget:"+Str(GadgetHeight(#TEXT))
   
   
    x+100
   
   
    ; String Gadget
    StringGadget(#STRING,x,y,200,200,"ZXp")
    GadgetFit(#STRING)
    Debug "String Gadget:"+Str(GadgetHeight(#STRING))
   
   
    x+100
   
    ; Combobox Gadget
    ComboBoxGadget(#COMBOBOX,x,y,200,200)
    AddGadgetItem(#COMBOBOX,-1,"ZXp")
    GadgetFit(#COMBOBOX)
    Debug "Combobox Gadget:"+Str(GadgetHeight(#COMBOBOX))
     
   
    x+100
   
    ; CheckBox Gadget
    CheckBoxGadget(#CHECKBOX,x,y,200,200,"ZXp")
    GadgetFit(#CHECKBOX)
    Debug "CheckBox Gadget:"+Str(GadgetHeight(#CHECKBOX))   
     
   
    x+100
   
    ; RadioButton Gadget
    OptionGadget(#RADIOBUTTON,x,y,200,200,"ZXp")
    GadgetFit(#RADIOBUTTON)
    Debug "RadioButton Gadget:"+Str(GadgetHeight(#RADIOBUTTON))
   
   
   
    x+100
   
    ; Spin Gadget
    OptionGadget(#SPIN,x,y,200,200,"ZXp")
    GadgetFit(#SPIN)
    Debug "Spin Gadget:"+Str(GadgetHeight(#SPIN))

Author:  marcoagpinto [ Thu Aug 22, 2019 8:32 pm ]
Post subject:  Re: Gadgets Height on each OS

Hello!

I had forgotten the ProgressBar Gadget:

Code:
    Enumeration
      #WINDOW_MAIN
      #BUTTON
      #TEXT
      #STRING
      #COMBOBOX
      #CHECKBOX
      #RADIOBUTTON
      #SPIN
      #PROGRESSBAR
    EndEnumeration

   
   
    Procedure GadgetFit(gadget)
 
      x=GadgetX(gadget)
      y=GadgetY(gadget)
      w=GadgetWidth(gadget)
      h=GadgetHeight(gadget)
      w_new=GadgetWidth(gadget,#PB_Gadget_RequiredSize)
      h_new=GadgetHeight(gadget,#PB_Gadget_RequiredSize)
 
      If w<>w_new Or h<>h_new
        ResizeGadget(gadget,x,y,w_new,h_new)     
      EndIf
 
    EndProcedure
   
   
   
    ; Open a Window
    If OpenWindow(#WINDOW_MAIN,0,0,1024,600,"Gadgets Height on each OS",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)=#False : MessageRequester("Error", "Can't open a window.", #PB_MessageRequester_Error) : EndIf
   
   
    t=LoadFont(1,"Arial",10,#PB_Font_HighQuality) ;Load Arial Font, Size 10
    If t=#False : MessageRequester("Error", "Can't load Arial font.",#PB_MessageRequester_Error) : EndIf   
    SetGadgetFont(#PB_Default,FontID(1))   
   
   
    x=10
    y=10
   
   
    ; Button Gadget
    ButtonGadget(#BUTTON,x,y,200,200,"ZXpy")
    GadgetFit(#BUTTON)
    Debug "Button Gadget:"+Str(GadgetHeight(#BUTTON))
   
    x+100
   
    ; Text Gadget
    TextGadget(#TEXT,x,y,200,200,"ZXpy")
    GadgetFit(#TEXT)
    Debug "Text Gadget:"+Str(GadgetHeight(#TEXT))
   
   
    x+100
   
   
    ; String Gadget
    StringGadget(#STRING,x,y,200,200,"ZXpy")
    GadgetFit(#STRING)
    Debug "String Gadget:"+Str(GadgetHeight(#STRING))
   
   
    x+100
   
    ; Combobox Gadget
    ComboBoxGadget(#COMBOBOX,x,y,200,200)
    AddGadgetItem(#COMBOBOX,-1,"ZXpy")
    GadgetFit(#COMBOBOX)
    Debug "Combobox Gadget:"+Str(GadgetHeight(#COMBOBOX))
     
   
    x+100
   
    ; CheckBox Gadget
    CheckBoxGadget(#CHECKBOX,x,y,200,200,"ZXpy")
    GadgetFit(#CHECKBOX)
    Debug "CheckBox Gadget:"+Str(GadgetHeight(#CHECKBOX))   
     
   
    x+100
   
    ; RadioButton Gadget
    OptionGadget(#RADIOBUTTON,x,y,200,200,"ZXpy")
    GadgetFit(#RADIOBUTTON)
    Debug "RadioButton Gadget:"+Str(GadgetHeight(#RADIOBUTTON))
   
   
   
    x+100
   
    ; Spin Gadget
    SpinGadget(#SPIN,x,y,1,1,0,50)
    SetGadgetText(#SPIN,"9990")
    GadgetFit(#SPIN)
    Debug "Spin Gadget:"+Str(GadgetHeight(#SPIN))
   
   
   
    x+100
   
    ; ProgressBar Gadget
    ProgressBarGadget(#PROGRESSBAR,x,y,1000,1000,0,100)
    GadgetFit(#PROGRESSBAR)
    Debug "ProgressBar Gadget (width):"+Str(GadgetWidth(#PROGRESSBAR))
    Debug "ProgressBar Gadget (height):"+Str(GadgetHeight(#PROGRESSBAR))
   
   

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/