func_maxgui_tabbers_createtabber.rst 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. .. _func_maxgui_tabbers_createtabber:
  2. ============
  3. CreateTabber
  4. ============
  5. CreateTabber -
  6. Description
  7. ===========
  8. .. code-block:: blitzmax
  9. CreateTabber:TGadget(x,y,w,h,group:TGadget,style=0)
  10. Create a Tabber gadget.
  11. A Tabber gadget shows a list of tabs above a client area typically used for
  12. handling multiple documents.
  13. [ @{Event ID} | @Description
  14. * EVENT_GADGETACTION | A new tab has been selected. Event data should contain the tab index.
  15. ]
  16. See Also: #AddGadgetItem, #ClearGadgetItems, #ModifyGadgetItem, #SelectGadgetItem,
  17. #RemoveGadgetItem and #SelectedGadgetItem.
  18. Parameters
  19. ==========
  20. Return Values
  21. =============
  22. Nothing.
  23. Examples
  24. ========
  25. .. code-block:: blitzmax
  26. ' createtabber.bmx
  27. Import MaxGui.Drivers
  28. Strict
  29. Local window:TGadget
  30. Local tabber:TGadget
  31. Local document:TGadget[3]
  32. Local currentdocument:TGadget
  33. ' CreateDocument creates a hidden panel that fills entire tabber client area
  34. Function CreateDocument:TGadget(tabber:TGadget)
  35. Local panel:TGadget
  36. panel=CreatePanel(0,0,ClientWidth(tabber),ClientHeight(tabber),tabber)
  37. SetGadgetLayout panel,1,1,1,1
  38. HideGadget panel
  39. Return panel
  40. End Function
  41. ' create a default window with a tabber gadget that fills entire client area
  42. window=CreateWindow("My Window",30,20,400,300)
  43. tabber=CreateTabber(0,0,ClientWidth(window),ClientHeight(window),window)
  44. SetGadgetLayout tabber,1,1,1,1
  45. ' add three items and corresponding document panels to the tabber
  46. AddGadgetItem tabber,"Document 0",False,-1,""
  47. AddGadgetItem tabber,"Document 1",False,-1,"Tabber Tip 1"
  48. AddGadgetItem tabber,"Document 2",False,-1,"tips 4 2"
  49. document[0]=CreateDocument(tabber)
  50. document[1]=CreateDocument(tabber)
  51. document[2]=CreateDocument(tabber)
  52. SetPanelColor document[0],255,200,200
  53. SetPanelColor document[1],200,255,200
  54. SetPanelColor document[2],200,200,255
  55. ' our documents start off hidden so make first one current and show
  56. currentdocument=document[0]
  57. ShowGadget currentdocument
  58. ' standard message loop with special tabber GADGET_ACTION handling
  59. While WaitEvent()
  60. Select EventID()
  61. Case EVENT_GADGETACTION
  62. If EventSource()=tabber
  63. HideGadget currentdocument
  64. currentdocument=document[EventData()]
  65. ShowGadget currentdocument
  66. EndIf
  67. Case EVENT_WINDOWCLOSE
  68. End
  69. End Select
  70. Wend
  71. See Also
  72. ========