FLTK logo

[Library] r9017 - in branches/branch-3.0: . include/fltk3 src/fltk3 test

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[Library] r9017 - in branches/branch-3.0: . include/fltk3 src/fltk3 test fltk-dev Aug 27, 2011  
 
Author: matt
Date: 2011-08-27 15:50:53 -0700 (Sat, 27 Aug 2011)
New Revision: 9017
Log:
FLTK3: Widget is now derived from Label which is derived from Rectangle. This will allow very lightweight text displays. It's also usefule as an interim solution on the way to Styles.

Modified:
   branches/branch-3.0/fltk.flw
   branches/branch-3.0/include/fltk3/Widget.h
   branches/branch-3.0/include/fltk3/all.h
   branches/branch-3.0/include/fltk3/run.h
   branches/branch-3.0/src/fltk3/Choice.cxx
   branches/branch-3.0/src/fltk3/FileIcon.cxx
   branches/branch-3.0/src/fltk3/Image.cxx
   branches/branch-3.0/src/fltk3/Menu.cxx
   branches/branch-3.0/src/fltk3/MultiLabel.cxx
   branches/branch-3.0/src/fltk3/Widget.cxx
   branches/branch-3.0/src/fltk3/engraved_label.cxx
   branches/branch-3.0/src/fltk3/labeltype.cxx
   branches/branch-3.0/src/fltk3/run.cxx
   branches/branch-3.0/test/hello.cxx

Modified: branches/branch-3.0/fltk.flw
===================================================================
--- branches/branch-3.0/fltk.flw	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/fltk.flw	2011-08-27 22:50:53 UTC (rev 9017)
@@ -600,14 +600,6 @@
           list_env 124
           filename_and_path {include/fltk3/FloatInput.h}
         }
