Canvas buttons, not working!
BlitzMax Forums/MaxGUI Module/Canvas buttons, not working!
| ||
My application attaches a canvas to the main window and then adds buttons, listbox... to the canvas. On the PC all works well the buttons appear ontop of the canvas and I get an image the background of my window. When I rune the same program under MacOS I get the nice image on my window but no buttons or listbox? If I don't create the canvas and attach the buttons to the window itself all is well. But the look and feel is not how I want it! Is this a BUG under MacOS? Or can you just not attach buttons and other widgets to canvas's under OSX? |
| ||
You can not attach any gadgets to a canvas. Only Windows and Panels are valid containers It is only working under windows because the creation order defines the initial depth sorting order as well but it is not suggested to draw gadget over a graphic context. |
| ||
If this is true BlitzMAX is not cross platform? And I will have to re-write the whole project from scratch on the Mac using C! Dremora if this is really true why do all the create gadgets that I have tried never return an error, always create but never plot? |
| ||
It is cross plattform. It is just not supported at the moment to use OS gadgets within Canvas. For event handling reasons I wouldn't do it as well because the events a canvas throws will be "blocked" by the button if it is in front of the canvas. What do you actually try to achieve? Because depending on what you want to achieve, I would suggest using HighGUI for fullscreen graphics (UI can't go fullscreen with graphic context, only maximized window) |
| ||
The button is attached to the canvas. I wonder if I am not making my point clearly enough here. I am not sure if anyone has fully comprehended the problem?SuperStrict Framework brl.blitz Import brl.standardio Import brl.retro Import brl.bank Import brl.eventqueue Import brl.filesystem Import brl.timer Import brl.system Import brl.jpgloader ?Win32 Import brl.d3d7max2d Import brl.win32maxgui Import pub.win32 ?MacOS Import brl.glmax2d Import brl.cocoamaxgui Import pub.macos ?Linux Import brl.glmax2d Import brl.fltkmaxgui ? Const WINDOW_WIDTH:Int = 640 Const WINDOW_HEIGHT:Int = 480 Const MENU_EXIT:Int = 104 Const MENU_ABOUT:Int = 105 Global main_window:Tgadget Global canvas:TGadget Global backgrnd:TImage Global filemenu:TGadget Global aboutmenu:TGadget '--------------------------------------------------------------------- If ( Initalise() ) '--------------------------------------------------------------------- While WaitEvent() Select EventID() Case EVENT_MENUACTION Select EventData() Case MENU_EXIT Finalise() Case MENU_ABOUT Notify( AppTitle + " ©2006", False ) Default End Select Case EVENT_WINDOWCLOSE If EventSource() = main_window Then Finalise() End Select Wend EndIf Finalise() '--------------------------------------------------------------------- Function MyHook:Object( iId:Int, tData:Object, tContext:Object ) '--------------------------------------------------------------------- Local event:TEvent=TEvent(tData) If event = Null Return Null Select event.source Case main_window Case canvas Select Event.ID Case EVENT_GADGETPAINT SetGraphics CanvasGraphics(canvas) DrawImage backgrnd,0,0 Flip Return Null EndSelect End Select Return tData End Function Const D3DRS_EDGEANTIALIAS:Int=40 '--------------------------------------------------------------------- Function Initalise:Int() '--------------------------------------------------------------------- ?Win32 SetGraphicsDriver D3D7Max2DDriver() ?MacOS SetGraphicsDriver GLMax2DDriver() ?Linux SetGraphicsDriver GLMax2DDriver() ? backgrnd = LoadImage("resources\background.jpg",FILTEREDIMAGE ) ' Create window and menu. CreateFurniture( AppTitle, WINDOW_WIDTH, WINDOW_HEIGHT ) Return True End Function '--------------------------------------------------------------------- Function Finalise() '--------------------------------------------------------------------- End End Function '--------------------------------------------------------------------- Function CreateFurniture( title:String, width:Int, height:Int ) '--------------------------------------------------------------------- Local listbox:TGadget ' Create a centered window with client size WINDOW_WIDTH,WINDOW_HEIGHT Local wx:Int=(GadgetWidth(Desktop())-WINDOW_WIDTH)/2 Local wy:Int=(GadgetHeight(Desktop())-WINDOW_HEIGHT)/2 main_window:TGadget = CreateWindow( title,wx,wy,WINDOW_WIDTH,WINDOW_HEIGHT,Null,WINDOW_TITLEBAR | WINDOW_CLIENTCOORDS | WINDOW_HIDDEN ) canvas:TGadget=CreateCanvas(0,0,WINDOW_WIDTH,WINDOW_HEIGHT,main_window) SetGadgetLayout(canvas, 1, 0, 1, 0 ) ' Add buttons for canvas CreateButton( "Update", ClientWidth(canvas)-80,ClientHeight(canvas)-58,70,24,canvas,BUTTON_CANCEL ) filemenu = CreateMenu("&File", 0,WindowMenu(main_window)) CreateMenu("E&xit", MENU_EXIT, filemenu, KEY_Q, MODIFIER_COMMAND ) aboutmenu = CreateMenu("Help", 0, WindowMenu(main_window)) CreateMenu("&About", MENU_ABOUT, aboutmenu) UpdateWindowMenu(main_window) AddHook EmitEventHook, MyHook ShowGadget(main_window) End Function |
| ||
If you only want to show a Backgroundpic, then use an Panel instead of a canvas From BM-Help: (A Panel is a general purpose gadget that can be used to group other gadgets, it has background color and pixmap properties and can optionally produce the following mouse and key events when the PANEL_ACTIVE style is selected) SetPanelPixmap( Panel:TGadget,pixmap:TPixmap,flags=PANELPIXMAP_TILE) |
| ||
Nigel: I fully understand but you do not fully understand as it seems. You can only attach gadgets to Windows and Panels. Not to anything else (ok Tabbers as well but for those, panels are normally used as tab-page containers). With MaxGUI without modifications, you can't have gadgets over canvas. You can have gadgets next to canvas, thats no problem. If you want to have GUI within the canvas, I suggest using HighGUI. Or if you insist on using "OS Gadgets" (linux actually does not have any, just a few different ui libraries), you will have to write your own gadget handling code into the source files to do so because gadgets above graphic contexts is something that is normally not done for good reasons. (for example: how do you actually want to fire the correct events if a button is over a canvas? because the canvas should have full mouse event handling ... but your button is breaking that if the mouse if over the button) |