MessageTextView

MessageTextView version 1.0
by Al.V.Sarikov.
Kherson, Ukraine, 2006.
E-mail: avix@ukrpost.net.
Home page: http://avix.pp.ru.

Class is created on base of and using code of URLView class of version 2.11 written by William Kakes of Tall Hill Software (http://www.tallhill.com).

Derived from: public BStringView, public BInvoker
Declared in:  MessageTextView.h
Summary:  more...


This class provides an underlined and clickable BStringView. Being clicked it sends message the same as BButton control. But unlike BButton it does not provide possibility to operate with keyboard.

Class is created by modifying of code of URLView class. Used parts of original code have taken unchanged. Lines of code which are not necessary for purposes of MessageTextView class are removed. Added a little of code responsible for transferring messages to receiver (working with messages is fully charged with functions derived from BInvoker class and is not described in this document). Added functions returning values of colors (of active, non-active, hovered link), state of link, underline thickness.

MessageTextView is provided as is, with no warranties of any kind. If you use it, you are on your own.


Constructor and Destructor


MessageTextView()

MessageTextView(BRect frame, const char *name, const char *label, BMessage *msg,
      uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW)

Initializes the MessageTextView by assigning it a label string and the system plain font (be_plain_font) colored blue with a one-pixel underline. The frame, name, resizingMode and flags arguments are passed unchanged to the BView constructor, msg argument - to BInvoker constructor.

The frame rectangle needs to be large enough to display the entire link label in the current font. The link is drawn at the bottom of the frame rectangle and, by default, is aligned to the left side. Colors and certain features can be changed and toggled through the various methods.

The constructor assumes some default values which may be changed using the Set() methods. The default link color is blue, turning red when clicked. When the mouse cursor is over the link, the link turns a darker blue (not only this color can be changed, but the behavior can be toggled). The underline thickness is set to one pixel.


~MessageTextView()

virtual ~MessageTextView()

Frees the label and cursor.


Member Functions


ClickColor() see SetClickColor()
Color() see SetColor()
DisabledColor() see SetDisabledColor()
HoverColor() see SetHoverColor()


IsEnabled() see SetEnabled()
IsHoverEnabled() see SetHoverEnabled()


ClickColor() , SetClickColor()

virtual rgb_color ClickColor(void) const
virtual void SetClickColor(rgb_color color)
virtual void SetClickColor(uchar red, uchar green, uchar blue, uchar alpha = 255 )

ClickColor() returns the color in which to draw the link when it is being clicked on.

SetClickColor() sets this color.


Color() , SetColor()

virtual rgb_color Color(void) const
virtual void SetColor(rgb_color color)
virtual void SetColor(uchar red, uchar green, uchar blue, uchar alpha = 255 )

Color() returns the color in which to draw the link when it is not being clicked on or hovered over with the mouse cursor.

SetColor() sets this color.

Note: It is not sufficient to call SetHighColor() on the MessageTextView. SetColor() must be used.


DisabledColor() , SetDisabledColor()

virtual rgb_color DisabledColor(void) const
virtual void SetDisabledColor(rgb_color color)
virtual void SetDisabledColor(uchar red, uchar green, uchar blue, uchar alpha = 255 )

DisabledColor() returns the color in which to draw the link when it is disabled.

SetDisabledColor() sets this color. Use SetEnabled() to disable link.


IsEnabled() , SetEnabled()

virtual bool IsEnabled(void)
virtual void SetEnabled(bool enabled )

IsEnabled() returns whether link is enabled.

SetEnabled() sets whether or not the link is enabled. If it is disabled, it will look and behave just like a normal BStringView (i.e. the underline will not be drawn and it will not highlight or respond to mouse clicks). It will be drawn in gray by default, but you can override this by using SetDisabledColor().


HoverColor() , SetHoverColor()

virtual rgb_color HoverColor(void) const
virtual void SetHoverColor(rgb_color color)
virtual void SetHoverColor(uchar red, uchar green, uchar blue, uchar alpha = 255 )

HoverColor() returns the color in which to draw the link when the mouse cursor is over the link.

SetHoverColor() sets this color. This behavior can be turned off using SetHoverEnabled().


IsHoverEnabled() , SetHoverEnabled()

virtual bool IsHoverEnabled(void)
virtual void SetHoverEnabled(bool hover)

IsHoverEnabled() returns whether link will highlight when the mouse cursor is over it.

SetHoverEnabled() toggles whether or not the link will highlight when the mouse cursor is over it. The highlight color is specified by SetHoverColor().


UnderlineThickness() , SetUnderlineThickness()

virtual int UnderlineThickness(void)
virtual void SetUnderlineThickness(int thickness)

UnderlineThickness() returns the thickness of the underline in pixels.

SetUnderlineThickness() specifies the thickness of the underline in pixels. Typically, you will probably want to use the default value of one pixel, but for larger text a larger value may be desired. This function will go away when Be's font system can render underlines for all fonts.


UnderlineThickness() see SetUnderlineThickness()