1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Multi-label header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2015-02-04 16:12:43 +03:00
|
|
|
// Copyright 1998-2015 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
|
|
// file is missing or damaged, see the license at:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/COPYING.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
#ifndef Fl_Multi_Label_H
|
|
|
|
#define Fl_Multi_Label_H
|
|
|
|
|
|
|
|
class Fl_Widget;
|
|
|
|
struct Fl_Menu_Item;
|
|
|
|
|
2015-02-04 16:12:43 +03:00
|
|
|
/** This struct allows multiple labels to be added to objects that might normally have only one label.
|
|
|
|
|
|
|
|
This struct allows a mixed text and/or graphics label to be applied to an object that
|
|
|
|
would normally only have a single (usually text only) label.
|
|
|
|
|
|
|
|
Most regular FLTK widgets now support the ability to associate both images and text
|
|
|
|
with a label but some special cases, notably the non-widget Fl_Menu_Item objects, do not.
|
|
|
|
Fl_Multi_Label may be used to create menu items that have an icon and text, which would
|
|
|
|
not normally be possible for an Fl_Menu_Item.
|
|
|
|
For example, Fl_Multi_Label is used in the New->Code submenu in fluid, and others.
|
|
|
|
|
2017-09-12 23:12:21 +03:00
|
|
|
\image html Fl_Multi_Label-menu-item.png "Menu items with icons using Fl_Multi_Label"
|
|
|
|
\image latex Fl_Multi_Label-menu-item.png "Menu items with icons using Fl_Multi_Label" width=4cm
|
|
|
|
|
2015-02-04 16:12:43 +03:00
|
|
|
Each Fl_Multi_Label holds two elements, labela and labelb; each may hold either a
|
|
|
|
text label (const char*) or an image (Fl_Image*). When displayed, labela is drawn first
|
|
|
|
and labelb is drawn immediately to its right.
|
|
|
|
|
|
|
|
More complex labels might be constructed by setting labelb as another Fl_Multi_Label and
|
|
|
|
thus chaining up a series of label elements.
|
|
|
|
|
|
|
|
When assigning a label element to one of labela or labelb, they should be explicitly cast
|
|
|
|
to (const char*) if they are not of that type already.
|
|
|
|
|
2017-09-12 00:27:53 +03:00
|
|
|
Example Use: Fl_Menu_Bar
|
|
|
|
\code
|
|
|
|
Fl_Pixmap *image = new Fl_Pixmap(..); // image for menu item; can be any Fl_Image based widget
|
|
|
|
Fl_Menu_Bar *menu = new Fl_Menu_Bar(..); // can be any Fl_Menu_ oriented widget (Fl_Choice, Fl_Menu_Button..)
|
|
|
|
|
|
|
|
// Create a menu item
|
|
|
|
int i = menu->add("File/New", ..);
|
|
|
|
Fl_Menu_Item *item = (Fl_Menu_Item*)&(menu->menu()[i]);
|
|
|
|
|
|
|
|
// Create a multi label, assign it an image + text
|
|
|
|
Fl_Multi_Label *ml = new Fl_Multi_Label;
|
|
|
|
|
|
|
|
// Left side of label is an image
|
|
|
|
ml->typea = FL_IMAGE_LABEL;
|
|
|
|
ml->labela = (const char*)image;
|
|
|
|
|
|
|
|
// Right side of label is label text
|
|
|
|
ml->typeb = FL_NORMAL_LABEL;
|
|
|
|
ml->labelb = item->label();
|
|
|
|
|
|
|
|
// Assign the multilabel to the menu item
|
|
|
|
ml->label(item);
|
|
|
|
\endcode
|
|
|
|
|
|
|
|
\see Fl_Label and Fl_Labeltype and examples/howto-menu-with-images.cxx
|
2015-02-04 16:12:43 +03:00
|
|
|
*/
|
2002-08-14 20:49:38 +04:00
|
|
|
struct FL_EXPORT Fl_Multi_Label {
|
2015-02-04 16:12:43 +03:00
|
|
|
/** Holds the "leftmost" of the two elements in the composite label.
|
|
|
|
Typically this would be assigned either a text string (const char*),
|
|
|
|
a (Fl_Image*) or a (Fl_Multi_Label*). */
|
1998-10-06 22:21:25 +04:00
|
|
|
const char* labela;
|
2015-02-04 16:12:43 +03:00
|
|
|
/** Holds the "rightmost" of the two elements in the composite label.
|
|
|
|
Typically this would be assigned either a text string (const char*),
|
|
|
|
a (Fl_Image*) or a (Fl_Multi_Label*). */
|
1998-10-06 22:21:25 +04:00
|
|
|
const char* labelb;
|
2015-02-04 16:12:43 +03:00
|
|
|
/** Holds the "type" of labela.
|
|
|
|
Typically this is set to FL_NORMAL_LABEL for a text label,
|
2017-09-12 16:05:48 +03:00
|
|
|
FL_IMAGE_LABEL for an image (based on Fl_image) or FL_MULTI_LABEL
|
2015-02-04 16:12:43 +03:00
|
|
|
if "chaining" multiple Fl_Multi_Label elements together. */
|
1998-10-06 22:21:25 +04:00
|
|
|
uchar typea;
|
2015-02-04 16:12:43 +03:00
|
|
|
/** Holds the "type" of labelb.
|
|
|
|
Typically this is set to FL_NORMAL_LABEL for a text label,
|
2017-09-12 16:05:48 +03:00
|
|
|
FL_IMAGE_LABEL for an image (based on Fl_image) or FL_MULTI_LABEL
|
2015-02-04 16:12:43 +03:00
|
|
|
if "chaining" multiple Fl_Multi_Label elements together. */
|
1998-10-06 22:21:25 +04:00
|
|
|
uchar typeb;
|
2015-02-04 16:12:43 +03:00
|
|
|
|
|
|
|
/** This method is used to associate a Fl_Multi_Label with a Fl_Widget. */
|
2002-08-14 20:49:38 +04:00
|
|
|
void label(Fl_Widget*);
|
2015-02-04 16:12:43 +03:00
|
|
|
/** This method is used to associate a Fl_Multi_Label with a Fl_Menu_Item. */
|
2002-08-14 20:49:38 +04:00
|
|
|
void label(Fl_Menu_Item*);
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-10-20 01:39:29 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|