00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWMessage.h,v $ 00004 00005 Copyright (c) Kitware, Inc. 00006 All rights reserved. 00007 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00014 // .NAME vtkKWMessage - message widget 00015 // .SECTION Description 00016 // A simple widget that represents a message (a long unit of text). A message 00017 // is a widget that displays a textual string. A message widget (vtkKWMessage) 00018 // has several special features compared to a label (vtkKWLabel). 00019 // First, It breaks up its string into lines in order to produce a given 00020 // aspect ratio for the window. The line breaks are chosen at word boundaries 00021 // wherever possible (if not even a single word would fit on a line, then the 00022 // word will be split across lines). Newline characters in the string will 00023 // force line breaks; they can be used, for example, to leave blank lines in 00024 // the display. 00025 // The second feature of a message widget is justification. The text may be 00026 // displayed left-justified (each line starts at the left side of 00027 // the window), centered on a line-by-line basis, or right-justified (each 00028 // line ends at the right side of the window). 00029 // For short text, or to set an image as a label, see vtkKWLabel. 00030 // .SECTION See Also 00031 // vtkKWLabel 00032 00033 #ifndef __vtkKWMessage_h 00034 #define __vtkKWMessage_h 00035 00036 #include "vtkKWCoreWidget.h" 00037 00038 class KWWidgets_EXPORT vtkKWMessage : public vtkKWCoreWidget 00039 { 00040 public: 00041 static vtkKWMessage* New(); 00042 vtkTypeRevisionMacro(vtkKWMessage,vtkKWCoreWidget); 00043 void PrintSelf(ostream& os, vtkIndent indent); 00044 00045 // Description: 00046 // Set the text on the message. 00047 virtual void SetText(const char*); 00048 vtkGetStringMacro(Text); 00049 virtual void AppendText(const char*); 00050 00051 // Description: 00052 // Set/Get width of the message (in pixels). 00053 // Specifies the length of lines in the window. If this option has a value 00054 // greater than zero then the AspectRatio setting is ignored and the width 00055 // setting determines the line length. If this option has a value less than 00056 // or equal to zero, then the AspectRatio determines the line length. 00057 virtual void SetWidth(int); 00058 virtual int GetWidth(); 00059 00060 // Description: 00061 // Set/Get aspect ratio of the message. 00062 // Specifies a non-negative integer value indicating desired aspect ratio 00063 // for the text. The aspect ratio is specified as 100*width/height. 00064 // 100 means the text should be as wide as it is tall, 200 means the text 00065 // should be twice as wide as it is tall, 50 means the text should be twice 00066 // as tall as it is wide, and so on. It is used to choose line length for 00067 // the text if the Width setting isn't specified. 00068 virtual void SetAspectRatio(int); 00069 virtual int GetAspectRatio(); 00070 00071 // Description: 00072 // Set/Get the background color of the widget. 00073 virtual void GetBackgroundColor(double *r, double *g, double *b); 00074 virtual double* GetBackgroundColor(); 00075 virtual void SetBackgroundColor(double r, double g, double b); 00076 virtual void SetBackgroundColor(double rgb[3]) 00077 { this->SetBackgroundColor(rgb[0], rgb[1], rgb[2]); }; 00078 00079 // Description: 00080 // Set/Get the foreground color of the widget. 00081 virtual void GetForegroundColor(double *r, double *g, double *b); 00082 virtual double* GetForegroundColor(); 00083 virtual void SetForegroundColor(double r, double g, double b); 00084 virtual void SetForegroundColor(double rgb[3]) 00085 { this->SetForegroundColor(rgb[0], rgb[1], rgb[2]); }; 00086 00087 // Description: 00088 // Set/Get the highlight thickness, a non-negative value indicating the 00089 // width of the highlight rectangle to draw around the outside of the 00090 // widget when it has the input focus. 00091 virtual void SetHighlightThickness(int); 00092 virtual int GetHighlightThickness(); 00093 00094 // Description: 00095 // Set/Get the border width, a non-negative value indicating the width of 00096 // the 3-D border to draw around the outside of the widget (if such a border 00097 // is being drawn; the Relief option typically determines this). 00098 virtual void SetBorderWidth(int); 00099 virtual int GetBorderWidth(); 00100 00101 // Description: 00102 // Set/Get the 3-D effect desired for the widget. 00103 // The value indicates how the interior of the widget should appear 00104 // relative to its exterior. 00105 // Valid constants can be found in vtkKWOptions::ReliefType. 00106 virtual void SetRelief(int); 00107 virtual int GetRelief(); 00108 virtual void SetReliefToRaised(); 00109 virtual void SetReliefToSunken(); 00110 virtual void SetReliefToFlat(); 00111 virtual void SetReliefToRidge(); 00112 virtual void SetReliefToSolid(); 00113 virtual void SetReliefToGroove(); 00114 00115 // Description: 00116 // Specifies the font to use when drawing text inside the widget. 00117 // You can use predefined font names (e.g. 'system'), or you can specify 00118 // a set of font attributes with a platform-independent name, for example, 00119 // 'times 12 bold'. In this example, the font is specified with a three 00120 // element list: the first element is the font family, the second is the 00121 // size, the third is a list of style parameters (normal, bold, roman, 00122 // italic, underline, overstrike). Example: 'times 12 {bold italic}'. 00123 // The Times, Courier and Helvetica font families are guaranteed to exist 00124 // and will be matched to the corresponding (closest) font on your system. 00125 // If you are familiar with the X font names specification, you can also 00126 // describe the font that way (say, '*times-medium-r-*-*-12*'). 00127 virtual void SetFont(const char *font); 00128 virtual const char* GetFont(); 00129 00130 // Description: 00131 // Set/Get the padding that will be applied around each widget (in pixels). 00132 // Specifies a non-negative value indicating how much extra space to request 00133 // for the widget in the X and Y-direction. When computing how large a 00134 // window it needs, the widget will add this amount to the width it would 00135 // normally need (as determined by the width of the things displayed 00136 // in the widget); if the geometry manager can satisfy this request, the 00137 // widget will end up with extra internal space around what it displays 00138 // inside. 00139 virtual void SetPadX(int); 00140 virtual int GetPadX(); 00141 virtual void SetPadY(int); 00142 virtual int GetPadY(); 00143 00144 // Description: 00145 // Set/Get the justification mode. 00146 // When there are multiple lines of text displayed in a widget, this option 00147 // determines how the lines line up with each other. 00148 // This option works together with the Anchor, AspectRatio, and Width 00149 // settings to provide a variety of arrangements of the text within the 00150 // window. The AspectRatio and Width settings determine the amount of screen 00151 // space needed to display the text. The Anchor setting determines where 00152 // this rectangular area is displayed within the widget's window, and the 00153 // Justification setting determines how each line is displayed within that 00154 // rectangular region. For example, suppose Anchor is East and Justification 00155 // is Left, and that the message window is much larger than needed for the 00156 // text. The text will displayed so that the left edges of all the lines 00157 // line up and the right edge of the longest line is on the right side of 00158 // the window; the entire text block will be centered in the vertical span 00159 // of the window. Note that the superclass's PadX and PadY setting can be 00160 // use to provide additional margins. 00161 // Valid constants can be found in vtkKWOptions::JustificationType. 00162 virtual void SetJustification(int); 00163 virtual int GetJustification(); 00164 virtual void SetJustificationToLeft(); 00165 virtual void SetJustificationToCenter(); 00166 virtual void SetJustificationToRight(); 00167 00168 // Description: 00169 // Set/Get the anchoring. 00170 // Specifies how the information in a widget (e.g. text) is to 00171 // be displayed in the widget. See example in the Justification method doc. 00172 // Valid constants can be found in vtkKWOptions::AnchorType. 00173 virtual void SetAnchor(int); 00174 virtual int GetAnchor(); 00175 virtual void SetAnchorToNorth(); 00176 virtual void SetAnchorToNorthEast(); 00177 virtual void SetAnchorToEast(); 00178 virtual void SetAnchorToSouthEast(); 00179 virtual void SetAnchorToSouth(); 00180 virtual void SetAnchorToSouthWest(); 00181 virtual void SetAnchorToWest(); 00182 virtual void SetAnchorToNorthWest(); 00183 virtual void SetAnchorToCenter(); 00184 00185 protected: 00186 vtkKWMessage(); 00187 ~vtkKWMessage(); 00188 00189 // Description: 00190 // Create the widget. 00191 virtual void CreateWidget(); 00192 00193 virtual void UpdateText(); 00194 00195 private: 00196 char* Text; 00197 00198 vtkKWMessage(const vtkKWMessage&); // Not implemented 00199 void operator=(const vtkKWMessage&); // Not implemented 00200 }; 00201 00202 #endif