(Problem exist on Ubuntu, not under windows.)
I think I have isolated the problem, in the code below, of not being able to draw the gadgets.
OpenGadgetList(hnd) and CloseGadgetList() combined with the flag #PB_Canvas_Container.
Yet why is still not clear to me.
If the #PB_Canvas_Container is not set only CloseGadgetList() gives problems, OpenGadgetList(hnd) doesn't.
If the #PB_Canvas_Container is set OpenGadgetList(hnd) and CloseGadgetList() gives problems. No gadgets are drawn.
So the sollution looks more like, add gadgets at runtime : change the flag #PB_Canvas_Container.
What else if adding gadgets at runtime to more then one canvas ?
To me there is something wrong in the order of using these three, (or else just in CloseGadgetList().
Can anyone clarify this
Thanks
Code: Select all
;********************************************************
;{********************************************************
Structure Gadget_Set
x.w
y.w
w.w
h.w
fcolor.a ;kleur nr fill dot-kader
bcolor.a ;kleur nr achtergrond
mark.a ;runtime markering voor delete oid.
prnt.u ;list index van het parent Gadget gebruik nog verder invoeren (zie ook uitleg bovenaan)
type.u ;Gadget type constante
atrb.l ;Gadget flag specifikaties binair ingevoegd MAAR op volgorde van de tekst-lijst met Flags
flag.i ;som van alle Flag-specifikaties decimale vorm INTEGERS ACHTERAAN PLAATSEN
idx.i
EndStructure
Structure Save_Ob
name.i ;som van alle specifikaties decimale vorm INTEGERS ACHTERAAN PLAATSEN
spec.i
typ.u
EndStructure
Structure wXYWH ;OPGELET NIEUW FORMAAT ALLES ALS WORD I.P.V. LONG
x.w ;door 2-bytes Word ipv Unicode gebruik kunnen ook negatieve waarde gebruikt worden
y.w ;nuttig bij rubberdrawbox met "negatieve muisbewegingen" !
w.w
h.w
EndStructure
;*******************************************************
Global NewList Ob.Gadget_Set()
Global NewList xy.wXYWH()
Global result.s, text.s, pad.s, userpad.s, S_flag.s, Ob_Edit.Gadget_Set, SOb.Save_Ob, btn_info
Global.i Window_0,Canvas_0, btn1, a, b,x,y,w,h,btn1, btn2
;}********************************************************
;********************************************************
Procedure AddGadgetSample(spec.i)
If spec
Debug "tweede"
AddElement(Ob()) : Ob()\x= 95 : Ob()\y= 80 : Ob()\w=90 : Ob()\h=40 : Ob()\type = #PB_GadgetType_Button
AddElement(Ob()) : Ob()\x=207 : Ob()\y= 80 : Ob()\w=90 : Ob()\h=40 : Ob()\type = #PB_GadgetType_Button
AddElement(Ob()) : Ob()\x= 95 : Ob()\y=132 : Ob()\w=90 : Ob()\h=40 : Ob()\type = #PB_GadgetType_Button
AddElement(Ob()) : Ob()\x=207 : Ob()\y=132 : Ob()\w=90 : Ob()\h=40 : Ob()\type = #PB_GadgetType_Button
AddElement(Ob()) : Ob()\x=335 : Ob()\y=210 : Ob()\w=55 : Ob()\h=30 : Ob()\type =#PB_GadgetType_CheckBox
AddElement(Ob()) : Ob()\x=397 : Ob()\y=210 : Ob()\w=55 : Ob()\h=30 : Ob()\type =#PB_GadgetType_CheckBox
AddElement(Ob()) : Ob()\x=335 : Ob()\y=245 : Ob()\w=55 : Ob()\h=30 : Ob()\type =#PB_GadgetType_CheckBox
AddElement(Ob()) : Ob()\x=397 : Ob()\y=245 : Ob()\w=55 : Ob()\h=30 : Ob()\type =#PB_GadgetType_CheckBox
AddElement(Ob()) : Ob()\x=335 : Ob()\y=280 : Ob()\w=55 : Ob()\h=30 : Ob()\type =#PB_GadgetType_Option
AddElement(Ob()) : Ob()\x=397 : Ob()\y=280 : Ob()\w=55 : Ob()\h=30 : Ob()\type =#PB_GadgetType_Option
AddElement(Ob()) : Ob()\x=335 : Ob()\y=315 : Ob()\w=55 : Ob()\h=30 : Ob()\type =#PB_GadgetType_Option
AddElement(Ob()) : Ob()\x=397 : Ob()\y=315 : Ob()\w=55 : Ob()\h=30 : Ob()\type =#PB_GadgetType_Option
Else
Debug "eerste"
AddElement(xy()) : xy()\x= 95+200 : xy()\y= 80 : xy()\w=90 : xy()\h=40
AddElement(xy()) : xy()\x=207+200 : xy()\y= 80 : xy()\w=90 : xy()\h=40
AddElement(xy()) : xy()\x= 95+200 : xy()\y=132 : xy()\w=90 : xy()\h=40
AddElement(xy()) : xy()\x=207+200 : xy()\y=132 : xy()\w=90 : xy()\h=40
AddElement(xy()) : xy()\x=535 : xy()\y=210 : xy()\w=55 : xy()\h=30
AddElement(xy()) : xy()\x=597 : xy()\y=210 : xy()\w=55 : xy()\h=30
AddElement(xy()) : xy()\x=535 : xy()\y=245 : xy()\w=55 : xy()\h=30
AddElement(xy()) : xy()\x=597 : xy()\y=245 : xy()\w=55 : xy()\h=30
AddElement(xy()) : xy()\x=535 : xy()\y=280 : xy()\w=55 : xy()\h=30
AddElement(xy()) : xy()\x=597 : xy()\y=280 : xy()\w=55 : xy()\h=30
AddElement(xy()) : xy()\x=535 : xy()\y=315 : xy()\w=55 : xy()\h=30
AddElement(xy()) : xy()\x=597 : xy()\y=315 : xy()\w=55 : xy()\h=30
EndIf
EndProcedure
;********************************************************
Procedure Drop_Gadget_Selected(*ob.Gadget_Set, idx.i)
Protected.i a, val1, val2, val3, last_idx, txt.s
With *ob
txt="gdt"
Debug Str(\type)+ " drop "+ RSet(Str(\x),3," ") + ","+ RSet(Str(\y),3," ") + ","+ RSet(Str(\w),3," ") + ","+ RSet(Str(\h),3," ") + " "+ txt + " flg= " +Str(\flag)
Select \type
Case #PB_GadgetType_Button : \idx = ButtonGadget(#PB_Any, \x,\y,\w,\h, txt, \flag) ;1
Case #PB_GadgetType_ButtonImage : \idx = ButtonImageGadget(#PB_Any, \x,\y,\w,\h, val1, \flag) ;19
Case #PB_GadgetType_Calendar : \idx = CalendarGadget(#PB_Any, \x,\y,\w,\h, val1, \flag) ;20
Case #PB_GadgetType_Canvas :; \idx = CanvasGadget(#PB_Any, \x,\y,\w,\h, \flag) ;33
Case #PB_GadgetType_CheckBox : \idx = CheckBoxGadget(#PB_Any, \x,\y,\w,\h, txt, \flag) ;4
Case #PB_GadgetType_ComboBox : \idx = ComboBoxGadget(#PB_Any, \x,\y,\w,\h, \flag) ;8
;OPGELET CONTANER GADGETS WORDEN MET HANDLE OPGEZOCHT EN DUS INVOER MET GADGETID => SetGadgetData(\idx, GadgetID(\idx))
Case #PB_GadgetType_Container : \idx =ContainerGadget(#PB_Any, \x,\y,\w,\h, \flag)
Case #PB_GadgetType_Frame : \idx = FrameGadget(#PB_Any, \x,\y,\w,\h, txt, \flag) ;7
Case #PB_GadgetType_Option : \idx = OptionGadget(#PB_Any, \x,\y,\w,\h, txt) ;5
EndSelect
last_idx=\idx
EndWith
EndProcedure
Procedure Add_Element(type.u, flag.i, atrb.l, prnt.u)
AddElement(Ob())
Ob()\type =#PB_GadgetType_Button ; type
Ob()\flag = flag
Ob()\atrb = atrb
Ob()\prnt = prnt
EndProcedure
Procedure Position_Added_Gadgets(hnd.i) ;PLAATSEN VAN AT RUNTIME GETEKENDE GADGETS
Protected grid.i
Static parent_id.u
OpenGadgetList(hnd) ;***************problem*****************
With Ob_Edit
ForEach xy()
Add_Element(\type, \flag, \atrb, parent_id)
CopyMemory(@xy(), @Ob(), SizeOf(wXYWH))
Drop_Gadget_Selected(Ob(), ListIndex(Ob()))
Next
EndWith
CloseGadgetList() ;***************problem*****************
EndProcedure
Procedure Remove_All_Gadgets()
ClearList(xy())
ClearList(Ob())
EndProcedure
Procedure Window_0_Events(event) ; GADGET PLAATSING WINDOW
Protected.i x,y,tekst.s
Select event
;********************************************************
Case #PB_Event_CloseWindow : End
Case #PB_Event_SizeWindow : ResizeGadget(Canvas_0,#PB_Ignore, #PB_Ignore, WindowWidth(Window_0), WindowHeight(Window_0))
Case #PB_Event_Gadget
;********************************************************
Select EventGadget()
Case btn1 :
Remove_All_Gadgets()
AddGadgetSample(0)
Position_Added_Gadgets(Canvas_0)
Case btn2 :
;deze worden wel geplaatst
Remove_All_Gadgets()
AddGadgetSample(1)
ForEach Ob()
Drop_Gadget_Selected(Ob(), ListIndex(Ob()))
Next
Case Canvas_0 :
Select EventType()
Case #PB_EventType_KeyDown
Case #PB_EventType_LeftButtonDown
Case #PB_EventType_MouseMove :
Case #PB_EventType_RightButtonDown
EndSelect
;********************************************************
EndSelect
EndSelect
EndProcedure
;********************************************************
Procedure OpenWindow_0(x = 0, y = 0, width = 800, height = 700)
Window_0 = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, width, height, "Testing", #PB_Window_SystemMenu |#PB_Window_ScreenCentered |#PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
Canvas_0 = CanvasGadget(#PB_Any,0, 0, width, height, #PB_Canvas_Keyboard) ;| #PB_Canvas_Container) ; | #PB_Canvas_ClipMouse)
btn1 = ButtonGadget(#PB_Any, 700,20,50,20, "Set 1")
btn2 = ButtonGadget(#PB_Any, 700,60,50,20, "Set 2")
EndProcedure
Procedure Eventloop()
Repeat
EventID = WaitWindowEvent()
If EventID
Select EventWindow()
Case Window_0
Window_0_Events(EventID)
EndSelect
EndIf
ForEver
EndProcedure
OpenWindow_0()
Eventloop()
;errors bij reuniform outpu aanmaak van nieuwe gadgets :
; [10:17:02] [WARNING] GLib-GIO (Debug): _g_io_module_get_default: Found Default implementation gvfs (GDaemonVfs) For âgio-vfsâ
; [10:17:26] [WARNING] Gtk (CRITICAL): gtk_layout_put: assertion 'GTK_IS_LAYOUT (layout)' failed
; [10:17:26] [WARNING] Gtk (CRITICAL): gtk_widget_realize: assertion 'widget->priv->anchored || GTK_IS_INVISIBLE (widget)' failed