Fl_Widget.H 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. //
  2. // "$Id: Fl_Widget.H 10096 2014-02-08 01:10:44Z AlbrechtS $"
  3. //
  4. // Widget header file for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2012 by Bill Spitzak and others.
  7. //
  8. // This library is free software. Distribution and use rights are outlined in
  9. // the file "COPYING" which should have been included with this file. If this
  10. // file is missing or damaged, see the license at:
  11. //
  12. // http://www.fltk.org/COPYING.php
  13. //
  14. // Please report all bugs and problems on the following page:
  15. //
  16. // http://www.fltk.org/str.php
  17. //
  18. /** \file
  19. Fl_Widget, Fl_Label classes . */
  20. #ifndef Fl_Widget_H
  21. #define Fl_Widget_H
  22. #include "Enumerations.H"
  23. #include "Fl_Rectangle.H"
  24. /**
  25. \todo typedef's fl_intptr_t and fl_uintptr_t should be documented.
  26. */
  27. #ifdef _WIN64
  28. #if defined(__GNUC__) || defined(__clang__)
  29. #include <stdint.h>
  30. #else
  31. #include <stddef.h> // M$VC
  32. #endif
  33. typedef intptr_t fl_intptr_t;
  34. typedef uintptr_t fl_uintptr_t;
  35. #else
  36. typedef long fl_intptr_t;
  37. typedef unsigned long fl_uintptr_t;
  38. #endif
  39. class Fl_Widget;
  40. class Fl_Window;
  41. class Fl_Group;
  42. class Fl_Image;
  43. class Fl_Association_Type;
  44. /** Default callback type definition for all fltk widgets (by far the most used) */
  45. typedef void (Fl_Callback )(Fl_Widget*, void*);
  46. /** Default callback type pointer definition for all fltk widgets */
  47. typedef Fl_Callback* Fl_Callback_p; // needed for BORLAND
  48. /** One parameter callback type definition passing only the widget */
  49. typedef void (Fl_Callback0)(Fl_Widget*);
  50. /** Callback type definition passing the widget and a long data value */
  51. typedef void (Fl_Callback1)(Fl_Widget*, long);
  52. class Fl_AnyClass {};
  53. /** Default member callback type definition for all fltk widgets (by far the most used) */
  54. typedef void (Fl_AnyClass::*Fl_MCallback)(Fl_Widget*, void*);
  55. /** Default member callback type pointer definition for all fltk widgets */
  56. typedef Fl_MCallback* Fl_MCallback_p; // needed for BORLAND
  57. /** Zero parameter member callback type definition passing only the widget */
  58. typedef void (Fl_AnyClass::*Fl_MCallback0)();
  59. /** One parameter member callback type definition passing only the widget */
  60. typedef void (Fl_AnyClass::*Fl_MCallback1)(Fl_Widget*);
  61. /** Member callback type definition passing the widget and a long data value */
  62. typedef void (Fl_AnyClass::*Fl_MCallback2)(Fl_Widget*, long);
  63. /** Member callback type definition passing the widget and a long data value */
  64. typedef void (Fl_AnyClass::*Fl_MCallback3)(Fl_Widget*, double);
  65. #define MCALLBACK(wdg, mf) (wdg)->mcallback((Fl_AnyClass*)this, (Fl_MCallback)&mf)
  66. #define THISMBACK(wdg, mf) (wdg)->mcallback((Fl_AnyClass*)this, (Fl_MCallback)&THISCLASS::mf)
  67. /** This struct stores all information for a text or mixed graphics label.
  68. \todo For FLTK 1.3, the Fl_Label type will become a widget by itself. That way
  69. we will be avoiding a lot of code duplication by handling labels in
  70. a similar fashion to widgets containing text. We also provide an easy
  71. interface for very complex labels, containing html or vector graphics.
  72. */
  73. class FL_EXPORT Fl_Label {
  74. public:
  75. /** label text */
  76. const char* value;
  77. /** optional image for an active label */
  78. Fl_Image* image;
  79. /** optional image for a deactivated label */
  80. Fl_Image* deimage;
  81. /** label font used in text */
  82. Fl_Font font;
  83. /** size of label font */
  84. Fl_Fontsize size;
  85. /** text color */
  86. Fl_Color color;
  87. /** alignment of label */
  88. Fl_Align align_;
  89. /** type of label. \see Fl_Labeltype */
  90. uchar type;
  91. /** Draws the label aligned to the given box */
  92. void draw(int,int,int,int, Fl_Align) const ;
  93. void measure(int &w, int &h) const ;
  94. };
  95. //DAD Extensions
  96. struct st_cheap_rtti {
  97. const char *class_name;
  98. const st_cheap_rtti *(*cheap_rtti_info_func)(void);
  99. };
  100. #define DECLARE_CLASS_CHEAP_RTTI_1(a1class_name) DECLARE_CLASS_CHEAP_RTTI_00(a1class_name, 0)
  101. #define DECLARE_CLASS_CHEAP_RTTI_2(a2class_name, a2base_class) \
  102. DECLARE_CLASS_CHEAP_RTTI_00(a2class_name, &a2base_class::cheap_rtti_info)
  103. //DECLARE_CLASS_CHEAP_RTTI_00(a2class_name, : public a2base_class, &a2base_class::cheap_rtti_info)
  104. #define DECLARE_CLASS_CHEAP_RTTI_00(aclass_name, abase_class) \
  105. public:\
  106. static const st_cheap_rtti *cheap_rtti_info() {\
  107. static st_cheap_rtti scr = {#aclass_name, abase_class};\
  108. return &scr;\
  109. };\
  110. virtual const st_cheap_rtti *classRTTI(void) {return aclass_name::cheap_rtti_info();}; \
  111. static const char *className(void) {return aclass_name::cheap_rtti_info()->class_name;}; \
  112. virtual const char *classId(void) {return aclass_name::className();}; \
  113. virtual int inherits_from(const st_cheap_rtti *aclass_id) {\
  114. const st_cheap_rtti *cri = aclass_name::cheap_rtti_info();\
  115. while(cri) {\
  116. if (aclass_id == cri) return 1;\
  117. if(cri->cheap_rtti_info_func) \
  118. cri = (*cri->cheap_rtti_info_func)();\
  119. else break; \
  120. }\
  121. return 0;\
  122. }\
  123. typedef aclass_name THISCLASS; \
  124. private:
  125. /** Fl_Widget is the base class for all widgets in FLTK.
  126. You can't create one of these because the constructor is not public.
  127. However you can subclass it.
  128. All "property" accessing methods, such as color(), parent(), or argument()
  129. are implemented as trivial inline functions and thus are as fast and small
  130. as accessing fields in a structure. Unless otherwise noted, the property
  131. setting methods such as color(n) or label(s) are also trivial inline
  132. functions, even if they change the widget's appearance. It is up to the
  133. user code to call redraw() after these.
  134. */
  135. class FL_EXPORT Fl_Widget : public Fl_Rectangle {
  136. friend class Fl_Group;
  137. Fl_Group* parent_;
  138. union {
  139. Fl_Callback* callback_;
  140. Fl_MCallback mcallback_;
  141. };
  142. void* user_data_;
  143. //int x_,y_,w_,h_; //Using Fl_Rectangle
  144. Fl_AnyClass *any_class_mcb_;
  145. Fl_Label label_;
  146. unsigned int flags_;
  147. Fl_Color color_;
  148. Fl_Color color2_;
  149. uchar type_;
  150. uchar damage_;
  151. uchar box_;
  152. uchar when_;
  153. const char *tooltip_;
  154. /** unimplemented copy ctor */
  155. Fl_Widget(const Fl_Widget &);
  156. /** unimplemented assignment operator */
  157. Fl_Widget& operator=(const Fl_Widget &);
  158. protected:
  159. /** Creates a widget at the given position and size.
  160. The Fl_Widget is a protected constructor, but all derived widgets have a
  161. matching public constructor. It takes a value for x(), y(), w(), h(), and
  162. an optional value for label().
  163. \param[in] x, y the position of the widget relative to the enclosing window
  164. \param[in] w, h size of the widget in pixels
  165. \param[in] label optional text for the widget label
  166. */
  167. Fl_Widget(int x, int y, int w, int h, const char *label=0L);
  168. #if 0 //Using Fl_Rectangle as base class
  169. /** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */
  170. void x(int v) {x_ = v;}
  171. /** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */
  172. void y(int v) {y_ = v;}
  173. /** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */
  174. void w(int v) {w_ = v;}
  175. /** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */
  176. void h(int v) {h_ = v;}
  177. #endif
  178. /** Gets the widget flags mask */
  179. unsigned int flags() const {return flags_;}
  180. /** Sets a flag in the flags mask */
  181. void set_flag(unsigned int c) {flags_ |= c;}
  182. /** Clears a flag in the flags mask */
  183. void clear_flag(unsigned int c) {flags_ &= ~c;}
  184. /** flags possible values enumeration.
  185. See activate(), output(), visible(), changed(), set_visible_focus()
  186. */
  187. public:
  188. enum {
  189. INACTIVE = 1<<0, ///< the widget can't receive focus, and is disabled but potentially visible
  190. INVISIBLE = 1<<1, ///< the widget is not drawn, but can receive a few special events
  191. OUTPUT = 1<<2, ///< for output only
  192. NOBORDER = 1<<3, ///< don't draw a decoration (Fl_Window)
  193. FORCE_POSITION = 1<<4, ///< don't let the window manager position the window (Fl_Window)
  194. NON_MODAL = 1<<5, ///< this is a hovering toolbar window (Fl_Window)
  195. SHORTCUT_LABEL = 1<<6, ///< the label contains a shortcut we need to draw
  196. CHANGED = 1<<7, ///< the widget value changed
  197. OVERRIDE = 1<<8, ///< position window on top (Fl_Window)
  198. VISIBLE_FOCUS = 1<<9, ///< accepts keyboard focus navigation if the widget can have the focus
  199. COPIED_LABEL = 1<<10, ///< the widget label is internally copied, its destruction is handled by the widget
  200. CLIP_CHILDREN = 1<<11, ///< all drawing within this widget will be clipped (Fl_Group)
  201. MENU_WINDOW = 1<<12, ///< a temporary popup window, dismissed by clicking outside (Fl_Window)
  202. TOOLTIP_WINDOW = 1<<13, ///< a temporary popup, transparent to events, and dismissed easily (Fl_Window)
  203. MODAL = 1<<14, ///< a window blocking input to all other winows (Fl_Window)
  204. NO_OVERLAY = 1<<15, ///< window not using a hardware overlay plane (Fl_Menu_Window)
  205. GROUP_RELATIVE = 1<<16, ///< position this widget relative to the parent group, not to the window
  206. COPIED_TOOLTIP = 1<<17, ///< the widget tooltip is internally copied, its destruction is handled by the widget
  207. FULLSCREEN = 1<<18, ///< a fullscreen window (Fl_Window)
  208. MAC_USE_ACCENTS_MENU = 1<<19, ///< On the Mac OS platform, pressing and holding a key on the keyboard opens an accented-character menu window (Fl_Input_, Fl_Text_Editor)
  209. SELECT_ALL_ON_FOCUS = 1<<21, ///< when take focus select all text
  210. CHANGED2 = 1<<22, ///< the widget value changed and is not reseted by the callback call
  211. NUMERIC_RIGHT_TO_LEFT = 1 << 23, ///See bellow
  212. USE_NUMERIC_FORMAT = 1 << 24, ///Fl_Input and descendents used for numeric values with format
  213. ON_GROUP_ONLY_REMOVE = 1<<25, ///< Fl_Group should only remove this widget without apply free on it
  214. MY_MARK = 1 << 26,
  215. // (space for more flags)
  216. USERFLAG3 = 1<<29, ///< reserved for 3rd party extensions
  217. USERFLAG2 = 1<<30, ///< reserved for 3rd party extensions
  218. USERFLAG1 = 1<<31 ///< reserved for 3rd party extensions
  219. };
  220. protected:
  221. void draw_box() const;
  222. void draw_box(Fl_Boxtype t, Fl_Color c) const;
  223. void draw_box(Fl_Boxtype t, int x,int y,int w,int h, Fl_Color c) const;
  224. void draw_backdrop() const;
  225. /** draws a focus rectangle around the widget */
  226. void draw_focus() {draw_focus(box(),x(),y(),w(),h());}
  227. void draw_focus(Fl_Boxtype t, int x,int y,int w,int h) const;
  228. void draw_label() const;
  229. void draw_label(int, int, int, int) const;
  230. public:
  231. /** Destroys the widget.
  232. Destroying single widgets is not very common. You almost always want to
  233. destroy the parent group instead, which will destroy all of the child widgets
  234. and groups in that group.
  235. \since FLTK 1.3, the widget's destructor removes the widget from its parent
  236. group, if it is member of a group.
  237. */
  238. virtual ~Fl_Widget();
  239. /** Draws the widget.
  240. Never call this function directly. FLTK will schedule redrawing whenever
  241. needed. If your widget must be redrawn as soon as possible, call redraw()
  242. instead.
  243. Override this function to draw your own widgets.
  244. If you ever need to call another widget's draw method <I>from within your
  245. own draw() method</I>, e.g. for an embedded scrollbar, you can do it
  246. (because draw() is virtual) like this:
  247. \code
  248. Fl_Widget *s = &scroll; // scroll is an embedded Fl_Scrollbar
  249. s->draw(); // calls Fl_Scrollbar::draw()
  250. \endcode
  251. */
  252. virtual void draw() {}; //= 0;
  253. /** Handles the specified event.
  254. You normally don't call this method directly, but instead let FLTK do
  255. it when the user interacts with the widget.
  256. When implemented in a widget, this function must return 0 if the
  257. widget does not use the event or 1 otherwise.
  258. Most of the time, you want to call the inherited handle() method in
  259. your overridden method so that you don't short-circuit events that you
  260. don't handle. In this last case you should return the callee retval.
  261. \param[in] event the kind of event received
  262. \retval 0 if the event was not used or understood
  263. \retval 1 if the event was used and can be deleted
  264. \see Fl_Event
  265. */
  266. virtual int handle(int event);
  267. /** Returns a pointer to the root parent widget.
  268. Usually this is a Fl_Window.
  269. \retval NULL if the widget has no root parent
  270. */
  271. Fl_Group* parent_root() const;
  272. /** Returns a pointer to the parent widget.
  273. Usually this is a Fl_Group or Fl_Window.
  274. \retval NULL if the widget has no parent
  275. \see Fl_Group::add(Fl_Widget*)
  276. */
  277. Fl_Group* parent() const {return parent_;}
  278. /** Internal use only - "for hacks only".
  279. It is \em \b STRONGLY recommended not to use this method, because it
  280. short-circuits Fl_Group's normal widget adding and removing methods,
  281. if the widget is already a child widget of another Fl_Group.
  282. Use Fl_Group::add(Fl_Widget*) and/or Fl_Group::remove(Fl_Widget*) instead.
  283. */
  284. void parent(Fl_Group* p) {parent_ = p;} // for hacks only, use Fl_Group::add()
  285. /** Gets the widget type.
  286. Returns the widget type value, which is used for Forms compatibility
  287. and to simulate RTTI.
  288. \todo Explain "simulate RTTI" (currently only used to decide if a widget
  289. is a window, i.e. type()>=FL_WINDOW ?). Is type() really used in a way
  290. that ensures "Forms compatibility" ?
  291. */
  292. uchar type() const {return type_;}
  293. /** Sets the widget type.
  294. This is used for Forms compatibility.
  295. */
  296. void type(uchar t) {type_ = t;}
  297. #if 0 //Using Fl_Rectangle as base class
  298. /** Gets the widget position in its window.
  299. \return the x position relative to the window
  300. */
  301. int x() const {return x_;}
  302. /** Gets the widget position in its window.
  303. \return the y position relative to the window
  304. */
  305. int y() const {return y_;}
  306. /** Gets the widget width.
  307. \return the width of the widget in pixels.
  308. */
  309. int w() const {return w_;}
  310. /** Gets the widget height.
  311. \return the height of the widget in pixels.
  312. */
  313. int h() const {return h_;}
  314. #endif
  315. /**
  316. Returns the full rectangle occupied by a widget plus it's external label if any
  317. */
  318. void get_full_size(int &full_x, int &full_y, int &full_w, int &full_h);
  319. /** Changes the size or position of the widget.
  320. This is a virtual function so that the widget may implement its
  321. own handling of resizing. The default version does \e not
  322. call the redraw() method, but instead relies on the parent widget
  323. to do so because the parent may know a faster way to update the
  324. display, such as scrolling from the old position.
  325. Some window managers under X11 call resize() a lot more often
  326. than needed. Please verify that the position or size of a widget
  327. did actually change before doing any extensive calculations.
  328. position(X, Y) is a shortcut for resize(X, Y, w(), h()),
  329. and size(W, H) is a shortcut for resize(x(), y(), W, H).
  330. \param[in] x, y new position relative to the parent window
  331. \param[in] w, h new size
  332. \see position(int,int), size(int,int)
  333. */
  334. virtual void resize(int x, int y, int w, int h);
  335. /** Internal use only. */
  336. int damage_resize(int,int,int,int);
  337. /** Repositions the window or widget.
  338. position(X, Y) is a shortcut for resize(X, Y, w(), h()).
  339. \param[in] X, Y new position relative to the parent window
  340. \see resize(int,int,int,int), size(int,int)
  341. */
  342. void position(int X,int Y) {resize(X,Y,w_,h_);}
  343. /** Changes the size of the widget.
  344. size(W, H) is a shortcut for resize(x(), y(), W, H).
  345. \param[in] W, H new size
  346. \see position(int,int), resize(int,int,int,int)
  347. */
  348. void size(int W,int H) {resize(x_,y_,W,H);}
  349. /** Gets the label alignment.
  350. \return label alignment
  351. \see label(), align(Fl_Align), Fl_Align
  352. */
  353. Fl_Align align() const {return label_.align_;}
  354. /** Sets the label alignment.
  355. This controls how the label is displayed next to or inside the widget.
  356. The default value is FL_ALIGN_CENTER, which centers the label inside
  357. the widget.
  358. \param[in] alignment new label alignment
  359. \see align(), Fl_Align
  360. */
  361. void align(Fl_Align alignment) {label_.align_ = alignment;}
  362. /** Gets the box type of the widget.
  363. \return the current box type
  364. \see box(Fl_Boxtype), Fl_Boxtype
  365. */
  366. Fl_Boxtype box() const {return (Fl_Boxtype)box_;}
  367. /** Sets the box type for the widget.
  368. This identifies a routine that draws the background of the widget.
  369. See Fl_Boxtype for the available types. The default depends on the
  370. widget, but is usually FL_NO_BOX or FL_UP_BOX.
  371. \param[in] new_box the new box type
  372. \see box(), Fl_Boxtype
  373. */
  374. void box(Fl_Boxtype new_box) {box_ = new_box;}
  375. /** Gets the background color of the widget.
  376. \return current background color
  377. \see color(Fl_Color), color(Fl_Color, Fl_Color)
  378. */
  379. Fl_Color color() const {return color_;}
  380. /** Sets the background color of the widget.
  381. The color is passed to the box routine. The color is either an index into
  382. an internal table of RGB colors or an RGB color value generated using
  383. fl_rgb_color().
  384. The default for most widgets is FL_BACKGROUND_COLOR. Use Fl::set_color()
  385. to redefine colors in the color map.
  386. \param[in] bg background color
  387. \see color(), color(Fl_Color, Fl_Color), selection_color(Fl_Color)
  388. */
  389. void color(Fl_Color bg) {color_ = bg;}
  390. /** Gets the selection color.
  391. \return the current selection color
  392. \see selection_color(Fl_Color), color(Fl_Color, Fl_Color)
  393. */
  394. Fl_Color selection_color() const {return color2_;}
  395. /** Sets the selection color.
  396. The selection color is defined for Forms compatibility and is usually
  397. used to color the widget when it is selected, although some widgets
  398. use this color for other purposes. You can set both colors at once
  399. with color(Fl_Color bg, Fl_Color sel).
  400. \param[in] a the new selection color
  401. \see selection_color(), color(Fl_Color, Fl_Color)
  402. */
  403. void selection_color(Fl_Color a) {color2_ = a;}
  404. /** Sets the background and selection color of the widget.
  405. The two color form sets both the background and selection colors.
  406. \param[in] bg background color
  407. \param[in] sel selection color
  408. \see color(unsigned), selection_color(unsigned)
  409. */
  410. void color(Fl_Color bg, Fl_Color sel) {color_=bg; color2_=sel;}
  411. /** Gets the current label text.
  412. \return a pointer to the current label text
  413. \see label(const char *), copy_label(const char *)
  414. */
  415. const char* label() const {return label_.value;}
  416. /** Sets the current label pointer.
  417. The label is shown somewhere on or next to the widget. The passed pointer
  418. is stored unchanged in the widget (the string is \em not copied), so if
  419. you need to set the label to a formatted value, make sure the buffer is
  420. static, global, or allocated. The copy_label() method can be used
  421. to make a copy of the label string automatically.
  422. \param[in] text pointer to new label text
  423. \see copy_label()
  424. */
  425. void label(const char* text);
  426. /** Sets the current label.
  427. Unlike label(), this method allocates a copy of the label
  428. string instead of using the original string pointer.
  429. The internal copy will automatically be freed whenever you assign
  430. a new label or when the widget is destroyed.
  431. \param[in] new_label the new label text
  432. \see label()
  433. */
  434. void copy_label(const char *new_label);
  435. /** Shortcut to set the label text and type in one call.
  436. \see label(const char *), labeltype(Fl_Labeltype)
  437. */
  438. void label(Fl_Labeltype a, const char* b) {label_.type = a; label_.value = b;}
  439. /** Gets the label type.
  440. \return the current label type.
  441. \see Fl_Labeltype
  442. */
  443. Fl_Labeltype labeltype() const {return (Fl_Labeltype)label_.type;}
  444. /** Sets the label type.
  445. The label type identifies the function that draws the label of the widget.
  446. This is generally used for special effects such as embossing or for using
  447. the label() pointer as another form of data such as an icon. The value
  448. FL_NORMAL_LABEL prints the label as plain text.
  449. \param[in] a new label type
  450. \see Fl_Labeltype
  451. */
  452. void labeltype(Fl_Labeltype a) {label_.type = a;}
  453. /** Gets the label color.
  454. The default color is FL_FOREGROUND_COLOR.
  455. \return the current label color
  456. */
  457. Fl_Color labelcolor() const {return label_.color;}
  458. /** Sets the label color.
  459. The default color is FL_FOREGROUND_COLOR.
  460. \param[in] c the new label color
  461. */
  462. void labelcolor(Fl_Color c) {label_.color=c;}
  463. /** Gets the font to use.
  464. Fonts are identified by indexes into a table. The default value
  465. uses a Helvetica typeface (Arial for Microsoft&reg; Windows&reg;).
  466. The function Fl::set_font() can define new typefaces.
  467. \return current font used by the label
  468. \see Fl_Font
  469. */
  470. Fl_Font labelfont() const {return label_.font;}
  471. /** Sets the font to use.
  472. Fonts are identified by indexes into a table. The default value
  473. uses a Helvetica typeface (Arial for Microsoft&reg; Windows&reg;).
  474. The function Fl::set_font() can define new typefaces.
  475. \param[in] f the new font for the label
  476. \see Fl_Font
  477. */
  478. void labelfont(Fl_Font f) {label_.font=f;}
  479. /** Gets the font size in pixels.
  480. The default size is 14 pixels.
  481. \return the current font size
  482. */
  483. Fl_Fontsize labelsize() const {return label_.size;}
  484. /** Sets the font size in pixels.
  485. \param[in] pix the new font size
  486. \see Fl_Fontsize labelsize()
  487. */
  488. void labelsize(Fl_Fontsize pix) {label_.size=pix;}
  489. /** Gets the font of the text in derived
  490. classes like input field.
  491. \return the current Fl_Font index */
  492. virtual Fl_Font textfont() const {Fl_Font f = labelfont(); return f ? f : FL_HELVETICA;}
  493. /** Sets the font of the text in derived
  494. classes like input field.
  495. The text font defaults to \c FL_HELVETICA.
  496. \param [in] s the new text font */
  497. virtual void textfont(Fl_Font s) {}
  498. /** Gets the size of the text in derived
  499. classes like input field.
  500. \return the text height in pixels */
  501. virtual Fl_Fontsize textsize() const {Fl_Fontsize s = labelsize(); return s ? s : 10;}
  502. /** Sets the size of the text in derived
  503. classes like input field.
  504. The text height defaults to \c FL_NORMAL_SIZE.
  505. \param [in] s the new font height in pixel units */
  506. virtual void textsize(Fl_Fontsize s) {}
  507. /** Gets the image that is used as part of the widget label.
  508. This image is used when drawing the widget in the active state.
  509. \return the current image
  510. */
  511. Fl_Image* image() {return label_.image;}
  512. const Fl_Image* image() const {return label_.image;}
  513. /** Sets the image to use as part of the widget label.
  514. This image is used when drawing the widget in the active state.
  515. \param[in] img the new image for the label
  516. */
  517. void image(Fl_Image* img) {label_.image=img;}
  518. /** Sets the image to use as part of the widget label.
  519. This image is used when drawing the widget in the active state.
  520. \param[in] img the new image for the label
  521. */
  522. void image(Fl_Image& img) {label_.image=&img;}
  523. /** Gets the image that is used as part of the widget label.
  524. This image is used when drawing the widget in the inactive state.
  525. \return the current image for the deactivated widget
  526. */
  527. Fl_Image* deimage() {return label_.deimage;}
  528. const Fl_Image* deimage() const {return label_.deimage;}
  529. /** Sets the image to use as part of the widget label.
  530. This image is used when drawing the widget in the inactive state.
  531. \param[in] img the new image for the deactivated widget
  532. */
  533. void deimage(Fl_Image* img) {label_.deimage=img;}
  534. /** Sets the image to use as part of the widget label.
  535. This image is used when drawing the widget in the inactive state.
  536. \param[in] img the new image for the deactivated widget
  537. */
  538. void deimage(Fl_Image& img) {label_.deimage=&img;}
  539. /** Gets the current tooltip text.
  540. \return a pointer to the tooltip text or NULL
  541. \see tooltip(const char*), copy_tooltip(const char*)
  542. */
  543. const char *tooltip() const {return tooltip_;}
  544. void tooltip(const char *text); // see Fl_Tooltip
  545. void copy_tooltip(const char *text); // see Fl_Tooltip
  546. /** Gets the current callback function for the widget.
  547. Each widget has a single callback.
  548. \return current callback
  549. */
  550. Fl_Callback_p callback() const {return callback_;}
  551. /** Sets the current callback function for the widget.
  552. Each widget has a single callback.
  553. \param[in] cb new callback
  554. \param[in] p user data
  555. */
  556. void callback(Fl_Callback* cb, void* p) {callback_=cb; user_data_=p;}
  557. /** Sets the current callback function for the widget.
  558. Each widget has a single callback.
  559. \param[in] cb new callback
  560. */
  561. void callback(Fl_Callback* cb) {callback_=cb;}
  562. /** Sets the current callback function for the widget.
  563. Each widget has a single callback.
  564. \param[in] cb new callback
  565. */
  566. void callback(Fl_Callback0*cb) {callback_=(Fl_Callback*)cb;}
  567. /** Sets the current callback function for the widget.
  568. Each widget has a single callback.
  569. \param[in] cb new callback
  570. \param[in] p user data
  571. */
  572. void callback(Fl_Callback1*cb, long p=0) {callback_=(Fl_Callback*)cb; user_data_=(void*)p;}
  573. /** Gets the user data for this widget.
  574. Gets the current user data (void *) argument that is passed to the callback function.
  575. \return user data as a pointer
  576. */
  577. void* user_data() const {return user_data_;}
  578. /** Sets the user data for this widget.
  579. Sets the new user data (void *) argument that is passed to the callback function.
  580. \param[in] v new user data
  581. */
  582. void user_data(void* v) {user_data_ = v;}
  583. /** Gets the current user data (long) argument that is passed to the callback function.
  584. */
  585. long argument() const {return (long)(fl_intptr_t)user_data_;}
  586. /** Sets the current user data (long) argument that is passed to the callback function.
  587. \todo The user data value must be implemented using \em intptr_t or similar
  588. to avoid 64-bit machine incompatibilities.
  589. */
  590. void argument(long v) {user_data_ = (void*)v;}
  591. /** Returns the conditions under which the callback is called.
  592. You can set the flags with when(uchar), the default value is
  593. FL_WHEN_RELEASE.
  594. \return set of flags
  595. \see when(uchar)
  596. */
  597. Fl_When when() const {return (Fl_When)when_;}
  598. /** Sets the flags used to decide when a callback is called.
  599. This controls when callbacks are done. The following values are useful,
  600. the default value is FL_WHEN_RELEASE:
  601. \li 0: The callback is not done, but changed() is turned on.
  602. \li FL_WHEN_CHANGED: The callback is done each time the text is
  603. changed by the user.
  604. \li FL_WHEN_RELEASE: The callback will be done when this widget loses
  605. the focus, including when the window is unmapped. This is a useful
  606. value for text fields in a panel where doing the callback on every
  607. change is wasteful. However the callback will also happen if the
  608. mouse is moved out of the window, which means it should not do
  609. anything visible (like pop up an error message).
  610. You might do better setting this to zero, and scanning all the
  611. items for changed() when the OK button on a panel is pressed.
  612. \li FL_WHEN_ENTER_KEY: If the user types the Enter key, the entire
  613. text is selected, and the callback is done if the text has changed.
  614. Normally the Enter key will navigate to the next field (or insert
  615. a newline for a Fl_Multiline_Input) - this changes the behavior.
  616. \li FL_WHEN_ENTER_KEY|FL_WHEN_NOT_CHANGED: The Enter key will do the
  617. callback even if the text has not changed. Useful for command fields.
  618. Fl_Widget::when() is a set of bitflags used by subclasses of
  619. Fl_Widget to decide when to do the callback.
  620. If the value is zero then the callback is never done. Other values
  621. are described in the individual widgets. This field is in the base
  622. class so that you can scan a panel and do_callback() on all the ones
  623. that don't do their own callbacks in response to an "OK" button.
  624. \param[in] i set of flags
  625. */
  626. void when(uchar i) {when_ = i;}
  627. /** Returns whether a widget is visible.
  628. \retval 0 if the widget is not drawn and hence invisible.
  629. \see show(), hide(), visible_r()
  630. */
  631. unsigned int visible() const {return !(flags_&INVISIBLE);}
  632. /** Returns whether a widget and all its parents are visible.
  633. \retval 0 if the widget or any of its parents are invisible.
  634. \see show(), hide(), visible()
  635. */
  636. int visible_r() const;
  637. /** Makes a widget visible.
  638. An invisible widget never gets redrawn and does not get keyboard
  639. or mouse events, but can receive a few other events like FL_SHOW.
  640. The visible() method returns true if the widget is set to be
  641. visible. The visible_r() method returns true if the widget and
  642. all of its parents are visible. A widget is only visible if
  643. visible() is true on it <I>and all of its parents</I>.
  644. Changing it will send FL_SHOW or FL_HIDE events to the widget.
  645. <I>Do not change it if the parent is not visible, as this
  646. will send false FL_SHOW or FL_HIDE events to the widget</I>.
  647. redraw() is called if necessary on this or the parent.
  648. \see hide(), visible(), visible_r()
  649. */
  650. virtual void show();
  651. /** Makes a widget invisible.
  652. \see show(), visible(), visible_r()
  653. */
  654. virtual void hide();
  655. /** Makes the widget visible.
  656. You must still redraw the parent widget to see a change in the
  657. window. Normally you want to use the show() method instead.
  658. */
  659. void set_visible() {flags_ &= ~INVISIBLE;}
  660. /** Hides the widget.
  661. You must still redraw the parent to see a change in the window.
  662. Normally you want to use the hide() method instead.
  663. */
  664. void clear_visible() {flags_ |= INVISIBLE;}
  665. /** Returns whether the widget is in full screen mode
  666. \retval non 0 if in full screen mode
  667. */
  668. unsigned int is_fullscreen() const {return (flags_ & FULLSCREEN);}
  669. /** Returns whether the widget is active.
  670. \retval 0 if the widget is inactive
  671. \see active_r(), activate(), deactivate()
  672. */
  673. unsigned int active() const {return !(flags_&INACTIVE);}
  674. /** Returns whether the widget and all of its parents are active.
  675. \retval 0 if this or any of the parent widgets are inactive
  676. \see active(), activate(), deactivate()
  677. */
  678. int active_r() const;
  679. /** Activates the widget.
  680. Changing this value will send FL_ACTIVATE to the widget if
  681. active_r() is true.
  682. \see active(), active_r(), deactivate()
  683. */
  684. void activate();
  685. /** Deactivates the widget.
  686. Inactive widgets will be drawn "grayed out", e.g. with less contrast
  687. than the active widget. Inactive widgets will not receive any keyboard
  688. or mouse button events. Other events (including FL_ENTER, FL_MOVE,
  689. FL_LEAVE, FL_SHORTCUT, and others) will still be sent. A widget is
  690. only active if active() is true on it <I>and all of its parents</I>.
  691. Changing this value will send FL_DEACTIVATE to the widget if
  692. active_r() is true.
  693. Currently you cannot deactivate Fl_Window widgets.
  694. \see activate(), active(), active_r()
  695. */
  696. void deactivate();
  697. /** Returns if a widget is used for output only.
  698. output() means the same as !active() except it does not change how the
  699. widget is drawn. The widget will not receive any events. This is useful
  700. for making scrollbars or buttons that work as displays rather than input
  701. devices.
  702. \retval 0 if the widget is used for input and output
  703. \see set_output(), clear_output()
  704. */
  705. unsigned int output() const {return (flags_&OUTPUT);}
  706. /** Sets a widget to output only.
  707. \see output(), clear_output()
  708. */
  709. void set_output() {flags_ |= OUTPUT;}
  710. /** Sets a widget to accept input.
  711. \see set_output(), output()
  712. */
  713. void clear_output() {flags_ &= ~OUTPUT;}
  714. /** Returns if the widget is able to take events.
  715. This is the same as (active() && !output() && visible())
  716. but is faster.
  717. \retval 0 if the widget takes no events
  718. */
  719. unsigned int takesevents() const {return !(flags_&(INACTIVE|INVISIBLE|OUTPUT));}
  720. /**
  721. Checks if the widget value changed since the last callback.
  722. "Changed" is a flag that is turned on when the user changes the value
  723. stored in the widget. This is only used by subclasses of Fl_Widget that
  724. store values, but is in the base class so it is easier to scan all the
  725. widgets in a panel and do_callback() on the changed ones in response
  726. to an "OK" button.
  727. Most widgets turn this flag off when they do the callback, and when
  728. the program sets the stored value.
  729. \retval 0 if the value did not change
  730. \see set_changed(), clear_changed()
  731. */
  732. unsigned int changed() const {return flags_&CHANGED;}
  733. unsigned int changed2() const {return flags_&CHANGED2;}
  734. /** Marks the value of the widget as changed.
  735. \see changed(), clear_changed()
  736. */
  737. void set_changed() {flags_ |= (CHANGED|CHANGED2);}
  738. void set_changed2() {flags_ |= CHANGED2;}
  739. /** Marks the value of the widget as unchanged.
  740. \see changed(), set_changed()
  741. */
  742. void clear_changed() {flags_ &= ~CHANGED;}
  743. void clear_changed2() {flags_ &= ~CHANGED2;}
  744. void clear_changed_all() {flags_ &= ~(CHANGED|CHANGED2);}
  745. /** Gives the widget the keyboard focus.
  746. Tries to make this widget be the Fl::focus() widget, by first sending
  747. it an FL_FOCUS event, and if it returns non-zero, setting
  748. Fl::focus() to this widget. You should use this method to
  749. assign the focus to a widget.
  750. \return true if the widget accepted the focus.
  751. */
  752. int take_focus();
  753. int select_all_on_focus() {return flags_&SELECT_ALL_ON_FOCUS;}
  754. void select_all_on_focus(int bFlag) {
  755. if(bFlag) flags_|=SELECT_ALL_ON_FOCUS;
  756. else flags_ &= ~SELECT_ALL_ON_FOCUS;
  757. }
  758. void on_group_only_remove(int bFlag) {
  759. if(bFlag) flags_|=ON_GROUP_ONLY_REMOVE;
  760. else flags_ &= ~ON_GROUP_ONLY_REMOVE;
  761. }
  762. /** Enables keyboard focus navigation with this widget.
  763. Note, however, that this will not necessarily mean that the widget
  764. will accept focus, but for widgets that can accept focus, this method
  765. enables it if it has been disabled.
  766. \see visible_focus(), clear_visible_focus(), visible_focus(int)
  767. */
  768. void set_visible_focus() { flags_ |= VISIBLE_FOCUS; }
  769. /** Disables keyboard focus navigation with this widget.
  770. Normally, all widgets participate in keyboard focus navigation.
  771. \see set_visible_focus(), visible_focus(), visible_focus(int)
  772. */
  773. void clear_visible_focus() { flags_ &= ~VISIBLE_FOCUS; }
  774. /** Modifies keyboard focus navigation.
  775. \param[in] v set or clear visible focus
  776. \see set_visible_focus(), clear_visible_focus(), visible_focus()
  777. */
  778. void visible_focus(int v) { if (v) set_visible_focus(); else clear_visible_focus(); }
  779. /** Checks whether this widget has a visible focus.
  780. \retval 0 if this widget has no visible focus.
  781. \see visible_focus(int), set_visible_focus(), clear_visible_focus()
  782. */
  783. unsigned int visible_focus() const { return flags_ & VISIBLE_FOCUS; }
  784. /** Sets the default callback for all widgets.
  785. Sets the default callback, which puts a pointer to the widget on the queue
  786. returned by Fl::readqueue(). You may want to call this from your own callback.
  787. \param[in] cb the new callback
  788. \param[in] d user data associated with that callback
  789. \see callback(), do_callback(), Fl::readqueue()
  790. */
  791. static void default_callback(Fl_Widget *cb, void *d);
  792. /** Calls the widget callback.
  793. Causes a widget to invoke its callback function with default arguments.
  794. \see callback()
  795. */
  796. void do_callback() {do_callback(this,user_data_);}
  797. /** Calls the widget callback.
  798. Causes a widget to invoke its callback function with arbitrary arguments.
  799. \param[in] o call the callback with \p o as the widget argument
  800. \param[in] arg call the callback with \p arg as the user data argument
  801. \see callback()
  802. */
  803. void do_callback(Fl_Widget* o,long arg) {do_callback(o,(void*)arg);}
  804. // Causes a widget to invoke its callback function with arbitrary arguments.
  805. // Documentation and implementation in Fl_Widget.cxx
  806. virtual void do_callback(Fl_Widget* o,void* arg=0);
  807. /* Internal use only. */
  808. int test_shortcut();
  809. /* Internal use only. */
  810. static unsigned int label_shortcut(const char *t);
  811. /* Internal use only. */
  812. static int test_shortcut(const char*, const bool require_alt = false);
  813. /* Internal use only. */
  814. void _set_fullscreen() {flags_ |= FULLSCREEN;}
  815. void _clear_fullscreen() {flags_ &= ~FULLSCREEN;}
  816. /** Checks if w is a child of this widget.
  817. \param[in] w potential child widget
  818. \return Returns 1 if \p w is a child of this widget, or is
  819. equal to this widget. Returns 0 if \p w is NULL.
  820. */
  821. int contains(const Fl_Widget *w) const ;
  822. /** Checks if this widget is a child of \p wgt.
  823. Returns 1 if this widget is a child of \p wgt, or is
  824. equal to \p wgt. Returns 0 if \p wgt is NULL.
  825. \param[in] wgt the possible parent widget.
  826. \see contains()
  827. */
  828. int inside(const Fl_Widget* wgt) const {return wgt ? wgt->contains(this) : 0;}
  829. /** Schedules the drawing of the widget.
  830. Marks the widget as needing its draw() routine called.
  831. */
  832. void redraw();
  833. /** Schedules the drawing of the label.
  834. Marks the widget or the parent as needing a redraw for the label area
  835. of a widget.
  836. */
  837. void redraw_label();
  838. /** Returns non-zero if draw() needs to be called.
  839. The damage value is actually a bit field that the widget
  840. subclass can use to figure out what parts to draw.
  841. \return a bitmap of flags describing the kind of damage to the widget
  842. \see damage(uchar), clear_damage(uchar)
  843. */
  844. uchar damage() const {return damage_;}
  845. /** Clears or sets the damage flags.
  846. Damage flags are cleared when parts of the widget drawing is repaired.
  847. The optional argument \p c specifies the bits that <b>are set</b>
  848. after the call (default: 0) and \b not the bits that are cleared!
  849. \note Therefore it is possible to set damage bits with this method, but
  850. this should be avoided. Use damage(uchar) instead.
  851. \param[in] c new bitmask of damage flags (default: 0)
  852. \see damage(uchar), damage()
  853. */
  854. void clear_damage(uchar c = 0) {damage_ = c;}
  855. /** Sets the damage bits for the widget.
  856. Setting damage bits will schedule the widget for the next redraw.
  857. \param[in] c bitmask of flags to set
  858. \see damage(), clear_damage(uchar)
  859. */
  860. void damage(uchar c);
  861. /** Sets the damage bits for an area inside the widget.
  862. Setting damage bits will schedule the widget for the next redraw.
  863. \param[in] c bitmask of flags to set
  864. \param[in] x, y, w, h size of damaged area
  865. \see damage(), clear_damage(uchar)
  866. */
  867. void damage(uchar c, int x, int y, int w, int h);
  868. void draw_label(int, int, int, int, Fl_Align) const;
  869. /** Sets width ww and height hh accordingly with the label size.
  870. Labels with images will return w() and h() of the image.
  871. This calls fl_measure() internally. For more information about
  872. the arguments \p ww and \p hh and word wrapping
  873. \see fl_measure(const char*, int&, int&, int)
  874. */
  875. void measure_label(int& ww, int& hh) const {label_.measure(ww, hh);}
  876. /** Returns a pointer to the primary Fl_Window widget.
  877. \retval NULL if no window is associated with this widget.
  878. \note for an Fl_Window widget, this returns its <I>parent</I> window
  879. (if any), not <I>this</I> window.
  880. */
  881. Fl_Window* window() const ;
  882. Fl_Window* top_window() const;
  883. Fl_Window* top_window_offset(int& xoff, int& yoff) const;
  884. /** Returns an Fl_Group pointer if this widget is an Fl_Group.
  885. Use this method if you have a widget (pointer) and need to
  886. know whether this widget is derived from Fl_Group. If it returns
  887. non-NULL, then the widget in question is derived from Fl_Group,
  888. and you can use the returned pointer to access its children
  889. or other Fl_Group-specific methods.
  890. Example:
  891. \code
  892. void my_callback (Fl_Widget *w, void *) {
  893. Fl_Group *g = w->as_group();
  894. if (g)
  895. printf ("This group has %d children\n",g->children());
  896. else
  897. printf ("This widget is not a group!\n");
  898. }
  899. \endcode
  900. \retval NULL if this widget is not derived from Fl_Group.
  901. \note This method is provided to avoid dynamic_cast.
  902. \see Fl_Widget::as_window(), Fl_Widget::as_gl_window()
  903. */
  904. virtual Fl_Group* as_group() {return 0;}
  905. /** Returns an Fl_Window pointer if this widget is an Fl_Window.
  906. Use this method if you have a widget (pointer) and need to
  907. know whether this widget is derived from Fl_Window. If it returns
  908. non-NULL, then the widget in question is derived from Fl_Window,
  909. and you can use the returned pointer to access its children
  910. or other Fl_Window-specific methods.
  911. \retval NULL if this widget is not derived from Fl_Window.
  912. \note This method is provided to avoid dynamic_cast.
  913. \see Fl_Widget::as_group(), Fl_Widget::as_gl_window()
  914. */
  915. virtual Fl_Window* as_window() {return 0;}
  916. /** Returns an Fl_Gl_Window pointer if this widget is an Fl_Gl_Window.
  917. Use this method if you have a widget (pointer) and need to
  918. know whether this widget is derived from Fl_Gl_Window. If it returns
  919. non-NULL, then the widget in question is derived from Fl_Gl_Window.
  920. \retval NULL if this widget is not derived from Fl_Gl_Window.
  921. \note This method is provided to avoid dynamic_cast.
  922. \see Fl_Widget::as_group(), Fl_Widget::as_window()
  923. */
  924. virtual class Fl_Gl_Window* as_gl_window() {return 0;}
  925. /** Returns non zero if MAC_USE_ACCENTS_MENU flag is set, 0 otherwise.
  926. */
  927. int use_accents_menu() { return flags() & MAC_USE_ACCENTS_MENU; }
  928. /** For back compatibility only.
  929. \deprecated Use selection_color() instead.
  930. */
  931. Fl_Color color2() const {return (Fl_Color)color2_;}
  932. /** For back compatibility only.
  933. \deprecated Use selection_color(unsigned) instead.
  934. */
  935. void color2(unsigned a) {color2_ = a;}
  936. /** Set the associated data pointer for this widget.
  937. \param [in] at the data type of the association
  938. \param [in] data the actual pointer to set
  939. */
  940. void set_assoc(const Fl_Association_Type&, void* data) const;
  941. /** Get the data pointer for the given association type that is assigned to this widget.
  942. \param [in] at the data type of the association
  943. \retval pointer to the associated data or NULL if non is associated
  944. */
  945. void* get_assoc(const Fl_Association_Type&) const;
  946. /** Remove all associations of the given type.
  947. \param [in] at the data type of the association
  948. */
  949. void remove_assoc(const Fl_Association_Type&) const;
  950. /** class that holds a method for callbacks*/
  951. Fl_AnyClass *any_class_mcb() {return any_class_mcb_;};
  952. /** Gets the current class method callback function for the widget.
  953. Each widget has a single class method callback.
  954. \return current mcallback
  955. */
  956. Fl_MCallback mcallback() const {return mcallback_;}
  957. /** Sets the current class method callback function for the widget.
  958. Each widget has a single class method callback.
  959. \param[in] cb new class method callback
  960. \param[in] p user data
  961. */
  962. void mcallback(Fl_AnyClass *klass, Fl_MCallback cb, void* p) {
  963. any_class_mcb_ = klass;
  964. mcallback_=cb;
  965. user_data_=p;
  966. }
  967. /** Sets the current class method callback function for the widget.
  968. Each widget has a single callback.
  969. \param[in] cb new method callback
  970. */
  971. void mcallback(Fl_AnyClass *klass, Fl_MCallback cb) {
  972. any_class_mcb_ = klass;
  973. mcallback_=cb;
  974. }
  975. /** Sets the current callback method function for the widget.
  976. Each widget has a single method callback.
  977. \param[in] cb new callback
  978. */
  979. void mcallback(Fl_AnyClass *klass, Fl_MCallback0 cb) {
  980. any_class_mcb_ = klass;
  981. mcallback_=(Fl_MCallback)cb;
  982. }
  983. /** Sets the current callback method function for the widget.
  984. Each widget has a single method callback.
  985. \param[in] cb new callback
  986. */
  987. void mcallback(Fl_AnyClass *klass, Fl_MCallback1 cb) {
  988. any_class_mcb_ = klass;
  989. mcallback_=(Fl_MCallback)cb;
  990. }
  991. /** Sets the current callback method function for the widget.
  992. Each widget has a single method callback.
  993. \param[in] cb new callback
  994. \param[in] p user data
  995. */
  996. void mcallback(Fl_AnyClass *klass, Fl_MCallback2 cb, long p=0) {
  997. any_class_mcb_ = klass;
  998. mcallback_=(Fl_MCallback)cb;
  999. user_data_=(void*)p;
  1000. }
  1001. /*! Fills the Rectangle pointed to by \a rect with the widget's
  1002. rectangle expressed in relative to parent coordinates.
  1003. */
  1004. void get_relative_rect( Fl_Rectangle &rect ) const;
  1005. /*Virtual function for any user purpose to extend FLTK*/
  1006. virtual void *user_callback(Fl_Widget *sender, int when, void *udata=0){return 0;}
  1007. //DAD Extensios
  1008. DECLARE_CLASS_CHEAP_RTTI_1(Fl_Widget)
  1009. };
  1010. /**
  1011. Reserved type numbers (necessary for my cheapo RTTI) start here.
  1012. Grep the header files for "RESERVED_TYPE" to find the next available
  1013. number.
  1014. */
  1015. #define FL_RESERVED_TYPE 100
  1016. #endif
  1017. //
  1018. // End of "$Id: Fl_Widget.H 10096 2014-02-08 01:10:44Z AlbrechtS $".
  1019. //