buttbar.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #ifndef _BUTTBAR_H
  2. #define _BUTTBAR_H
  3. #include <bfc/common.h>
  4. #include <api/wnd/wndclass/guiobjwnd.h>
  5. #include <bfc/ptrlist.h>
  6. class ButtonWnd;
  7. class ButtHooker;
  8. #define BUTTBAR_PARENT GuiObjectWnd
  9. /**
  10. A resizable button bar control.
  11. @short A resizable button bar
  12. @author Nullsoft
  13. @ver 1.0
  14. @see ButtonWnd
  15. */
  16. class ButtBar : public BUTTBAR_PARENT {
  17. public:
  18. // resize modes
  19. /**
  20. Resize modes for the button bar.
  21. */
  22. enum { NORMAL, STRETCH, STACK };
  23. /**
  24. You can set the resize mode for the button bar by specifying it
  25. via the contructor.
  26. @see ~ButtBar() setResizeMode()
  27. @param resizemode The default resize mode.
  28. */
  29. ButtBar(int resizemode=NORMAL);
  30. /**
  31. Deletes all the buttons present in the button bar.
  32. @see ButtBar()
  33. */
  34. virtual ~ButtBar();
  35. /**
  36. This event is triggered when the button bar is being initialized.
  37. If you override this, please call up the parent chain first, then
  38. do your initialization.
  39. @ret 1
  40. */
  41. virtual int onInit();
  42. /**
  43. This event is triggered when the button bar is being resized.
  44. If you override this, please call up the parent chain first, then
  45. do your own resize handling.
  46. @ret 1
  47. */
  48. virtual int onResize();
  49. /**
  50. This event is triggered when the button bar is being painted.
  51. If you override this, please call up the parent chain first, then
  52. do your painting.
  53. @ret 1
  54. @param canvas The canvas upon which we will paint ourself.
  55. */
  56. virtual int onPaint(Canvas *canvas);
  57. /**
  58. Sets the resize mode for the button bar.
  59. @param resizemode NORMAL, Normal Resize; STRETCH, Stretch the button bar to window width; STACK, ?;
  60. */
  61. virtual void setResizeMode(int resizemode);
  62. /**
  63. Enables you to add a child window to your button bar.
  64. Since this is a button bar, the windows you can add must be
  65. derived or be ButtonWnd's.
  66. @see removeChild()
  67. @see getNumChildren()
  68. @see enumChild()
  69. @see ButtonWnd
  70. @ret 1
  71. @param child A pointer to the child window to add.
  72. */
  73. int addChild(ButtonWnd *child);
  74. /**
  75. */
  76. int removeChild(ButtonWnd *child); // does not delete, just removes
  77. /**
  78. Get the number of children (buttons) that the button bar has.
  79. @ret The number of children (buttons).
  80. */
  81. int getNumChildren();
  82. /**
  83. Get a pointer to a child (button) in the button bar, by button index number.
  84. The first button added is at index 0.
  85. @ret !NULL, a pointer the requested button; NULL, The button does not exist;
  86. */
  87. ButtonWnd *enumChild(int n);
  88. /**
  89. Get the width of the button bar (in pixels).
  90. @see getHeight()
  91. @ret Width of the button bar (in pixels).
  92. */
  93. int getWidth();
  94. /**
  95. Get the height of the button bar (in pixels).
  96. @see getWidth()
  97. @ret Height of the button bar (in pixels).
  98. */
  99. int getHeight();
  100. /**
  101. Event is triggered when the left mouse button is used to click on the
  102. button bar. Override this to implement your own handling of the event.
  103. If you override this method, call up the parent chain.
  104. @param x The x coordinate of the mouse cursor in the button bar.
  105. @param y The y coordinate of the mouse cursor in the button bar.
  106. */
  107. virtual void onLeftPush(int x, int y);
  108. /**
  109. Notify a child window via a generic message system.
  110. @see addChild()
  111. @ret
  112. @param child A pointer to the child window which will receive the notify.
  113. @param msg The message you want to send to the child.
  114. @param p1 A user parameter.
  115. @param p2 A user parameter.
  116. */
  117. virtual int childNotify(ifc_window *child, int msg,
  118. intptr_t param1=0, intptr_t param2=0);
  119. // GuiObjectWnd
  120. virtual void onNewContent();
  121. void setSpacer(int sp) { spacer = sp; }
  122. void setGroupLabel(const wchar_t *l);
  123. protected:
  124. virtual int onLeftPush(int id) { return 0; }
  125. PtrList<ButtonWnd> buttons;
  126. private:
  127. int resize_mode;
  128. int spacer;
  129. ButtHooker *hooker;
  130. };
  131. #endif