func_maxgui_panels_createpanel.rst 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. .. _func_maxgui_panels_createpanel:
  2. ===========
  3. CreatePanel
  4. ===========
  5. CreatePanel -
  6. Description
  7. ===========
  8. .. code-block:: blitzmax
  9. CreatePanel:TGadget(x,y,w,h,group:TGadget,style=0,title$="")
  10. Create a Panel gadget.
  11. A Panel is a general purpose gadget that can be used to group other gadgets,
  12. it has background color and pixmap properties.
  13. A panel can feature the following optional styles:
  14. [ @Style | @Meaning
  15. * PANEL_BORDER | Panel is drawn with a border.
  16. * PANEL_ACTIVE | Panel generates mouse move events.
  17. * PANEL_GROUP | Panel is drawn with a titled etched border.
  18. ]
  19. If the PANEL_ACTIVE style flag is specified, the Panel will emit the following
  20. mouse and key events:
  21. [ @{Event ID} | @Description
  22. * EVENT_MOUSEDOWN | Mouse button pressed. Event data contains mouse button code.
  23. * EVENT_MOUSEUP | Mouse button released. Event data contains mouse button code.
  24. * EVENT_MOUSEMOVE | Mouse moved. Event x and y contain mouse coordinates.
  25. * EVENT_MOUSEWHEEL | Mouse wheel spun. Event data contains delta clicks.
  26. * EVENT_MOUSEENTER | Mouse entered gadget area.
  27. * EVENT_MOUSELEAVE | Mouse left gadget area.
  28. * EVENT_KEYDOWN | Key pressed. Event data contains keycode.
  29. * EVENT_KEYUP | Key released. Event data contains keycode.
  30. * EVENT_KEYCHAR | Key character. Event data contains unicode value.
  31. ]
  32. %{Note: The PANEL_BORDER and PANEL_GROUP style flags cannot be used together.}
  33. See Also: #SetPanelColor and #SetPanelPixmap.
  34. Parameters
  35. ==========
  36. Return Values
  37. =============
  38. Nothing.
  39. Examples
  40. ========
  41. .. code-block:: blitzmax
  42. ' createpanel.bmx
  43. Import MaxGui.Drivers
  44. Strict
  45. Local window:TGadget
  46. Local panel:TGadget
  47. Local panel2:TGadget
  48. Local group:TGadget
  49. window=CreateWindow("My Window",40,40,320,240)
  50. ' create a purple panel that occupies entire window client area
  51. panel=CreatePanel(0,0,ClientWidth(window),ClientHeight(window),window,PANEL_ACTIVE)
  52. SetGadgetLayout panel,1,1,1,1
  53. 'SetPanelColor panel,100,0,200
  54. ' and a smaller box
  55. panel2=CreatePanel(10,10,100,100,panel,PANEL_ACTIVE|PANEL_BORDER)
  56. panel2.SetColor(160,255,160)
  57. ' and a group panel with a child button
  58. group=CreatePanel(120,10,100,100,panel,PANEL_GROUP)
  59. group.settext("My Group")
  60. CreateButton("hello",0,0,64,24,group)
  61. While True
  62. WaitEvent
  63. Print CurrentEvent.ToString()
  64. Select EventID()
  65. Case EVENT_WINDOWCLOSE
  66. End
  67. End Select
  68. Wend
  69. See Also
  70. ========