#include <xtextbox.h>
Inheritance diagram for Ars::XTextBox:


Public Member Functions | |
| XTextBox (void) | |
| ~XTextBox (void) | |
| Standard destructor. | |
| virtual void | Init (icstring &aStr) |
| virtual const bool | SetupWindow (const Message &msg) |
| Deregister the setup_window message. | |
| virtual void | SetWndText (const std::string &sWindowText) |
| virtual void | DrawBG (void) |
| virtual void | Draw (void) |
| Draws the button and renders the button label. | |
| virtual void | SetWindowRect (const XRect &WindowRect) |
| virtual const bool | evValueChange (const CtrlMessage &msg) |
| virtual const bool | evValueChanging (const CtrlMessage &msg) |
Protected Attributes | |
| XScrollBar * | vScrollBar |
| A pointer to the vertical scrollbar. | |
| vector< std::string > | textList |
|
|
Construct a new XTextBox
Definition at line 5 of file xtextbox.cpp. References vScrollBar.
00006 : vScrollBar( 0 ) 00007 { 00008 vScrollBar = new XScrollBar(); 00009 } |
|
|
Standard destructor.
Definition at line 11 of file xtextbox.cpp. References vScrollBar.
00012 {
00013 if( vScrollBar )
00014 delete vScrollBar;
00015 vScrollBar = 0;
00016 }
|
|
|
Draws the button and renders the button label.
Reimplemented from Ars::XLabel. Definition at line 53 of file xtextbox.cpp. References Ars::XRect::Bottom(), Ars::XRect::ClipTo(), Ars::Window::GetClientRect(), Ars::Thing::GetFgColor(), Ars::HPaint::GetFontSize(), Ars::XScrollBar::GetPosition(), Ars::XRect::Grow(), Ars::XRect::Height(), Ars::XRect::Overlaps(), Ars::XRect::SetBottom(), textList, Ars::HPaint::TextOutStr(), vScrollBar, and Ars::XRect::Width().
00054 {
00055 w -= 21;
00056 XBox::Draw();
00057 w += 21;
00058 XRect r( GetClientRect() );
00059 r.w -= 21;
00060
00061 int iStartIndex = vScrollBar->GetPosition();
00062 int n = (Height() + GetFontSize() - 1) / GetFontSize();
00063
00064 for( int j = 0; j < n ; ++j )
00065 {
00066 int i = j + iStartIndex;
00067 if( i < (int)textList.size() )
00068 {
00069 XRect ItemRect( r.x , r.y + (i - iStartIndex) * GetFontSize() , r.Width() , GetFontSize() );
00070 if( ItemRect.Overlaps(r ) )
00071 {
00072 ItemRect.ClipTo( r );
00073 ItemRect.SetBottom(ItemRect.Bottom() - 1);
00074 ItemRect.Grow(-1);
00075 TextOutStr( ItemRect , textList[i] , GetFgColor() );
00076 }
00077 }
00078 }
00079 }
|
|
|
Render the background for the control Draws the background as a filled CRect Reimplemented from Ars::Window. Definition at line 46 of file xtextbox.cpp.
00047 {
00048 w -= 21;
00049 XLabel::DrawBG();
00050 w += 21;
00051 }
|
|
|
Reimplemented from Ars::MessageClient. Definition at line 111 of file xtextbox.cpp. References Ars::Thing::SetDirty(), Ars::CtrlMessage::source, textList, and vScrollBar.
00112 {
00113 bool ans = XLabel::evValueChange( msg );
00114
00115 if( !textList.empty() )
00116 {
00117 if( msg.source == vScrollBar )
00118 {
00119 SetDirty();
00120 ans = true;
00121 }
00122 }
00123 return ans;
00124 }
|
|
|
Reimplemented from Ars::MessageClient. Definition at line 126 of file xtextbox.cpp. References Ars::Thing::SetDirty(), Ars::CtrlMessage::source, textList, and vScrollBar.
00127 {
00128 bool ans = XLabel::evValueChanging( msg );
00129
00130 if( !textList.empty() )
00131 {
00132 if( msg.source == vScrollBar )
00133 {
00134 SetDirty();
00135 ans = true;
00136 }
00137 }
00138 return ans;
00139 }
|
|
|
Initialize the thing object via a string the CAR identifiers used are: itemHeight: height of all items... (default -1 for the current font height) mselect: set to 1 if multi selectionis allowed - default single select (scrollbar <s-expression> ): description of the scroll bar Reimplemented from Ars::Window. Definition at line 18 of file xtextbox.cpp. References F_NONE, Ars::Thing::GetBgColor(), Ars::Thing::GetFgColor(), Ars::HPaint::GetFont(), Ars::XRect::Height(), icstring, Ars::XScrollBar::Init(), Ars::XRect::Right(), S_SUNKEN, Ars::Thing::SetBgColor(), Ars::Thing::SetFgColor(), Ars::Thing::SetFlags(), Ars::HPaint::SetFont(), Ars::Thing::SetState(), Ars::XScrollBar::SetWindowRect(), vScrollBar, and Ars::XRect::XRect().
00019 {
00020 XLabel::Init( aStr );
00021
00022 vScrollBar->SetFgColor( GetFgColor() );
00023 vScrollBar->SetBgColor( GetBgColor() );
00024 vScrollBar->SetFont( GetFont() );
00025 vScrollBar->SetState( S_SUNKEN );
00026 vScrollBar->SetFlags( F_NONE );
00027 icstring tmp = Rsrc::FindCrdOf( aStr, "scrollbar" );
00028 vScrollBar->Init( tmp );
00029
00030 vScrollBar->SetWindowRect( XRect( Right() - 20, y , 20 , Height() ) );
00031 }
|
|
|
Deregister the setup_window message.
Reimplemented from Ars::XLabel. Definition at line 33 of file xtextbox.cpp. References Ars::Window::SetParent(), Ars::XScrollBar::SetupWindow(), and vScrollBar.
00034 {
00035 XLabel::SetupWindow( msg );
00036
00037 vScrollBar->SetParent( this );
00038 vScrollBar->SetupWindow( msg );
00039
00040 MessageServer::Instance().RegisterMessageClient(this, Message::CTRL_VALUECHANGE);
00041 MessageServer::Instance().RegisterMessageClient(this, Message::CTRL_VALUECHANGING);
00042
00043 return true;
00044 }
|
|
|
Giving a control a new WindowRect will move and resize the control
Reimplemented from Ars::Window. Definition at line 101 of file xtextbox.cpp. References Ars::Window::clientRect, Ars::XRect::Grow(), Ars::XRect::Height(), Ars::XRect::Right(), Ars::XScrollBar::SetWindowRect(), vScrollBar, Ars::XRect::Width(), and Ars::XRect::XRect().
00102 {
00103 XLabel::SetWindowRect( WindowRect );
00104
00105 XRect ScrollbarRect( *this );
00106 ScrollbarRect.Grow(-1);
00107 vScrollBar->SetWindowRect( XRect( ScrollbarRect.Right() - 12 , ScrollbarRect.y , ScrollbarRect.Width(), ScrollbarRect.Height() ) );
00108 clientRect = XRect( 2 , 2 , Width() - 16 , Height() - 4 );
00109 }
|
|
|
Set the WindowText of the label
Reimplemented from Ars::XLabel. Definition at line 81 of file xtextbox.cpp. References Ars::HPaint::GetFontSize(), Ars::XRect::Height(), Ars::Thing::SetDirty(), Ars::XScrollBar::SetLimits(), textList, and vScrollBar.
00082 {
00083 XLabel::SetWndText( sWindowText );
00084
00085 textList.clear();
00086
00087 size_t n0 = 0 , n1 = sWindowText.find( '\n' , n0 );
00088 while( n1 != string::npos )
00089 {
00090 textList.push_back( sWindowText.substr( n0 , n1 - n0 ) );
00091 n0 = n1 + 1;
00092 n1 = sWindowText.find( '\n' , n0 );
00093 }
00094 int iMax = textList.size() + 1;
00095 int n = Height() / GetFontSize();
00096 iMax -= n;
00097 vScrollBar->SetLimits( 0 , max( 0 , iMax ) );
00098 SetDirty( true );
00099 }
|
|
|
Definition at line 12 of file xtextbox.h. Referenced by Draw(), evValueChange(), evValueChanging(), and SetWndText(). |
|
|
A pointer to the vertical scrollbar.
Definition at line 10 of file xtextbox.h. Referenced by Draw(), evValueChange(), evValueChanging(), Init(), SetupWindow(), SetWindowRect(), SetWndText(), XTextBox(), and ~XTextBox(). |
1.3.3