gml_GRItem_Text.h

00001 // gml_GRItem_Text.h --
00002 //
00003 //    Declares the "gml_TGRItem_Text" class. A gml_TGRItem_Text displays a text
00004 //      using one particular font.
00005 //
00006 //  Copyright (c) 2004 CLIPS-IMAG
00007 //
00008 //  See the file "gml_LicenseTerms.txt" for information on usage and redistribution
00009 //  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00010 //
00011 //  Created on February 8, 2004 FB.
00012 
00013 #ifndef __GML_GRITEM_TEXT__
00014 #define __GML_GRITEM_TEXT__
00015 
00016 #include "gml/ui/gml_GRItem.h"
00017 
00018 #include "gml/ui/gml_TextRender.h"
00019 #include "gml/image/gml_RGBColor.h"
00020 
00021 
00022 
00023 // Default configuration values.
00024 
00025 extern char*                gml_cGRItem_TextDefaultFont;            /*  = "Helvetica 12"; */
00026 const gml_TRGBColor         gml_cGRItem_TextDefaultColor                = { 0xffff, 0xffff, 0xffff };
00027 const gml_TGRItemParam      gml_cGRItem_TextDefaultAlpha                = 1.0;
00028 const gml_TGRItemAnchor     gml_cGRItem_TextDefaultAnchor               = gml_cGRItem_AnchorSW;
00029 const int                       gml_cGRItem_TextDefaultWidth            = 0;
00030 const gml_TTextRender_Justify   gml_cGRItem_TextDefaultJustify          = gml_cTextRender_JustifyCenter;
00031 
00032 
00033 struct Tcl_Interp;
00034 
00035 
00036 // gml_TGRItem_Text --
00037 
00038 class gml_TGRItem_Text : virtual public gml_TGRItem
00039 {
00040 public:
00041 
00042   // Init --
00043   //
00044   //  See "gml_TGRItem::Init".
00045   virtual
00046   gml_TError        Init (gml_TGRItem_Scene*  scene       = (gml_TGRItem_Scene*)NULL,
00047         gml_TGRItem*        parentItem  = (gml_TGRItem*)NULL,
00048         gml_TGRItemTransfo* transfo     = (gml_TGRItemTransfo*)NULL,
00049         gml_TPointer        clientData  = (gml_TPointer)NULL,
00050         Tcl_Interp*         tcl_interp  = (Tcl_Interp*)NULL);
00051   
00052   // Dispose --
00053   //
00054   //  See "gml_TGRItem::Dispose".
00055 
00056   void              Dispose ();
00057 
00058   // Configure --
00059   //
00060   //  Set Text aspect parameters. Any parameter which value is "NULL" is not modified.
00061   //    <text>          UTF encoded string to be displayed.
00062   //    <font>          string that names the font to be used (family and size, such as "Helvetica 12").
00063   //                      Refer to the Tk "font" command manual page for a description of accepted font names.
00064   //    <*color>        color of the text. The given color is copied so it can be freed
00065   //                      after calling configure.
00066   //    <*alpha>        transparency of the text.
00067   //    <*anchor>       position of the origin of the item coordinate system.
00068   //    <*width>        width (pixel) of the resulting bitmap. Set to 0 if the text is to be on a single line.
00069   //    <*justify>      how to align the lines of text (left, right, center).
00070 
00071   virtual
00072   gml_TError        Configure  (char*               text          = (char*)NULL,
00073         char*               font          = (char*)NULL,
00074         gml_TRGBColor*      color         = (gml_TRGBColor*)NULL,
00075         gml_TGRItemParam*   alpha         = (gml_TGRItemParam*)NULL,
00076         gml_TGRItemAnchor*        anchor  = (gml_TGRItemAnchor*)NULL,
00077         int*                      width   = (int*)NULL,
00078         gml_TTextRender_Justify*  justify = (gml_TTextRender_Justify*)NULL);
00079 
00080   // GetConfiguration --
00081   //
00082   //  Get Text aspect parameters. Any parameter which value is "NULL" is not returned.
00083   //  See <Configure>.
00084 
00085   virtual
00086   gml_TError        GetConfiguration (char**              text          = (char**)NULL,
00087               char**              font          = (char**)NULL,
00088               gml_TRGBColor*      color         = (gml_TRGBColor*)NULL,
00089               gml_TGRItemParam*   alpha         = (gml_TGRItemParam*)NULL,
00090               gml_TGRItemAnchor*        anchor  = (gml_TGRItemAnchor*)NULL,
00091               int*                      width   = (int*)NULL,
00092               gml_TTextRender_Justify*  justify = (gml_TTextRender_Justify*)NULL);
00093 
00094   // UpdateNonClippedBBox --
00095   //
00096   //  See "gml_TGRItem::UpdateNonClippedBBox".
00097 
00098   virtual void      UpdateNonClippedBBox ();
00099 
00100 
00101   // ComputeLocalBBox --
00102   //
00103   //  Sets (left, top, right, bottom) to the bouding box of the item expressed in
00104   //  local coordinates. This is affected by the width, height and anchor point of
00105   //  the item.
00106 
00107   void              ComputeLocalBBox (gml_TGRItemParam& left,
00108               gml_TGRItemParam& bottom,
00109               gml_TGRItemParam& right,
00110               gml_TGRItemParam& top);
00111 
00112 
00113 
00114   // PointToItem --
00115   //
00116   //  See "gml_TGRItem::PointToItem".
00117 
00118   gml_TGRItemParam  PointToItem (gml_TGRItemParam* pt);
00119 
00120 
00121 
00122   // RelationToRect --
00123   //
00124   //  See "gml_TGRItem::RelationToRect".
00125 
00126   int               RelationToRect (gml_TGRItemParam* rect);
00127 
00128 
00129 
00130 protected:
00131 
00132   static void         Initialize ();
00133   static gml_TBoolean fGRItem_text_initialized;
00134 
00135   int                 fWidth;
00136   int                 fHeight;
00137 
00138   char*               fText;
00139   char*               fFont;
00140   gml_TRGBColor       fColor;
00141   gml_TGRItemParam    fAlpha;
00142   gml_TGRItemAnchor   fAnchor;
00143   int                     fRequestedWidth;
00144   gml_TTextRender_Justify fJustify;
00145 
00146   gml_TTextRender     fTextRender;
00147 
00148   gml_TGRItemParam    fVertices[4*2];   // expressed in global coordinates, computed when the
00149           //  bouding box is computed.
00150 };
00151 
00152 
00153 
00154 #endif
Generated on Tue Jun 12 14:03:27 2007 for gml by Doxygen 1.5.2.