-        file_ref {forms.h} {
-          uuid_Xcode4_BuildFile {13BD0083-5C3A-4485-B0C4-76521CB9DCF9}
-          uuid_Xcode4_FileRef {BA378976-019A-40AC-9C07-D6A57A07A00A}
-          uuid_Xcode4_BuildFileInHeaders {0AEE62FF-5E0B-4D27-9E43-D21940004C32}
-          build_env 96
-          list_env 124
-          filename_and_path {include/fltk3/forms.h}
-        }
         file_ref {FormsBitmap.h} {
           uuid_Xcode4_BuildFile {16C8EAEF-18D0-4B67-B81A-EF35EB92559A}
           uuid_Xcode4_FileRef {11DF5111-EDFE-4B10-B251-852CAAFDB68B}

Modified: branches/branch-3.0/include/fltk3/Widget.h
===================================================================
--- branches/branch-3.0/include/fltk3/Widget.h	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/include/fltk3/Widget.h	2011-08-27 22:50:53 UTC (rev 9017)
@@ -73,33 +73,243 @@
    a similar fashion to widgets containing text. We also provide an easy
    interface for very complex labels, containing html or vector graphics.
    */
-  struct FLTK3_EXPORT Label {
+  class FLTK3_EXPORT Label : public Rectangle {
+  protected:
     /** label text */
-    const char* value;
-    /** optional image for an active label */
-    fltk3::Image* image;
-    /** optional image for a deactivated label */
-    fltk3::Image* deimage;
+    const char* labeltext_;
+    /** type of label. \see fltk3::Labeltype */
+    uchar labeltype_;
+    /** text color */
+    fltk3::Color labelcolor_;
     /** label font used in text */
-    fltk3::Font font;
+    fltk3::Font labelfont_;
     /** size of label font */
-    fltk3::Fontsize size;
-    /** text color */
-    fltk3::Color color;
+    fltk3::Fontsize labelsize_;
+    /** alignment of label */
+    fltk3::Align align_;
+    /** various flags for the label and derived classes */
+    unsigned int flags_;
     /** \internal The font used for the entire text. */
     fltk3::Font textfont_;
     /** \internal Height of the font used for the entire text. */
     fltk3::Fontsize textsize_;
     /** \internal color of the entire text */
     fltk3::Color textcolor_;
-    /** alignment of label */
-    fltk3::Align align_;
-    /** type of label. \see fltk3::Labeltype */
-    uchar type;
+    /** optional image for an active label */
+    fltk3::Image* image_;
+    /** optional image for a deactivated label */
+    fltk3::Image* deimage_;
     
+  public:
+    
+    Label(int x, int y, int w, int h, const char *l=0L);
+    
+    Label(const Label &s);
+    
+    Label();
+    
     /** Draws the label aligned to the given box */
     void draw(int,int,int,int, fltk3::Align) const ;
+    
     void measure(int &w, int &h) const ;
+    
+    /** Gets the current label text.
+     \return a pointer to the current label text
+     \see label(const char *), copy_label(const char *)
+     */
+    const char* label() const {return labeltext_;}
+    
+    /** Sets the current label pointer.
+     
+     The label is shown somewhere on or next to the widget. The passed pointer 
+     is stored unchanged in the widget (the string is \em not copied), so if 
+     you need to set the label to a formatted value, make sure the buffer is 
+     static, global, or allocated. The copy_label() method can be used 
+     to make a copy of the label string automatically.
+     \param[in] text pointer to new label text
+     \see copy_label()
+     */
+    void label(const char* text);
+    
+    /** Sets the current label. 
+     Unlike label(), this method allocates a copy of the label 
+     string instead of using the original string pointer.
+     
+     The internal copy will automatically be freed whenever you assign
+     a new label or when the widget is destroyed.
+     
+     \param[in] new_label the new label text
+     \see label()
+     */
+    void copy_label(const char *new_label);
+    
+    /** Shortcut to set the label text and type in one call.
+     \see label(const char *), labeltype(fltk3::Labeltype)
+     */
+    void label(fltk3::Labeltype a, const char* b) { Label::labeltype_ = a; labeltext_ = b; }
+    
+    /** Gets the label color. 
+     The default color is fltk3::FOREGROUND_COLOR. 
+     \return the current label color
+     */
+    fltk3::Color labelcolor() const {return labelcolor_;}
+    
+    /** Sets the label color. 
+     The default color is fltk3::FOREGROUND_COLOR. 
+     \param[in] c the new label color
+     */
+    void labelcolor(fltk3::Color c) {labelcolor_=c;}
+    
+    /** Gets the font to use. 
+     Fonts are identified by indexes into a table. The default value
+     uses a Helvetica typeface (Arial for Microsoft® Windows®).
+     The function fltk3::set_font() can define new typefaces.
+     \return current font used by the label
+     \see fltk3::Font
+     */
+    fltk3::Font labelfont() const {return labelfont_;}
+    
+    /** Sets the font to use. 
+     Fonts are identified by indexes into a table. The default value
+     uses a Helvetica typeface (Arial for Microsoft® Windows®).
+     The function fltk3::set_font() can define new typefaces.
+     \param[in] f the new font for the label
+     \see fltk3::Font
+     */
+    void labelfont(fltk3::Font f) {labelfont_=f;}
+    
+    /** Gets the font size in pixels. 
+     The default size is 14 pixels.
+     \return the current font size
+     */
+    fltk3::Fontsize labelsize() const {return labelsize_;}
+    
+    /** Sets the font size in pixels.
+     \param[in] pix the new font size
+     \see fltk3::Fontsize labelsize()
+     */
+    void labelsize(fltk3::Fontsize pix) {labelsize_=pix;}
+    
+    /** Gets the label type.
+     \return the current label type.
+     \see fltk3::Labeltype
+     */
+    fltk3::Labeltype labeltype() const {return (fltk3::Labeltype)labeltype_;}
+    
+    /** Sets the label type. 
+     The label type identifies the function that draws the label of the widget. 
+     This is generally used for special effects such as embossing or for using 
+     the label() pointer as another form of data such as an icon. The value 
+     fltk3::NORMAL_LABEL prints the label as plain text.
+     \param[in] a new label type
+     \see fltk3::Labeltype
+     */
+    void labeltype(int a) {labeltype_ = (fltk3::Labeltype)a;}
+    
+    /** Gets the label alignment.     
+     \return label alignment
+     \see label(), align(fltk3::Align), fltk3::Align
+     */
+    Align align() const {return align_;}
+    
+    /** Sets the label alignment.
+     This controls how the label is displayed next to or inside the widget. 
+     The default value is fltk3::ALIGN_CENTER, which centers the label inside 
+     the widget.
+     \param[in] alignment new label alignment
+     \see align(), fltk3::Align
+     */
+    void align(Align alignment) {align_ = alignment;}
+    
+    /** Gets the widget flags mask */
+    unsigned int flags() const {return flags_;}
+    
+    /** Sets a flag in the flags mask */
+    void set_flag(unsigned int c) {flags_ |= c;}
+    
+    /** Clears a flag in the flags mask */
+    void clear_flag(unsigned int c) {flags_ &= ~c;}
+    
+    /** flags possible values enumeration. */
+    enum {
+      INACTIVE        = 1<<0,   ///< the widget can't receive focus, and is disabled but potentially visible
+      SHORTCUT_LABEL  = 1<<6,   ///< the label contains a shortcut we need to draw
+      COPIED_LABEL    = 1<<10,  ///< the widget label is internally copied, its destruction is handled by the widget
+    };
+    
+    /** Schedules the drawing of the label.
+     Marks the widget or the parent as needing a redraw for the label area 
+     of a widget.
+     */
+    virtual void redraw_label() { }
+
+    /** Gets the font of the text in the input field.
+     \return the current fltk3::Font index */
+    fltk3::Font textfont() const {return textfont_;}
+    
+    /** Sets the font of the text in the input field.
+     The text font defaults to \c fltk3::HELVETICA.
+     \param [in] s the new text font */
+    void textfont(fltk3::Font s) {textfont_ = s;}
+    
+    /** Gets the size of the text in the input field.
+     \return the text height in pixels */
+    fltk3::Fontsize textsize() const {return textsize_;}
+    
+    /** Sets the size of the text in the input field.
+     The text height defaults to \c fltk3::NORMAL_SIZE.
+     \param [in] s the new font height in pixel units */
+    void textsize(fltk3::Fontsize s) {textsize_ = s;}
+    
+    /** Gets the color of the text in the input field.
+     \return the text color
+     \see textcolor(fltk3::Color) */
+    fltk3::Color textcolor() const {return textcolor_;}
+    
+    /** Sets the color of the text in the input field.
+     The text color defaults to \c fltk3::FOREGROUND_COLOR.
+     \param [in] n new text color
+     \see textcolor() */
+    void textcolor(fltk3::Color n) {textcolor_ = n;}
+
+    /** Gets the image that is used as part of the widget label.
+     This image is used when drawing the widget in the active state.
+     \return the current image
+     */
+    fltk3::Image* image() {return image_;}
+    const fltk3::Image* image() const {return image_;}
+    
+    /** Sets the image to use as part of the widget label.
+     This image is used when drawing the widget in the active state.
+     \param[in] img the new image for the label 
+     */
+    void image(fltk3::Image* img) {image_ = img;}
+    
+    /** Sets the image to use as part of the widget label.
+     This image is used when drawing the widget in the active state.
+     \param[in] img the new image for the label 
+     */
+    void image(fltk3::Image& img) {image_=&img;}
+    
+    /** Gets the image that is used as part of the widget label.  
+     This image is used when drawing the widget in the inactive state.
+     \return the current image for the deactivated widget
+     */
+    fltk3::Image* deimage() {return deimage_;}
+    const fltk3::Image* deimage() const {return deimage_;}
+    
+    /** Sets the image to use as part of the widget label.  
+     This image is used when drawing the widget in the inactive state.
+     \param[in] img the new image for the deactivated widget
+     */
+    void deimage(fltk3::Image* img) {deimage_=img;}
+    
+    /** Sets the image to use as part of the widget label.  
+     This image is used when drawing the widget in the inactive state.
+     \param[in] img the new image for the deactivated widget
+     */
+    void deimage(fltk3::Image& img) {deimage_=&img;}
+    
   };
   
   
@@ -115,14 +325,12 @@
    functions, even if they change the widget's appearance. It is up to the 
    user code to call redraw() after these.
    */
-  class FLTK3_EXPORT Widget : public Rectangle {
+  class FLTK3_EXPORT Widget : public Label {
     friend class Group;
     
     fltk3::Group* parent_;
     fltk3::Callback* callback_;
     void* user_data_;
-    Label label_;
-    unsigned int flags_;
     Color color_;
     Color color2_;
     uchar type_;
@@ -139,27 +347,18 @@
     
   protected:
     
-    /** Gets the widget flags mask */
-    unsigned int flags() const {return flags_;}
-    /** Sets a flag in the flags mask */
-    void set_flag(unsigned int c) {flags_ |= c;}
-    /** Clears a flag in the flags mask */
-    void clear_flag(unsigned int c) {flags_ &= ~c;}
     /** flags possible values enumeration.
      See activate(), output(), visible(), changed(), set_visible_focus()
      */
     enum {
-      INACTIVE        = 1<<0,   ///< the widget can't receive focus, and is disabled but potentially visible
       INVISIBLE       = 1<<1,   ///< the widget is not drawn, but can receive a few special events
       OUTPUT          = 1<<2,   ///< for output only
       NOBORDER        = 1<<3,   ///< don't draw a decoration (fltk3::Window)
       FORCE_POSITION  = 1<<4,   ///< don't let the window manager position the window (fltk3::Window)
       NON_MODAL       = 1<<5,   ///< this is a hovering toolbar window (fltk3::Window)
-      SHORTCUT_LABEL  = 1<<6,   ///< the label contains a shortcut we need to draw
       CHANGED         = 1<<7,   ///< the widget value changed
       OVERRIDE        = 1<<8,   ///< position window on top (fltk3::Window)
       VISIBLE_FOCUS   = 1<<9,   ///< accepts keyboard focus navigation if the widget can have the focus
-      COPIED_LABEL    = 1<<10,  ///< the widget label is internally copied, its destruction is handled by the widget
       CLIP_CHILDREN   = 1<<11,  ///< all drawing within this widget will be clipped (fltk3::Group)
       MENU_WINDOW     = 1<<12,  ///< a temporary popup window, dismissed by clicking outside (fltk3::Window)
       TOOLTIP_WINDOW  = 1<<13,  ///< a temporary popup, transparent to events, and dismissed easily (fltk3::Window)
@@ -316,22 +515,6 @@
      */
     void size(int W,int H) {resize(x_,y_,W,H);}
     
-    /** Gets the label alignment.
-     
-     \return label alignment
-     \see label(), align(fltk3::Align), fltk3::Align
-     */
-    Align align() const {return label_.align_;}
-    
-    /** Sets the label alignment.
-     This controls how the label is displayed next to or inside the widget. 
-     The default value is fltk3::ALIGN_CENTER, which centers the label inside 
-     the widget.
-     \param[in] alignment new label alignment
-     \see align(), fltk3::Align
-     */
-    void align(Align alignment) {label_.align_ = alignment;}
-    
     /** Gets the box type of the widget.
      \return the current box type
      \see box(fltk3::Boxtype), fltk3::Boxtype
@@ -390,137 +573,6 @@
      */
     void color(fltk3::Color bg, fltk3::Color sel) {color_=bg; color2_=sel;}
     
-    /** Gets the current label text.
-     \return a pointer to the current label text
-     \see label(const char *), copy_label(const char *)
-     */
-    const char* label() const {return label_.value;}
-    
-    /** Sets the current label pointer.
-     
-     The label is shown somewhere on or next to the widget. The passed pointer 
-     is stored unchanged in the widget (the string is \em not copied), so if 
-     you need to set the label to a formatted value, make sure the buffer is 
-     static, global, or allocated. The copy_label() method can be used 
-     to make a copy of the label string automatically.
-     \param[in] text pointer to new label text
-     \see copy_label()
-     */
-    void label(const char* text);
-    
-    /** Sets the current label. 
-     Unlike label(), this method allocates a copy of the label 
-     string instead of using the original string pointer.
-     
-     The internal copy will automatically be freed whenever you assign
-     a new label or when the widget is destroyed.
-     
-     \param[in] new_label the new label text
-     \see label()
-     */
-    void copy_label(const char *new_label);
-    
-    /** Shortcut to set the label text and type in one call.
-     \see label(const char *), labeltype(fltk3::Labeltype)
-     */
-    void label(fltk3::Labeltype a, const char* b) {label_.type = a; label_.value = b;}
-    
-    /** Gets the label type.
-     \return the current label type.
-     \see fltk3::Labeltype
-     */
-    fltk3::Labeltype labeltype() const {return (fltk3::Labeltype)label_.type;}
-    
-    /** Sets the label type. 
-     The label type identifies the function that draws the label of the widget. 
-     This is generally used for special effects such as embossing or for using 
-     the label() pointer as another form of data such as an icon. The value 
-     fltk3::NORMAL_LABEL prints the label as plain text.
-     \param[in] a new label type
-     \see fltk3::Labeltype
-     */
-    void labeltype(fltk3::Labeltype a) {label_.type = a;}
-    
-    /** Gets the label color. 
-     The default color is fltk3::FOREGROUND_COLOR. 
-     \return the current label color
-     */
-    fltk3::Color labelcolor() const {return label_.color;}
-    
-    /** Sets the label color. 
-     The default color is fltk3::FOREGROUND_COLOR. 
-     \param[in] c the new label color
-     */
-    void labelcolor(fltk3::Color c) {label_.color=c;}
-    
-    /** Gets the font to use. 
-     Fonts are identified by indexes into a table. The default value
-     uses a Helvetica typeface (Arial for Microsoft&reg; Windows&reg;).
-     The function fltk3::set_font() can define new typefaces.
-     \return current font used by the label
-     \see fltk3::Font
-     */
-    fltk3::Font labelfont() const {return label_.font;}
-    
-    /** Sets the font to use. 
-     Fonts are identified by indexes into a table. The default value
-     uses a Helvetica typeface (Arial for Microsoft&reg; Windows&reg;).
-     The function fltk3::set_font() can define new typefaces.
-     \param[in] f the new font for the label
-     \see fltk3::Font
-     */
-    void labelfont(fltk3::Font f) {label_.font=f;}
-    
-    /** Gets the font size in pixels. 
-     The default size is 14 pixels.
-     \return the current font size
-     */
-    fltk3::Fontsize labelsize() const {return label_.size;}
-    
-    /** Sets the font size in pixels.
-     \param[in] pix the new font size
-     \see fltk3::Fontsize labelsize()
-     */
-    void labelsize(fltk3::Fontsize pix) {label_.size=pix;}
-    
-    /** Gets the image that is used as part of the widget label.
-     This image is used when drawing the widget in the active state.
-     \return the current image
-     */
-    fltk3::Image* image() {return label_.image;}
-    const fltk3::Image* image() const {return label_.image;}
-    
-    /** Sets the image to use as part of the widget label.
-     This image is used when drawing the widget in the active state.
-     \param[in] img the new image for the label 
-     */
-    void image(fltk3::Image* img) {label_.image=img;}
-    
-    /** Sets the image to use as part of the widget label.
-     This image is used when drawing the widget in the active state.
-     \param[in] img the new image for the label 
-     */
-    void image(fltk3::Image& img) {label_.image=&img;}
-    
-    /** Gets the image that is used as part of the widget label.  
-     This image is used when drawing the widget in the inactive state.
-     \return the current image for the deactivated widget
-     */
-    fltk3::Image* deimage() {return label_.deimage;}
-    const fltk3::Image* deimage() const {return label_.deimage;}
-    
-    /** Sets the image to use as part of the widget label.  
-     This image is used when drawing the widget in the inactive state.
-     \param[in] img the new image for the deactivated widget
-     */
-    void deimage(fltk3::Image* img) {label_.deimage=img;}
-    
-    /** Sets the image to use as part of the widget label.  
-     This image is used when drawing the widget in the inactive state.
-     \param[in] img the new image for the deactivated widget
-     */
-    void deimage(fltk3::Image& img) {label_.deimage=&img;}
-    
     /** Gets the current tooltip text.
      \return a pointer to the tooltip text or NULL
      \see tooltip(const char*), copy_tooltip(const char*)
@@ -857,7 +909,7 @@
      Marks the widget or the parent as needing a redraw for the label area 
      of a widget.
      */
-    void redraw_label();
+    virtual void redraw_label();
     
     /** Returns non-zero if draw() needs to be called. 
      The damage value is actually a bit field that the widget 
@@ -901,7 +953,7 @@
     /** Sets width ww and height hh accordingly with the label size.
      Labels with images will return w() and h() of the image.
      */
-    void measure_label(int& ww, int& hh) const {label_.measure(ww, hh);}
+    void measure_label(int& ww, int& hh) const {Label::measure(ww, hh);}
     
     /** Returns a pointer to the primary fltk3::Window widget.
      \retval  NULL if no window is associated with this widget.  
@@ -969,37 +1021,7 @@
     /** For back compatibility only.
      \deprecated Use selection_color(unsigned) instead.
      */
-    void color2(unsigned a) {color2_ = a;}
-
-    /** Gets the font of the text in the input field.
-     \return the current fltk3::Font index */
-    fltk3::Font textfont() const {return label_.textfont_;}
-    
-    /** Sets the font of the text in the input field.
-     The text font defaults to \c fltk3::HELVETICA.
-     \param [in] s the new text font */
-    void textfont(fltk3::Font s) {label_.textfont_ = s;}
-    
-    /** Gets the size of the text in the input field.
-     \return the text height in pixels */
-    fltk3::Fontsize textsize() const {return label_.textsize_;}
-    
-    /** Sets the size of the text in the input field.
-     The text height defaults to \c fltk3::NORMAL_SIZE.
-     \param [in] s the new font height in pixel units */
-    void textsize(fltk3::Fontsize s) {label_.textsize_ = s;}
-    
-    /** Gets the color of the text in the input field.
-     \return the text color
-     \see textcolor(fltk3::Color) */
-    fltk3::Color textcolor() const {return label_.textcolor_;}
-    
-    /** Sets the color of the text in the input field.
-     The text color defaults to \c fltk3::FOREGROUND_COLOR.
-     \param [in] n new text color
-     \see textcolor() */
-    void textcolor(fltk3::Color n) {label_.textcolor_ = n;}
-    
+    void color2(unsigned a) {color2_ = a;}    
 };
   
   

Modified: branches/branch-3.0/include/fltk3/all.h
===================================================================
--- branches/branch-3.0/include/fltk3/all.h	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/include/fltk3/all.h	2011-08-27 22:50:53 UTC (rev 9017)
@@ -28,6 +28,7 @@
 #ifndef FLTK3_ALL_H
 #define FLTK3_ALL_H
 
+#include "x.h"
 #include "Adjuster.h"
 #include "BMPImage.h"
 #include "Bitmap.h"
@@ -55,9 +56,6 @@
 #include "FillDial.h"
 #include "FillSlider.h"
 #include "FloatInput.h"
-#include "FormsBitmap.h"
-#include "FormsPixmap.h"
-#include "Free.h"
 #include "GIFImage.h"
 #include "Group.h"
 #include "HelpDialog.h"
@@ -75,8 +73,6 @@
 #include "JPEGImage.h"
 #include "LightButton.h"
 #include "LineDial.h"
-#include "Makefile"
-#include "Makefile.in"
 #include "Menu.h"
 #include "MenuBar.h"
 #include "MenuButton.h"
@@ -92,8 +88,6 @@
 #include "Object.h"
 #include "Output.h"
 #include "OverlayWindow.h"
-#include "PNGImage.h"
-#include "PNMImage.h"
 #include "PackedGroup.h"
 #include "PagedDevice.h"
 #include "Pixmap.h"
@@ -103,7 +97,6 @@
 #include "Preferences.h"
 #include "Printer.h"
 #include "Progress.h"
-#include "README.Xcode"
 #include "RGBImage.h"
 #include "RadioButton.h"
 #include "RadioLightButton.h"
@@ -152,7 +145,6 @@
 #include "Wrapper.h"
 #include "XBMImage.h"
 #include "XPMImage.h"
-#include "Xutf8.h"
 #include "ask.h"
 #include "dirent.h"
 #include "draw.h"
@@ -161,14 +153,11 @@
 #include "math.h"
 #include "message.h"
 #include "names.h"
-#include "osx.h"
 #include "run.h"
 #include "showInput.h"
 #include "show_colormap.h"
 #include "types.h"
 #include "utf8.h"
-#include "win32.h"
-#include "x.h"
 
 #endif // !FLTK3_ALL_H
 

Modified: branches/branch-3.0/include/fltk3/run.h
===================================================================
--- branches/branch-3.0/include/fltk3/run.h	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/include/fltk3/run.h	2011-08-27 22:50:53 UTC (rev 9017)
@@ -47,7 +47,7 @@
 namespace fltk3 { 
   class Widget;
   class Window;
-  struct Label;
+  class Label;
   class Image;
   
   /** \defgroup  callback_functions Callback function typedefs

Modified: branches/branch-3.0/src/fltk3/Choice.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/Choice.cxx	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/src/fltk3/Choice.cxx	2011-08-27 22:50:53 UTC (rev 9017)
@@ -93,14 +93,14 @@
 
     if ( fltk3::scheme()) {
       fltk3::Label l;
-      l.value = m.text;
-      l.image = 0;
-      l.deimage = 0;
-      l.type = m.labeltype_;
-      l.font = m.labelsize_ || m.labelfont_ ? m.labelfont_ : textfont();
-      l.size = m.labelsize_ ? m.labelsize_ : textsize();
-      l.color= m.labelcolor_ ? m.labelcolor_ : textcolor();
-      if (!m.active()) l.color = fltk3::inactive((fltk3::Color)l.color);
+      l.label(m.text);
+      l.image(0);
+      l.deimage(0);
+      l.labeltype( m.labeltype_ );
+      l.labelfont( m.labelsize_ || m.labelfont_ ? m.labelfont_ : textfont() );
+      l.labelsize( m.labelsize_ ? m.labelsize_ : textsize() );
+      l.labelcolor( m.labelcolor_ ? m.labelcolor_ : textcolor() );
+      if (!m.active()) l.labelcolor( fltk3::inactive((fltk3::Color)l.labelcolor()) );
       fltk3::draw_shortcut = 2; // hack value to make '&' disappear
       l.draw(xx+3, yy, ww>6 ? ww-6 : 0, hh, fltk3::ALIGN_LEFT);
       fltk3::draw_shortcut = 0;

Modified: branches/branch-3.0/src/fltk3/FileIcon.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/FileIcon.cxx	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/src/fltk3/FileIcon.cxx	2011-08-27 22:50:53 UTC (rev 9017)
@@ -480,8 +480,8 @@
 
   (void)a;
 
-  icon = (fltk3::FileIcon *)(o->value);
-  if (icon) icon->draw(x, y, w, h, (fltk3::Color)(o->color));
+  icon = (fltk3::FileIcon *)(o->label());
+  if (icon) icon->draw(x, y, w, h, (fltk3::Color)(o->labelcolor()));
 }
 
 

Modified: branches/branch-3.0/src/fltk3/Image.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/Image.cxx	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/src/fltk3/Image.cxx	2011-08-27 22:50:53 UTC (rev 9017)
@@ -143,7 +143,7 @@
   fltk3::Image	*img;				// Image pointer
   int		cx, cy;				// Image position
 
-  img = (fltk3::Image *)(lo->value);
+  img = (fltk3::Image *)(lo->label());
 
   if (la & fltk3::ALIGN_LEFT) cx = 0;
   else if (la & fltk3::ALIGN_RIGHT) cx = img->w() - lw;
@@ -153,7 +153,7 @@
   else if (la & fltk3::ALIGN_BOTTOM) cy = img->h() - lh;
   else cy = (img->h() - lh) / 2;
 
-  fltk3::color((fltk3::Color)lo->color);
+  fltk3::color((fltk3::Color)lo->labelcolor());
 
   img->draw(lx, ly, lw, lh, cx, cy);
 }
@@ -164,7 +164,7 @@
 		  int            &lh) {		// O - Height of image
   fltk3::Image *img;				// Image pointer
 
-  img = (fltk3::Image *)(lo->value);
+  img = (fltk3::Image *)(lo->label());
 
   lw = img->w();
   lh = img->h();

Modified: branches/branch-3.0/src/fltk3/Menu.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/Menu.cxx	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/src/fltk3/Menu.cxx	2011-08-27 22:50:53 UTC (rev 9017)
@@ -137,13 +137,13 @@
 */
 int fltk3::MenuItem::measure(int* hp, const fltk3::Menu_* m) const {
   fltk3::Label l;
-  l.value   = text;
-  l.image   = 0;
-  l.deimage = 0;
-  l.type    = labeltype_;
-  l.font    = labelsize_ || labelfont_ ? labelfont_ : (m ? m->textfont() : fltk3::HELVETICA);
-  l.size    = labelsize_ ? labelsize_ : m ? m->textsize() : fltk3::NORMAL_SIZE;
-  l.color   = fltk3::FOREGROUND_COLOR; // this makes no difference?
+  l.label(text);
+  l.image(0);
+  l.deimage(0);
+  l.labeltype( labeltype_ );
+  l.labelfont( labelsize_ || labelfont_ ? labelfont_ : (m ? m->textfont() : fltk3::HELVETICA) );
+  l.labelsize( labelsize_ ? labelsize_ : m ? m->textsize() : fltk3::NORMAL_SIZE );
+  l.labelcolor( fltk3::FOREGROUND_COLOR ); // this makes no difference?
   fltk3::draw_shortcut = 1;
   int w = 0; int h = 0;
   l.measure(w, hp ? *hp : h);
@@ -156,14 +156,14 @@
 void fltk3::MenuItem::draw(int x, int y, int w, int h, const fltk3::Menu_* m,
 			int selected) const {
   fltk3::Label l;
-  l.value   = text;
-  l.image   = 0;
-  l.deimage = 0;
-  l.type    = labeltype_;
-  l.font    = labelsize_ || labelfont_ ? labelfont_ : (m ? m->textfont() : fltk3::HELVETICA);
-  l.size    = labelsize_ ? labelsize_ : m ? m->textsize() : fltk3::NORMAL_SIZE;
-  l.color   = labelcolor_ ? labelcolor_ : m ? m->textcolor() : int(fltk3::FOREGROUND_COLOR);
-  if (!active()) l.color = fltk3::inactive((fltk3::Color)l.color);
+  l.label(text);
+  l.image(0);
+  l.deimage(0);
+  l.labeltype( labeltype_ );
+  l.labelfont( labelsize_ || labelfont_ ? labelfont_ : (m ? m->textfont() : fltk3::HELVETICA) );
+  l.labelsize( labelsize_ ? labelsize_ : m ? m->textsize() : fltk3::NORMAL_SIZE );
+  l.labelcolor( labelcolor_ ? labelcolor_ : m ? m->textcolor() : int(fltk3::FOREGROUND_COLOR) );
+  if (!active()) l.labelcolor( fltk3::inactive((fltk3::Color)l.labelcolor()) );
   fltk3::Color color = m ? m->color() : fltk3::GRAY;
   if (selected) {
     fltk3::Color r = m ? m->selection_color() : fltk3::SELECTION_COLOR;
@@ -174,10 +174,10 @@
 	b = m ? m->box() : fltk3::UP_BOX;
       } else {
 	r = (fltk3::Color)(fltk3::COLOR_CUBE-1); // white
-	l.color = fltk3::contrast((fltk3::Color)labelcolor_, r);
+	l.labelcolor( fltk3::contrast((fltk3::Color)labelcolor_, r) );
       }
     } else {
-      l.color = fltk3::contrast((fltk3::Color)labelcolor_, r);
+      l.labelcolor( fltk3::contrast((fltk3::Color)labelcolor_, r) );
     }
     if (selected == 2) { // menu title
       fltk3::draw_box(b, x, y, w, h, r);

Modified: branches/branch-3.0/src/fltk3/MultiLabel.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/MultiLabel.cxx	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/src/fltk3/MultiLabel.cxx	2011-08-27 22:50:53 UTC (rev 9017)
@@ -35,10 +35,10 @@
 
 void fl_multi_labeltype(const fltk3::Label* o, int x, int y, int w, int h, fltk3::Align a)
 {
-  fltk3::MultiLabel* b = (fltk3::MultiLabel*)(o->value);
+  fltk3::MultiLabel* b = (fltk3::MultiLabel*)(o->label());
   fltk3::Label local = *o;
-  local.value = b->labela;
-  local.type = b->typea;
+  local.label(b->labela);
+  local.labeltype(b->typea);
   int W = w; int H = h; local.measure(W, H);
   local.draw(x,y,w,h,a);
   if (a & fltk3::ALIGN_BOTTOM) h -= H;
@@ -46,20 +46,20 @@
   else if (a & fltk3::ALIGN_RIGHT) w -= W;
   else if (a & fltk3::ALIGN_LEFT) {x += W; w -= W;}
   else {int d = (h+H)/2; y += d; h -= d;}
-  local.value = b->labelb;
-  local.type = b->typeb;
+  local.label(b->labelb);
+  local.labeltype(b->typeb);
   local.draw(x,y,w,h,a);
 }
 
 // measurement is only correct for left-to-right appending...
 void fl_multi_measure(const fltk3::Label* o, int& w, int& h) {
-  fltk3::MultiLabel* b = (fltk3::MultiLabel*)(o->value);
+  fltk3::MultiLabel* b = (fltk3::MultiLabel*)(o->label());
   fltk3::Label local = *o;
-  local.value = b->labela;
-  local.type = b->typea;
+  local.label(b->labela);
+  local.labeltype(b->typea);
   local.measure(w,h);
-  local.value = b->labelb;
-  local.type = b->typeb;
+  local.label(b->labelb);
+  local.labeltype(b->typeb);
   int W = 0; int H = 0; local.measure(W,H);
   w += W; if (H>h) h = H;
 }

Modified: branches/branch-3.0/src/fltk3/Widget.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/Widget.cxx	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/src/fltk3/Widget.cxx	2011-08-27 22:50:53 UTC (rev 9017)
@@ -104,6 +104,58 @@
 }
 ////////////////////////////////////////////////////////////////
 
+fltk3::Label::Label(int X, int Y, int W, int H, const char* L) 
+: fltk3::Rectangle(X, Y, W, H),
+  labeltext_(L),
+  labeltype_(fltk3::NORMAL_LABEL),
+  labelcolor_(fltk3::FOREGROUND_COLOR),
+  labelfont_(fltk3::HELVETICA),
+  labelsize_(fltk3::NORMAL_SIZE),
+  align_(fltk3::ALIGN_CENTER),
+  flags_(0),
+  textfont_(0),
+  textsize_(0),
+  textcolor_(0),
+  image_(0),
+  deimage_(0)
+{
+}
+
+fltk3::Label::Label(const fltk3::Label &s) 
+: fltk3::Rectangle(s),
+  labeltext_(s.labeltext_), // FIXME: we must copy the label text!
+  labeltype_(s.labeltype_),
+  labelcolor_(s.labelcolor_),
+  labelfont_(s.labelfont_),
+  labelsize_(s.labelsize_),
+  align_(s.align_),
+  flags_(s.flags_),
+  textfont_(s.textfont_),
+  textsize_(s.textsize_),
+  textcolor_(s.textcolor_),
+  image_(s.image_),
+  deimage_(s.deimage_)
+{
+}
+
+fltk3::Label::Label() 
+: fltk3::Rectangle(),
+  labeltype_(fltk3::NORMAL_LABEL),
+  labelcolor_(fltk3::FOREGROUND_COLOR),
+  labelfont_(fltk3::HELVETICA),
+  labelsize_(fltk3::NORMAL_SIZE),
+  align_(fltk3::ALIGN_CENTER),
+  flags_(0),
+  textfont_(fltk3::HELVETICA),
+  textsize_(fltk3::NORMAL_SIZE),
+  textcolor_(fltk3::FOREGROUND_COLOR),
+  image_(0),
+  deimage_(0)
+{
+}
+
+////////////////////////////////////////////////////////////////
+
 int fltk3::Widget::handle(int event) {
   return 0;
 }
@@ -111,18 +163,9 @@
 /** Default font size for widgets */
 fltk3::Fontsize fltk3::NORMAL_SIZE = 14;
 
-fltk3::Widget::Widget(int X, int Y, int W, int H, const char* L) {
-
-  x_ = X; y_ = Y; w_ = W; h_ = H;
-
-  label_.value	 = L;
-  label_.image   = 0;
-  label_.deimage = 0;
-  label_.type	 = fltk3::NORMAL_LABEL;
-  label_.font	 = fltk3::HELVETICA;
-  label_.size	 = fltk3::NORMAL_SIZE;
-  label_.color	 = fltk3::FOREGROUND_COLOR;
-  label_.align_	 = fltk3::ALIGN_CENTER;
+fltk3::Widget::Widget(int X, int Y, int W, int H, const char* L) 
+: fltk3::Label(X, Y, W, H, L)
+{
   tooltip_       = 0;
   callback_	 = default_callback;
   user_data_ 	 = 0;
@@ -168,7 +211,7 @@
 */
 fltk3::Widget::~Widget() {
   fltk3::clear_widget_pointer(this);
-  if (flags() & COPIED_LABEL) free((void *)(label_.value));
+  if (flags() & COPIED_LABEL) free((void *)(labeltext_));
   if (flags() & COPIED_TOOLTIP) free((void *)(tooltip_));
   // remove from parent group
   if (parent_) parent_->remove(this);
@@ -298,28 +341,28 @@
 
 
 void
-fltk3::Widget::label(const char *a) {
+fltk3::Label::label(const char *a) {
   if (flags() & COPIED_LABEL) {
     // reassigning a copied label remains the same copied label
-    if (label_.value == a)
+    if (labeltext_ == a)
       return;
-    free((void *)(label_.value));
+    free((void *)(labeltext_));
     clear_flag(COPIED_LABEL);
   }
-  label_.value=a;
+  labeltext_ = a;
   redraw_label();
 }
 
 
 void
-fltk3::Widget::copy_label(const char *a) {
-  if (flags() & COPIED_LABEL) free((void *)(label_.value));
+fltk3::Label::copy_label(const char *a) {
+  if (flags() & COPIED_LABEL) free((void *)(labeltext_));
   if (a) {
     set_flag(COPIED_LABEL);
-    label_.value=strdup(a);
+    labeltext_ = strdup(a);
   } else {
     clear_flag(COPIED_LABEL);
-    label_.value=(char *)0;
+    labeltext_ = (char *)0;
   }
   redraw_label();
 }

Modified: branches/branch-3.0/src/fltk3/engraved_label.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/engraved_label.cxx	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/src/fltk3/engraved_label.cxx	2011-08-27 22:50:53 UTC (rev 9017)
@@ -40,10 +40,10 @@
   fltk3::Align a1 = align;
   if (a1 & fltk3::ALIGN_CLIP) {
     fltk3::push_clip(X, Y, W, H); a1 = (fltk3::Align)(a1&~fltk3::ALIGN_CLIP);}
-  fltk3::font((fltk3::Font)o->font, o->size);
+  fltk3::font((fltk3::Font)o->labelfont(), o->labelsize());
   for (int i = 0; i < n; i++) {
-    fltk3::color((fltk3::Color)(i < n-1 ? data[i][2] : o->color));
-    fltk3::draw(o->value, X+data[i][0], Y+data[i][1], W, H, a1);
+    fltk3::color((fltk3::Color)(i < n-1 ? data[i][2] : o->labelcolor()));
+    fltk3::draw(o->label(), X+data[i][0], Y+data[i][1], W, H, a1);
   }
   if (align & fltk3::ALIGN_CLIP) fltk3::pop_clip();
 }

Modified: branches/branch-3.0/src/fltk3/labeltype.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/labeltype.cxx	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/src/fltk3/labeltype.cxx	2011-08-27 22:50:53 UTC (rev 9017)
@@ -41,18 +41,18 @@
 void
 fl_normal_label(const fltk3::Label* o, int X, int Y, int W, int H, fltk3::Align align)
 {
-  fltk3::font(o->font, o->size);
-  fltk3::color((fltk3::Color)o->color);
-  fltk3::draw(o->value, X, Y, W, H, align, o->image);
+  fltk3::font(o->labelfont(), o->labelsize());
+  fltk3::color((fltk3::Color)o->labelcolor());
+  fltk3::draw(o->label(), X, Y, W, H, align, (fltk3::Image*)o->image());
 }
 
 void
 fl_normal_measure(const fltk3::Label* o, int& W, int& H) {
-  fltk3::font(o->font, o->size);
-  fltk3::measure(o->value, W, H);
-  if (o->image) {
-    if (o->image->w() > W) W = o->image->w();
-    H += o->image->h();
+  fltk3::font(o->labelfont(), o->labelsize());
+  fltk3::measure(o->label(), W, H);
+  if (o->image()) {
+    if (o->image()->w() > W) W = o->image()->w();
+    H += o->image()->h();
   }
 }
 
@@ -101,8 +101,8 @@
 
 /** Draws a label with arbitrary alignment in an arbitrary box. */
 void fltk3::Label::draw(int X, int Y, int W, int H, fltk3::Align align) const {
-  if (!value && !image) return;
-  table[type](this, X, Y, W, H, align);
+  if (!labeltext_ && !image()) return;
+  table[labeltype()](this, X, Y, W, H, align);
 }
 
 /** 
@@ -111,12 +111,12 @@
          on return, this will contain the size needed to fit the label
 */
 void fltk3::Label::measure(int& W, int& H) const {
-  if (!value && !image) {
+  if (!labeltext_ && !image()) {
     W = H = 0;
     return;
   }
 
-  fltk3::LabelMeasureF* f = ::measure[type]; if (!f) f = fl_normal_measure;
+  fltk3::LabelMeasureF* f = ::measure[labeltype()]; if (!f) f = fl_normal_measure;
   f(this, W, H);
 }
 
@@ -144,10 +144,10 @@
  */
 void fltk3::Widget::draw_label(int X, int Y, int W, int H, fltk3::Align a) const {
   if (flags()&SHORTCUT_LABEL) fltk3::draw_shortcut = 1;
-  fltk3::Label l1 = label_;
+  fltk3::Label l1(*this);
   if (!active_r()) {
-    l1.color = fltk3::inactive((fltk3::Color)l1.color);
-    if (l1.deimage) l1.image = l1.deimage;
+    l1.labelcolor( fltk3::inactive((fltk3::Color)l1.labelcolor()) );
+    if (l1.deimage()) l1.image(l1.deimage());
   }
   l1.draw(X,Y,W,H,a);
   fltk3::draw_shortcut = 0;

Modified: branches/branch-3.0/src/fltk3/run.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/run.cxx	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/src/fltk3/run.cxx	2011-08-27 22:50:53 UTC (rev 9017)
@@ -1587,7 +1587,7 @@
       // If the label is not inside the widget, compute the location of
       // the label and redraw the window within that bounding box...
       int W = 0, H = 0;
-      label_.measure(W, H);
+      Label::measure(W, H);
       W += 5; // Add a little to the size of the label to cover overflow
       H += 5;
 

Modified: branches/branch-3.0/test/hello.cxx
===================================================================
--- branches/branch-3.0/test/hello.cxx	2011-08-26 17:54:01 UTC (rev 9016)
+++ branches/branch-3.0/test/hello.cxx	2011-08-27 22:50:53 UTC (rev 9017)
@@ -25,22 +25,19 @@
 //     http://www.fltk.org/str.php
 //
 
-#include <fltk3/run.h>
-#include <fltk3/Window.h>
-#include <fltk3/Box.h>
+#include <fltk3/fltk3.h>
 
-using namespace fltk3;
 
 int main(int argc, char **argv) {
   fltk3::Window *window = new fltk3::Window(340,180);
-  Box *box = new Box(20,40,300,100,"Hello, World!");
-  box->box(UP_BOX);
-  box->labelfont(BOLD+ITALIC);
+  fltk3::Box *box = new fltk3::Box(20,40,300,100,"Hello, World!");
+  box->box(fltk3::UP_BOX);
+  box->labelfont(fltk3::BOLD+fltk3::ITALIC);
   box->labelsize(36);
-  box->labeltype(SHADOW_LABEL);
+  box->labeltype(fltk3::SHADOW_LABEL);
   window->end();
   window->show(argc, argv);
-  return run();
+  return fltk3::run();
 }
 
 //

Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.