PB5.50B1 - PanelGadget() + GetGadgetAttribute()

Post bugreports for the Linux version here
User avatar
StarBootics
Addict
Addict
Posts: 984
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

PB5.50B1 - PanelGadget() + GetGadgetAttribute()

Post by StarBootics »

Hello,

The following code explain everything

Best regards
StarBootics

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : PanelGadget() + GetGadgetAttribute(0, #PB_Panel_...)
; File Name : PanelGadget + GetGadgetAttribute.pb
; File version: 1.0.0
; Programming : Bug Demo
; Programmed by : StarBootics
; Date : 05-06-2016
; Last Update : 06-06-2016
; PureBasic code : V5.50 B1 x64
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Bug Description
;
; GetGadgetAttribute(0, #PB_Panel_TabHeight)  --> Return -1 
; GetGadgetAttribute(0, #PB_Panel_ItemWidth)  --> Return 1
; GetGadgetAttribute(0, #PB_Panel_ItemHeight) --> Return 1
;
; PureBasic 5.50B1 x64
; Ubuntu Gnome 16.04 x64
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
  PanelGadget     (0, 8, 8, 306, 203)
    AddGadgetItem (0, -1, "Onglet 1")
    
    Debug GetGadgetAttribute(0, #PB_Panel_TabHeight)
    Debug GetGadgetAttribute(0, #PB_Panel_ItemWidth) 
    Debug GetGadgetAttribute(0, #PB_Panel_ItemHeight)

    PanelGadget (1, 5, 5, 290, 166)
      AddGadgetItem(1, -1, "Sous-onglet 1")
      AddGadgetItem(1, -1, "Sous-onglet 2")
      AddGadgetItem(1, -1, "Sous-onglet 3")
    CloseGadgetList()
    AddGadgetItem (0, -1,"Onglet 2")
    ButtonGadget(2, 10, 15, 80, 24,"Bouton 1")
    ButtonGadget(3, 95, 15, 80, 24,"Bouton 2")
  CloseGadgetList()
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
The Stone Age did not end due to a shortage of stones !
User avatar
StarBootics
Addict
Addict
Posts: 984
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: PB5.50B1 - PanelGadget() + GetGadgetAttribute()

Post by StarBootics »

After 5 years I completely forget that I have already posted a bug about this.

Any news about this problem ?

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
HeX0R
Addict
Addict
Posts: 980
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: PB5.50B1 - PanelGadget() + GetGadgetAttribute()

Post by HeX0R »

Seems to run fine with qt subsystem at least.
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB5.50B1 - PanelGadget() + GetGadgetAttribute()

Post by Fred »

The widget needs to be fully realized in GTK to be able to query this. I don't think we can workaround this unfortunately. Will update the doc to reflect this.
Check the difference when clicking on the button:

Code: Select all

If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
  PanelGadget     (0, 8, 8, 306, 203)
  AddGadgetItem (0, -1, "Onglet 1")
  ButtonGadget(1, 10, 10, 50, 30, "Test")
  CloseGadgetList()
  
  Debug GetGadgetAttribute(0, #PB_Panel_TabHeight)
  Debug GetGadgetAttribute(0, #PB_Panel_ItemWidth) 
  Debug GetGadgetAttribute(0, #PB_Panel_ItemHeight)
  
  Repeat 
    event = WaitWindowEvent()
    If event = #PB_Event_Gadget And EventGadget() = 1
      Debug GetGadgetAttribute(0, #PB_Panel_TabHeight)
      Debug GetGadgetAttribute(0, #PB_Panel_ItemWidth) 
      Debug GetGadgetAttribute(0, #PB_Panel_ItemHeight)
    EndIf
    
  Until event = #PB_Event_CloseWindow
EndIf
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: PB5.50B1 - PanelGadget() + GetGadgetAttribute()

Post by Shardik »

A simple workaround would be to wait in a While..Wend loop until the TabHeight changes from -1 to another value:

Code: Select all

OpenWindow(0, 100, 100, 200, 150, "PanelGadget") 
PanelGadget (0, 10, 10, 180, 130)
AddGadgetItem (0, -1, "Tab 1")

While GetGadgetAttribute(0, #PB_Panel_TabHeight) = -1
  Delay(10)
Wend

Debug "Tab height: " + GetGadgetAttribute(0, #PB_Panel_TabHeight)
Debug "Panel width: " + GetGadgetAttribute(0, #PB_Panel_ItemWidth) 
Debug "Panel height: " + GetGadgetAttribute(0, #PB_Panel_ItemHeight)

Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB5.50B1 - PanelGadget() + GetGadgetAttribute()

Post by Fred »

Unfortunately, this workaround doesn't work if the window is invisible and blocks the whole program:

Code: Select all

OpenWindow(0, 100, 100, 200, 150, "PanelGadget", #PB_Window_Invisible) 
PanelGadget (0, 10, 10, 180, 130)
AddGadgetItem (0, -1, "Tab 1")

a = ElapsedMilliseconds()
While GetGadgetAttribute(0, #PB_Panel_TabHeight) = -1
  Delay(10)
Wend

Debug ElapsedMilliseconds() -a 

Debug "Tab height: " + GetGadgetAttribute(0, #PB_Panel_TabHeight)
Debug "Panel width: " + GetGadgetAttribute(0, #PB_Panel_ItemWidth) 
Debug "Panel height: " + GetGadgetAttribute(0, #PB_Panel_ItemHeight)

Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow
Post Reply