Page 1 of 1

Gadget order of appearence

Posted: Mon May 09, 2005 6:46 pm
by banban73
Hello
I am trying to make a cool window for my app, which will look like a sheet of japanese paper and in which buttons will be fully integrated and customized (i.e images without borders).
In order to achieve this gui, I tried to use imagegadget() for the background and for the "buttons" also.
My problem is that the "buttons" do not appear. It seems that the background imagegadget() displays over the buttons, even if I change the order of declaration in the gadgetlist()

Please help !!!

Posted: Mon May 09, 2005 11:55 pm
by dracflamloc
I've noticed that the order of appearance is wacky in PB, maybe fred could provide some clarification on how to set the Z order.

Posted: Tue May 10, 2005 12:13 am
by Sparkie
Without seeing any code, my best guess is to try using #WS_CLIPSIBLINGS on your image gadget.

Code: Select all

SetWindowLong_(GadgetID((#YourImageGadget), #GWL_STYLE, GetWindowLong_(GadgetID(#YourImageGagdet), #GWL_STYLE) | #WS_CLIPSIBLINGS) 

Posted: Tue May 10, 2005 8:54 am
by Fred
Theorically gadgets overlapping is not supported in PB. But on Windows (and only on Windows) you can try to put your button directly in the ImageGadget() by using UseGadgetList(GadgetID(#YourImageGadget)).

Posted: Tue May 10, 2005 3:19 pm
by dracflamloc
oh interesting...

Posted: Tue May 10, 2005 5:30 pm
by banban73
Thanks Everybody for your replies.

After posting my message yesterday, I reorganised again the order of declaration in gadgetlist and tried changing gadgetId and it comes to work.
But thanks again, I will keep your tips in mind for the next time as I may have been lucky this time.

Regards

Posted: Sun Oct 07, 2007 8:21 am
by Blue
Fred wrote:Theorically gadgets overlapping is not supported in PB. But on Windows (and only on Windows) you can try to put your button directly in the ImageGadget() by using UseGadgetList(GadgetID(#YourImageGadget)).
Your answer surprised me and got me all excited. I tried it immediately, and found that it works great visually, but is severely handicapped functionnally.

It seems that EventGadget() only sees the imageGadget.

Any idea on how to catch the GadgetIDs of those buttons clearly visible (and seemingly functional) on the picture ?

A solution, if it exists (!) would be much appreciated...

===================
Forget the above.
using another method, the code below now works fine:

Code: Select all


; ==============================================
;  Blue - octobre 2007
;; Window with picture as a background for controls
;;=================================================

;;#imageName = "D:\Projets\PureBasic\Marqueur\bones.jpg"
#imageNameA = "bones.jpg"   ;; picture is 344 X 341
#imageNameB = "bonesG.png"  ;; a light gray copy of above

Enumeration
  #imageFond
  #imageB
  #txtBox
  #strBox
  #bouton1
  #bouton2
  #bouton3
  #cmdImage
  #cmdQuit
EndEnumeration

Declare.L TellMe(id.L)
Declare.L ChangeImage()

;****************************************************
;- initializing pictures
; Plugins 
UseJPEGImageDecoder() 
UsePNGImageDecoder() 

Global JamesBones,JamesGhost  ;; handles for pictures

JamesBones = CatchImage(#imageFond, ?bones)
JamesGhost = CatchImage(#imageB, ?ghost)

DataSection 
bones: IncludeBinary #imageNameA
ghost: IncludeBinary #imageNameB
EndDataSection 

;****************************************************
;- creating the window
  imgW = ImageWidth(#imageFond) 
  imgH = ImageHeight(#imageFond)
  
;; #wintype = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
  #wintype =  #WS_POPUP

hWnd = OpenWindow(0, 200, 300, imgW+20, imgH+20, "ImageGadget", #winType)
If 0 = hWnd
  End
EndIf

SetWindowColor(0, $AA9900)

;- installing gadgets
If 0 = CreateGadgetList(hWnd)
  End
EndIf
;; a key to quickly close the window
AddKeyboardShortcut(0, #PB_Shortcut_Escape, #PB_Shortcut_Escape)

#gX = 16 : gY = imgH - 13 - 2*25 : #gW = 90

ImageGadget(#imageFond, 10, 10, 100, 83, JamesBones)
TextGadget( #txtBox,   #gX, 30, 200, 16, "Simple sample")
StringGadget(#strBox,  #gX, 50, 200, 20, "a string for the road", #PB_String_BorderLess)

ButtonGadget(#bouton1, #gX, gY   , #gW, 20, " He did",   #PB_Button_Left)
ButtonGadget(#bouton2, #gX, gY+25, #gW, 20, "Something")
ButtonGadget(#bouton3, #gX, gY+50, #gW, 20, "Right ",    #PB_Button_Right)
ButtonGadget(#cmdQuit, imgW-60, imgH - 13, 60, 20, "Quit")
ButtonGadget(#cmdImage, imgW-60-5-50, imgH - 13, 50, 20, "Ghost")

;; netMaaestro's suggestion - works perfectly
DisableGadget(#imageFond, 1)

HideGadget(#txtBox,1)   ;; force Windows to display this control
HideGadget(#txtBox,0)

;****************************************************
;-   main application loop  *************************
Repeat
  EventID = WaitWindowEvent()

  If #PB_Event_Menu = EventID
    kbd = EventMenu() 
    Select kbd
      Case #PB_Shortcut_Escape: End
      ;;Case whatever: yes, real soon now
    EndSelect
  EndIf  

  If #PB_Event_Gadget = EventID
    GadgetID = EventGadget()
    Select GadgetID
      Case #bouton1 To #bouton3 : TellMe(GadgetID)
      Case #cmdImage : ChangeImage()
      Case #cmdQuit: End
    EndSelect

  ElseIf #PB_Event_CloseWindow = EventID
    End
  EndIf
ForEver

Procedure.L ChangeImage()
  For i = #txtBox To #cmdQuit
    HideGadget(i,1)
  Next
  If GetGadgetData(#cmdImage) = 1
    SetGadgetData(#cmdImage,0)
    SetGadgetState(#imageFond,JamesBones)
    SetGadgetText(#cmdImage,"Ghost") 
  Else
    SetGadgetText(#cmdImage,"Bones") 
    SetGadgetData(#cmdImage,1)
    SetGadgetState(#imageFond, JamesGhost)
  EndIf
  For i = #txtBox To #cmdQuit
    HideGadget(i,0)
  Next
EndProcedure
Procedure TellMe(id.L)
  SetGadgetText(#txtBox, GetGadgetText(id))
;;  MessageRequester("Info", "We have a Gadget with ID #" + Str(id) +".", 0)
EndProcedure

Posted: Mon Oct 08, 2007 5:45 am
by Blue
Oops...
I just looked at the posting dates on the previous messages, and suddenly realize that I'll most likely remain very lonely here for the foreseeable future !!!

Doesn't matter. I like talking to myself.

Fred's suggestion is not the solution.
But somewhere else in this forum, NetMaestro offered that disabling the image gadget would allow the messages from the buttons to come trhrough. And he's right.

That works...

link to netmaestro's solution: http://www.purebasic.fr/english/viewtop ... 207#213207