Message(3X) manual page
Table of Contents
Message - display uneditable text or bitmap label
#include
<ivplus/message.h>
Message is an interactor which displays a label.
The label is either non-editable text or a bitmap.The text may include newlines
(specified by ’\n’). The alignment of the label with respect to the interactor’s
canvas can be specified in the constructor, as can the amount of padding
around the message and the amount of horizontal and vertical stretch. In
addition, an internal resize policy may be specified which will cause the
message to either change its shape to accommodate modifications to the
label or to remain at a fixed size. These may be specified by the resize
policies ShrinkToFit and FixedSize, respectively. If FixedSize is specified,
then the values of fixedWidth and fixedHeight determine what size the
message will be.
Internal margins may be specified for top, left, bottom,
and right. These margins require that the label be no closer to the indicated
edge than the appropriate margin value when alignment is performed. These
margins are used mainly for aligning fields within menuitems.
Derived classes
which modify left-to-right appearance only should override XAlign(). The
overridden XAlign() should call Message::XAlign() and then modify the
returned value accordingly to alter the location at which the label will
be drawn.
Message->Interactor
Create a new message
with the indicated text and alignment. Alignments are interpreted as follows:
- Center
- Center-justify each line of text.
- Left
- Left-justify each line of text.
- Right
- Right-justify each line of text.
Text will be surrounded by pad pixels
of whitespace. Stretchability of the message is set to be hstretch and
vstretch. Resize policy defaults to ShrinkToFit unless otherwise indicated.
Use the indicated fixedWidth and fixedHeight if FixedSize is the resize
policy.
Create a new message with the indicated bitmap and alignment. Alignments
are interpreted as follows:
- Center
- Center-justify the bitmap.
- Left
- Left-justify
the bitmap.
- Right
- Right-justify the bitmap.
The bitmap will be surrounded
by pad pixels of whitespace. Stretchability of the message is set to be
hstretch and vstretch. The resize policy defaults to ShrinkToFit unless
otherwise indicated. Use the indicated fixedWidth and fixedHeight if
FixedSize is the resize policy.
Creates a new message
with the same settings as msg. Text is duplicated and reference count of
bitmap is incremented if the bitmap is not nil.
This type is used to determine if message
should display text or a bitmap as its label. Its declaration is found in
interactor.h.
Used
to determine how the shape should be calculated. ShrinkToFit will make the
shape just large enough to fit the image or text on the display.
Returns the current alignment.
Sets
the current alignment.
Returns the current
value used for bottom margin.
Sets the
bottom margin to the indicated value.
Returns the
current width used when ResizePolicy() is FixedSize.
Returns
the current height used when ResizePolicy() is FixedSize.
Sets the width and height to use when ResizePolicy()
is FixedSize.
Returns the string associated with the
given line number.
This will set the highlight
of the display to true or false. When a message is highlighted, the foreground
and background colors are exchanged.
Returns a pointer to
the current bitmap image.
Returns the amount of
space required by the current label. If LabelType() is ImageDisplayType,
this operation will return the bitmap’s height, otherwise it will return
the height of the current text including spacing between lines.
Returns the current type of label in use, either ImageDisplayType
or TextDisplayType.
Sets the current type of
label to use, either ImageDisplayType or TextDisplayType.
Returns the width of the current label. If LabelType() is
ImageDisplayType, returns the width of the current bitmap, otherwise returns
the width of the longest line of text in the current font.
Returns
the amount of space included between any two lines of text.
Returns the current value used for left margin.
Sets the left margin to the indicated value.
Returns
the number of lines in the message.
Returns a pointer
to the output painter.
Returns the amount of padding surrounding
the label.
Sets the amount of padding to surround the
label.
This dynamically changes the alignment
of the message to the indicated alignment. Valid alignment types are: Left,
Center and Right.
Returns the current resize
policy.
Sets the current resize policy
to the indicated value. Valid policies are ShrinkToFit (large enough to
fit the current label and padding) and FixedSize (use the current values
of fixedWidth and fixedHeight to determine size). If the resize policy
changes from ShrinkToFit to FixedSize and the fixed width and height
have not been set, the current size will become the fixed size.
Returns the current value used for bottom margin.
Sets the left margin to the indicated
value.
Returns the array of text lines currently being used.
It contains LineCount() elements. They must not be modified.
Returns the current value used for bottom margin.
Sets the left margin to the indicated value.
Returns whether or not the message participates in
keyboard traversal.
Makes image
the current label. If the canvas is not nil, the shape is recomputed according
to the current resize policy and the parent scene is notified of any change.
Makes the results of Bitmap::open(imageFile)
the current label. If the canvas is not nil, the shape is recomputed according
to the current resize policy and the parent scene is notified of any change.
Replaces the current text in the
message with the passed character array. If the canvas is not nil, the
shape is recomputed according to the current resize policy and the parent
scene is notified of any change.
Replaces
the current text in the message with the passed string. The string is checked
for new line characters (’\n’) and broken into multiple lines where they are
encountered. If the canvas is not nil, the shape is recomputed according
to the current resize policy and the parent scene is notified of any change.
Replace the text at line
index with the passed string. If the canvas is not nil, the shape is recomputed
according to the current resize policy and the parent scene is notified
of any change. The passed text should not contain any newline characters.
If they are found, the substitution will not be performed.
Draws the current bitmap on the canvas according to the
margin values and current alignment.
Draws the lines
of text in the message, evaluating each line and modifying the left coordinate
depending on the alignment used.
Checks
to see if attribute have been set in the X resource file. (See the X RESOURCES
section below for a complete list of attributes.) If any have been set,
evaluates those values and places the results in the corresponding internal
variables. Calculates the size of the message using widest line of text
and line height of all the lines, or the width of the bitmap.
Sets
the clip region, clears the canvas, sets the foreground and background
colors as appropriate for the current value of highlighted and invokes
DrawText(). If LabelType() is ImageDisplayType invokes DrawImage() instead
of DrawText(). Resets the colors if necessary and remove the clip region.
Computes the initial x position
of the indicated piece of text using the current alignment, margins, and
canvas size. Derived classes which modify left-to-right appearance only should
override XAlign(). The overridden XAlign() should call Message::XAlign()
and then modify the returned value accordingly to alter the location at
which the label will be drawn.
Computes
the initial x position of the indicated bitmap using the current alignment,
margins, and canvas size. Derived classes which modify left-to-right appearance
only should override XAlign(). The overridden XAlign() should call Message::XAlign()
and then modify the returned value accordingly to alter the location at
which the label will be drawn.
Sets the amount
of white space which must be maintained between the bottom of the label
and the bottom of the canvas.
Sets the height required by
message when resizePolicy is FixedSize.
Sets the width required
by message when resizePolicy is FixedSize.
Sets the filename
of the bitmap to use when LabelType() is ImageDisplayType.
Sets
the amount of white space which must be maintained between the left end
of the label and the left edge of the canvas.
Sets the amount
of white space which must be maintained between the right end of the label
and the right edge of the canvas.
Sets the amount of white space
padding (in pixels) that surrounds the message to n.
Sets
the internal resize policy. ShrinkToFit instructs message to request only
as much room as needed for label and padding. FixedSize instructs message
to require fixedWidth space for width and fixedHeight space for height.
Sets the text of the message to string. This string may contain
newline (\n) characters.
Sets the amount of white space which
must be maintained between the top of the label and the top of the canvas.
None.
// Message Example
#include <ivplus/box.h>
#include <ivplus/frame.h>
#include <ivplus/glue.h>
#include <ivplus/message.h>
#include <ivplus/world.h>
int main(int argc, char **argv)
{
// Create the world to get the connection with the display.
World* world = new World("MyApp", argc, argv);
// Create a message with default alignment, padding, vstretch and hstretch.
Message* msg1 = new Message("Hello World");
// Create a message with 5 pixel padding, Center Alignment,
// 0 vstretch and 0 hstretch.
Message* msg2 = new Message("Hello World", Center, 5, 0, 0);
// Create a message with center alignment, 5 pixel padding,
// infinite vstretch and hstretch.
Message* msg3 = new Message("Hello World", Center, 5, hfil, vfil);
// Create a multi-line message with default pixel padding, vstretch
// and hstretch.
Message* msg4 = new Message("This is Line 1\nThis is Line 2");
// Enclose each message in a Frame and insert it in a VBox.
VBox* box = new VBox(new Frame(msg1), new Frame(msg2),
new Frame(msg3), new Frame(msg4));
// Map the window.
world->InsertApplication(new Frame(box, 1, BevelOut));
// Enter the event loop.
world->Run();
return 0;
}
message.h
message.C
Bitmap(3X)
, Canvas(3X)
, Interactor(3X)
, Painter(3X)
.
Table of Contents
- Name
- Synopsis
- Description
- Class Hierarchy
- Constructors
- Message(const char* msg, Alignment al = Center, int pad = 0, int hstretch = 0, int vstretch = 0, LabelResizePolicy = NoPolicy, int fixedWidth = 0, int fixedHeight = 0)
- Message(const char* name, const char* msg, Alignment al = Center, int pad = 0, int hstretch = 0, int vstretch = 0, LabelResizePolicy = NoPolicy, int fixedWidth = 0, int fixedHeight = 0)
- Message(Bitmap* image, Alignment al = Center, int pad = 0,int hstretch = 0, int vstretch = 0, LabelResizePolicy = NoPolicy, int fixedWidth = 0, int fixedHeight = 0)
- Message(const char* name, Bitmap* image, Alignment al = Center, int pad = 0, int hstretch = 0, int vstretch = 0, LabelResizePolicy = NoPolicy, int fixedWidth = 0, int fixedHeight = 0)
- Message(Message* msg)
- Public Data
- Public Operations
- Protected Data
- Protected Operations
- X Resources
- Default Keyboard Translations
- Examples
- Files
- See Also