1
0

tabsheet.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. #ifndef _TABSHEET_H
  2. #define _TABSHEET_H
  3. #include <api/skin/widgets/grouptgbutton.h>
  4. #include <api/wnd/wndclass/buttwnd.h>
  5. #include <bfc/common.h>
  6. #include <api/wnd/wndclass/guiobjwnd.h>
  7. #include <bfc/ptrlist.h>
  8. class ButtonWnd;
  9. class SkinBitmap;
  10. class TabButtonBase;
  11. class ButtBar;
  12. class TabSheetBar;
  13. #define TABSHEET_GROUPS -2
  14. #define TABSHEET_NOTABS -3
  15. #define TABSHEET_PARENT GuiObjectWnd
  16. /**
  17. class TabSheet
  18. @short A TabSheet Control.
  19. @author Nullsoft
  20. @ver 1.0
  21. @see
  22. @cat SDK
  23. */
  24. class TabSheet : public TABSHEET_PARENT
  25. {
  26. public:
  27. /**
  28. TabSheet constructor
  29. @see ~TabSheet()
  30. @param bbtype The type of button bar to use in the tabsheet.
  31. */
  32. TabSheet(int bbtype=-1);
  33. /**
  34. TabSheet destructor
  35. @see TabSheet()
  36. */
  37. virtual ~TabSheet();
  38. /**
  39. TabSheet method onInit
  40. @ret 1
  41. */
  42. virtual int onInit();
  43. /**
  44. TabSheet method getClientRect
  45. @param r A pointer to the RECT that will be filled.
  46. */
  47. virtual void getClientRect(RECT *);
  48. /**
  49. TabSheet method onPaint
  50. @ret 1
  51. @param canvas The canvas upon which we'll paint ourself.
  52. */
  53. virtual int onPaint(Canvas *canvas);
  54. /**
  55. TabSheet method onResize
  56. @ret 1
  57. */
  58. virtual int onResize();
  59. /**
  60. TabSheet method setButtonType .
  61. @param type The button type.
  62. */
  63. void setButtonType(int type);
  64. /**
  65. TabSheet method setTabRowMargin
  66. @assert newmargin is non-negative
  67. @param newmargin The new margin width in pixels.
  68. */
  69. void setTabRowMargin(int pixels);
  70. /**
  71. TabSheet method addChild
  72. @ret One less than the number of tabs
  73. @param newchild A pointer to the new child window to add.
  74. @param tip The tooltip for the button associated with this child.
  75. */
  76. int addChild(BaseWnd *newchild, const wchar_t *tooltip=NULL);
  77. /**
  78. TabSheet method activateChild
  79. @see addChild()
  80. @see killChildren()
  81. @ret None
  82. @param newactive A pointer to the child window to render active.
  83. */
  84. virtual void activateChild(BaseWnd *activechild);
  85. /**
  86. TabSheet method killChildren .
  87. */
  88. virtual void killChildren();
  89. /**
  90. TabSheet method childNotify .
  91. @ret Returns 1 when complete.
  92. @param child The child that's being notified.
  93. @param msg The message.
  94. @param param1 Custom parameter 1.
  95. @param param2 Custom parameter 2.
  96. */
  97. virtual int childNotify(ifc_window *child, int msg,
  98. intptr_t param1=0, intptr_t param2=0);
  99. void setContentMarginLeft(int cm);
  100. void setContentMarginTop(int cm);
  101. void setContentMarginRight(int cm);
  102. void setContentMarginBottom(int cm);
  103. /**
  104. TabSheet method enumChild
  105. @ret The base window of the specified tab button, or NULL if there is none.
  106. */
  107. BaseWnd *enumChild(int child);
  108. /**
  109. TabSheet method getNumChild
  110. @ret The number of tabs
  111. */
  112. int getNumChild();
  113. BaseWnd *getActiveChild() { return active; }
  114. virtual void onSetPage(int n) { lastpage = n; }
  115. int getCurPage() { return lastpage; }
  116. void setCurPage(int page);
  117. int getNumPages() { return tabs.getNumItems(); }
  118. void nextPage() { int n = getCurPage()+1; if (n >= getNumPages()) n = 0; setCurPage(n); }
  119. void previousPage() { int n = getCurPage()-1; if (n < 0) n = getNumPages()-1; setCurPage(n); }
  120. int onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source);
  121. protected:
  122. /** TabSheet method enumButton
  123. @ret The specified tab, or NULL if there is none. */
  124. TabButtonBase *enumButton(int button);
  125. public:
  126. /**
  127. TabSheet method setBackgroundBmp
  128. @param name The name of the bitmap to use.
  129. */
  130. #ifdef WASABI_COMPILE_IMGLDR
  131. void setBackgroundBmp(const wchar_t *name); //FG
  132. #endif
  133. SkinBitmap *getBackgroundBitmap(); //FG
  134. protected:
  135. // you can set these in your constructor, they will be deleted for you
  136. ButtonWnd *leftscroll, *rightscroll;
  137. SkinBitmap *background;
  138. private:
  139. int tabrowheight, tabrowwidth, tabrowmargin;
  140. PtrList<TabButtonBase> tabs;
  141. ButtBar *bb;
  142. TabSheetBar *tsb;
  143. GuiObjectWnd *contentwnd;
  144. int tilex, tilew;
  145. BaseWnd *active;
  146. int type;
  147. int content_margin_left, content_margin_top, content_margin_right, content_margin_bottom;
  148. int lastpage;
  149. };
  150. class TabButtonBase
  151. {
  152. public:
  153. TabButtonBase(BaseWnd *linkWnd, TabSheet *par, const wchar_t *tip=NULL);
  154. virtual ~TabButtonBase();
  155. BaseWnd *getBaseWnd() const { return linked; }
  156. void setNoDeleteLinked(int i) { nodeletelinked = i; }
  157. virtual void btn_setHilite(int tf)=0;
  158. virtual void btn_setText(const wchar_t *txt)=0;
  159. protected:
  160. BaseWnd *linked;
  161. TabSheet *parent;
  162. int nodeletelinked;
  163. };
  164. #define TABBUTTON_PARENT ButtonWnd
  165. /**
  166. Class TabButton
  167. @short
  168. @author Nullsoft
  169. @ver 1.0
  170. @see TabButtonBase
  171. @cat SDK
  172. */
  173. class TabButton : public TABBUTTON_PARENT, public TabButtonBase {
  174. public:
  175. /**
  176. TabButton constructor
  177. @assert The BaseWnd passed to this method must previously be linked.
  178. @param linkwnd The window to associate with this button.
  179. @param par A pointer to the parent tabsheet.
  180. @param tip The tooltip for the window associated with this button.
  181. */
  182. TabButton(BaseWnd *linkWnd, TabSheet *par, const wchar_t *tip=NULL) : TabButtonBase(linkWnd, par, tip)
  183. {
  184. if (tip != NULL)
  185. setTip(tip);
  186. }
  187. /**
  188. TabButton method onInit
  189. @ret 1
  190. */
  191. virtual int onInit();
  192. /**
  193. TabButton method onLeftPush .
  194. @assert parent and linked both exist.
  195. @param x The X position, of the mouse pointer, in the client screen.
  196. @param y The Y position, of the mouse pointer, in the client screen.
  197. */
  198. virtual void onLeftPush(int x, int y);
  199. virtual void btn_setHilite(int tf);
  200. virtual void btn_setText(const wchar_t *text);
  201. };
  202. #define GROUPTABBUTTON_PARENT GroupToggleButton
  203. class GroupTabButton : public GROUPTABBUTTON_PARENT, public TabButtonBase {
  204. public:
  205. GroupTabButton(BaseWnd *linkWnd, TabSheet *par, const wchar_t *tip=NULL) : TabButtonBase(linkWnd, par, tip)
  206. {
  207. setGroups(L"wasabi.tabsheet.button.selected.group", L"wasabi.tabsheet.button.unselected.group");
  208. }
  209. virtual int wantFullClick() { return 0; }
  210. virtual int wantAutoToggle() { return 0; }
  211. virtual int onInit();
  212. virtual void grouptoggle_onLeftPush();
  213. virtual void btn_setHilite(int tf);
  214. virtual void btn_setText(const wchar_t *text);
  215. };
  216. #endif