#include <xscrollbar.h>
Inheritance diagram for Ars::XScrollBar:


Public Types | |
| enum | EScrollBarType { VERTICAL, HORIZONTAL } |
| The types of scrollbars possible. More... | |
Public Member Functions | |
| XScrollBar (void) | |
| virtual | ~XScrollBar (void) |
| Standard destructor. | |
| virtual void | Init (icstring &aStr) |
| virtual const bool | SetupWindow (const Message &msg) |
| Deregister the setup_window message. | |
| void | SetLimits (const int Min, const int Max) |
| Set the limits of the scroll bar. | |
| const int | GetMinLimit (void) |
| The minimum limit of the scroll bar. | |
| const int | GetMaxLimit (void) |
| The maximum limit of the scroll bar. | |
| void | SetPosition (const int iPosition) |
| Set the current thumb position. | |
| const int | GetPosition (void) |
| The current progress value. | |
| virtual void | Draw (void) |
| Draws the scroll bar. | |
| virtual void | SetWindowRect (const XRect &WindowRect) |
Protected Member Functions | |
| virtual const bool | evMouseButtonDown (const MouseMessage &msg) |
| virtual const bool | evMouseButtonUp (const MouseMessage &msg) |
| virtual const bool | evMouseMove (const MouseMessage &msg) |
| virtual const bool | evMouseLClick (const CtrlMessage &msg) |
Private Attributes | |
| EScrollBarType | m_ScrollBarType |
| The type of scroll bar. | |
| int | m_iMin |
| The minimum value of the scroll bar. | |
| int | m_iMax |
| The maximum value of the scroll bar. | |
| int | m_iPosition |
| The current position of the scroll bar thumb. | |
| XButtonImage * | m_pBtnUpLeft |
| A pointer to the Up or Left button. | |
| XButtonImage * | m_pBtnDownRight |
| XRect | m_ThumbRect |
| The thumb rect. | |
| bool | m_bDragging |
| Indicates if the thumb is currently being dragged. | |
| string | sct |
| string | key |
| string | fname |
|
|
The types of scrollbars possible.
Definition at line 9 of file xscrollbar.h.
00010 {
00011 VERTICAL,
00012 HORIZONTAL
00013 };
|
|
|
Constructs a scroll bar, initilizes the limits to 0, and 100 with the position at 0
Definition at line 6 of file xscrollbar.cpp.
00007 : m_iMin( 0 ) , m_iMax( -1 ) , m_iPosition( 1 ) , m_bDragging( false ) 00008 , m_pBtnUpLeft( 0 ) , m_pBtnDownRight( 0 ) 00009 { 00010 } |
|
|
Standard destructor.
Definition at line 13 of file xscrollbar.cpp. References m_pBtnDownRight, and m_pBtnUpLeft.
00014 {
00015 if( m_pBtnUpLeft ) delete m_pBtnUpLeft; m_pBtnUpLeft = 0;
00016 if( m_pBtnDownRight ) delete m_pBtnDownRight; m_pBtnDownRight = 0;
00017 }
|
|
|
Draws the scroll bar.
Reimplemented from Ars::XBox. Definition at line 157 of file xscrollbar.cpp. References Ars::XBox::DrawRaised(), Ars::HPaint::DrawRect(), Ars::Thing::GetFgColor(), Ars::XRect::Grow(), Ars::XRect::HitTest(), m_ThumbRect, Ars::XRect::RELPOS_INSIDE, and Ars::XRect::TopLeft().
00158 {
00159 XBox::Draw();
00160
00161 XRect SubRect( m_ThumbRect );
00162
00163 if( HitTest( SubRect.TopLeft() ) == RELPOS_INSIDE )
00164 {
00165 SubRect.Grow( -1 );
00166
00167 DrawRaised( SubRect , GetFgColor() );
00168
00169 SubRect.Grow( -1 );
00170 DrawRect( SubRect , true , GetFgColor() , GetFgColor() );
00171 }
00172 }
|
|
|
Reimplemented from Ars::Window. Definition at line 210 of file xscrollbar.cpp. References Ars::MouseMessage::Button, Ars::XRect::HitTest(), m_bDragging, m_ThumbRect, Ars::MouseMessage::Point, Ars::XRect::RELPOS_INSIDE, and Ars::Thing::SetDirty().
00211 {
00212 bool ans = XBox::evMouseButtonDown( msg );
00213
00214 if( m_ThumbRect.HitTest( msg.Point ) == RELPOS_INSIDE && msg.Button == MouseMessage::LEFT )
00215 {
00216 m_bDragging = true;
00217 ans = true;
00218 SetDirty();
00219 }
00220
00221 return ans;
00222 }
|
|
|
Reimplemented from Ars::Window. Definition at line 224 of file xscrollbar.cpp. References ArsSendMessage, Ars::MouseMessage::Button, Ars::Window::GetParent(), m_bDragging, m_iPosition, and Ars::Thing::SetDirty().
00225 {
00226 bool ans = XBox::evMouseButtonUp( msg ); // we do not want to send out parent a click on the slider....
00227
00228 if( m_bDragging && msg.Button == MouseMessage::LEFT )
00229 {
00230 m_bDragging = false;
00231 ArsSendMessage( CtrlMessage( Message::CTRL_VALUECHANGE , GetParent() , this, m_iPosition ) );
00232 ans = true;
00233 SetDirty();
00234 }
00235 return ans;
00236 }
|
|
|
Reimplemented from Ars::MessageClient. Definition at line 264 of file xscrollbar.cpp. References ArsSendMessage, Ars::Message::Destination(), Ars::Window::GetParent(), m_iPosition, m_pBtnDownRight, m_pBtnUpLeft, Ars::Thing::SetDirty(), SetPosition(), and Ars::CtrlMessage::source.
00265 {
00266 bool ans = XBox::evMouseLClick( msg );
00267 if( msg.Destination() == this )
00268 {
00269 if( msg.source == m_pBtnUpLeft )
00270 {
00271 SetPosition( m_iPosition - 1 );
00272 ans = true;
00273 }
00274 else if( msg.source == m_pBtnDownRight )
00275 {
00276 SetPosition( m_iPosition + 1 );
00277 ans = true;
00278 }
00279 if( ans )
00280 ArsSendMessage( CtrlMessage( Message::CTRL_VALUECHANGE, GetParent() , this, m_iPosition ) );
00281 SetDirty();
00282 }
00283
00284 return ans;
00285 }
|
|
|
Reimplemented from Ars::MessageClient. Definition at line 238 of file xscrollbar.cpp. References ArsSendMessage, Ars::Window::GetClientRect(), Ars::Window::GetParent(), Ars::XRect::Height(), HORIZONTAL, m_bDragging, m_iMax, m_iMin, m_iPosition, m_ScrollBarType, Ars::MouseMessage::Point, Ars::Thing::SetDirty(), SetPosition(), VERTICAL, Ars::XRect::Width(), Ars::XPoint::x, and Ars::XPoint::y.
00239 {
00240 bool ans = XBox::evMouseMove( msg );
00241 if( m_bDragging )
00242 {
00243 int iOldPosition = m_iPosition;
00244 switch (m_ScrollBarType)
00245 {
00246 case VERTICAL:
00247 SetPosition( (msg.Point.y - GetClientRect().y) * (m_iMax - m_iMin) / GetClientRect().Height() + m_iMin );
00248 break;
00249 case HORIZONTAL:
00250 SetPosition( (msg.Point.x - GetClientRect().x) * (m_iMax - m_iMin) / GetClientRect().Width() + m_iMin );
00251 break;
00252 default:
00253 // throw(ExceptionApp("CScrollBar::HandleMessage: Unrecognized ScrollBar Type."));
00254 break;
00255 }
00256 if (iOldPosition != m_iPosition)
00257 ArsSendMessage( CtrlMessage( Message::CTRL_VALUECHANGING, GetParent() , this , m_iPosition ) );
00258 SetDirty();
00259 }
00260
00261 return ans;
00262 }
|
|
|
The maximum limit of the scroll bar.
Definition at line 55 of file xscrollbar.h. References m_iMax.
00055 { return m_iMax; }
|
|
|
The minimum limit of the scroll bar.
Definition at line 52 of file xscrollbar.h. References m_iMin.
00052 { return m_iMin; }
|
|
|
The current progress value.
Definition at line 61 of file xscrollbar.h. References m_iPosition. Referenced by Ars::XTextBox::Draw(), Ars::XListBox::Draw(), Ars::XListBox::evKeyDown(), Ars::XListBox::evMouseButtonDown(), and Ars::XListBox::evMouseButtonUp().
00061 { return m_iPosition; }
|
|
|
Initialize the thing object via a string the CAR identifiers used are: cfg: "section" "key" "fname" NB if fname starts with @ the string is the key of associated with afilename in the global Cfg file max: max element to scrol (default = 100) (ULButton <s-expression> ): list of the up or left button (BRButton <s-expression> ): list of the bottom ot right button Reimplemented from Ars::Window. Definition at line 19 of file xscrollbar.cpp. References Ars::XRect::Bottom(), Ars::XRect::BottomRight(), Ars::Window::clientRect, F_NONE, fname, Ars::Thing::GetBgColor(), Ars::Thing::GetFgColor(), Ars::HPaint::GetFont(), Ars::Window::GetWindowText(), Ars::XRect::Height(), HORIZONTAL, icstring, Ars::XButtonImage::Init(), key, m_iMax, m_pBtnDownRight, m_pBtnUpLeft, m_ScrollBarType, Ars::XRect::Right(), S_RAISED, sct, Ars::Thing::SetBgColor(), Ars::Thing::SetFgColor(), Ars::Thing::SetFlags(), Ars::HPaint::SetFont(), Ars::Thing::SetState(), SetWindowRect(), Ars::Window::SetWindowRect(), Ars::XLabel::SetWndText(), Ars::XRect::TopLeft(), VERTICAL, Ars::XRect::Width(), and Ars::XRect::XRect(). Referenced by Ars::XTextBox::Init(), and Ars::XListBox::Init().
00020 {
00021 XBox::Init( aStr );
00022
00023 icstring tmp = Rsrc::FindCrdOf( aStr , "cfg" );
00024
00025 sct = Rsrc::GetStr( tmp );
00026 key = Rsrc::GetStr( tmp );
00027 fname = Rsrc::GetStr( tmp );
00028
00029 if( Width() > Height() )
00030 {
00031 m_ScrollBarType = HORIZONTAL;
00032 m_pBtnUpLeft = new XButtonImage();
00033 m_pBtnUpLeft->SetWindowRect( XRect( TopLeft(), XPoint( x + Height(), Bottom() ) ) );
00034 m_pBtnDownRight = new XButtonImage();
00035 m_pBtnDownRight->SetWindowRect( XRect( XPoint( Right() - Height() , y ), BottomRight() ) );
00036 clientRect.x += m_pBtnUpLeft->Width() + 1;
00037 clientRect.w -= 2 * m_pBtnUpLeft->Width() + 1;
00038 }
00039 else
00040 {
00041 m_ScrollBarType = VERTICAL;
00042 m_pBtnUpLeft = new XButtonImage();
00043 m_pBtnUpLeft->SetWindowRect( XRect( TopLeft(), XPoint( Right(), y + Width() ) ) );
00044 m_pBtnDownRight = new XButtonImage();
00045 m_pBtnDownRight->SetWindowRect( XRect( XPoint( x , Bottom() - Width() ), BottomRight() ) );
00046 clientRect.y += m_pBtnUpLeft->Height() + 1;
00047 clientRect.h -= 2 * m_pBtnUpLeft->Height() + 1;
00048 }
00049
00050 if( m_iMax == -1 )
00051 {
00052 tmp = Rsrc::FindCrdOf( aStr , "max" );
00053 m_iMax = Rsrc::GetInt( tmp , 100 );
00054 }
00055
00056 m_pBtnUpLeft->SetBgColor( GetBgColor() );
00057 m_pBtnUpLeft->SetFgColor( GetFgColor().FadeColor( 32 ) );
00058 m_pBtnUpLeft->SetState( S_RAISED );
00059 m_pBtnUpLeft->SetFlags( F_NONE );
00060 m_pBtnUpLeft->SetFont( GetFont() );
00061 tmp = Rsrc::FindCrdOf( aStr , "ULButton" );
00062 m_pBtnUpLeft->Init( tmp );
00063 if( m_pBtnUpLeft->GetWindowText().empty() )
00064 if( m_ScrollBarType == HORIZONTAL )
00065 m_pBtnUpLeft->SetWndText( "<-" );
00066 else
00067 m_pBtnUpLeft->SetWndText( "/\\" );
00068
00069 m_pBtnDownRight->SetBgColor( GetBgColor() );
00070 m_pBtnDownRight->SetFgColor( GetFgColor().FadeColor( 32 ) );
00071 m_pBtnDownRight->SetFlags( F_NONE );
00072 m_pBtnDownRight->SetState( S_RAISED );
00073 m_pBtnDownRight->SetFont( GetFont() );
00074 tmp = Rsrc::FindCrdOf( aStr , "BRButton" );
00075 m_pBtnDownRight->Init( tmp );
00076 if( m_pBtnDownRight->GetWindowText().empty() )
00077 if( m_ScrollBarType == HORIZONTAL )
00078 m_pBtnDownRight->SetWndText( "->" );
00079 else
00080 m_pBtnDownRight->SetWndText( "\\/" );
00081 SetWindowRect( *this );
00082
00083 RGBColor c = GetFgColor();
00084 SetFgColor( GetBgColor() );
00085 SetBgColor( c );
00086 }
|
|
||||||||||||
|
Set the limits of the scroll bar.
Definition at line 49 of file xscrollbar.h. References m_iMax, m_iMin, and Ars::Thing::SetDirty(). Referenced by Ars::XListBox::AddItem(), Ars::XListBox::ClearItems(), Ars::XListBox::Init(), Ars::XListBox::RemoveItem(), and Ars::XTextBox::SetWndText().
|
|
|
Set the current thumb position.
Definition at line 128 of file xscrollbar.cpp. References Ars::Window::GetClientRect(), HORIZONTAL, m_iMax, m_iMin, m_iPosition, m_ScrollBarType, m_ThumbRect, Ars::Window::UpdateWindow(), and VERTICAL. Referenced by Ars::XListBox::evKeyDown(), evMouseLClick(), evMouseMove(), SetupWindow(), and SetWindowRect().
00129 {
00130 m_iPosition = min( m_iMax , max( m_iMin , iPosition ) );
00131 XRect clt = GetClientRect();
00132
00133 switch( m_ScrollBarType )
00134 {
00135 case VERTICAL:
00136 {
00137 int yPos = static_cast<int>(clt.y + (clt.h - 16) * (static_cast<double>(m_iPosition - m_iMin) / (m_iMax - m_iMin)) - 1);
00138 m_ThumbRect.y = yPos;
00139 m_ThumbRect.h= 16;
00140 break;
00141 }
00142 case HORIZONTAL:
00143 {
00144 int xPos = static_cast<int>(clt.x + (clt.w - 16) * (static_cast<double>(m_iPosition - m_iMin) / (m_iMax - m_iMin)) - 1);
00145 m_ThumbRect.x = xPos;
00146 m_ThumbRect.w = 16;
00147 break;
00148 }
00149 default:
00150 // throw(ExceptionApp("CScrollBar::SetPosition: Unrecognized ScrollBar Type."));
00151 break;
00152 }
00153 UpdateWindow();
00154 }
|
|
|
Deregister the setup_window message.
Reimplemented from Ars::Window. Definition at line 88 of file xscrollbar.cpp. References Ars::XButtonImage::ChangeImage(), fname, Cfg::GetCfg(), Cfg::Handler::GetCfgFile(), Ars::Window::GetClientRect(), HORIZONTAL, key, m_pBtnDownRight, m_pBtnUpLeft, m_ScrollBarType, m_ThumbRect, sct, Ars::Window::SetParent(), SetPosition(), and Ars::XButtonImage::SetupWindow(). Referenced by Ars::XTextBox::SetupWindow(), and Ars::XListBox::SetupWindow().
00089 {
00090 XBox::SetupWindow( msg );
00091
00092 if( !sct.empty() && !key.empty() && fname.empty() )
00093 fname = Cfg::GetCfg().GetCfgFile( sct , key );
00094 else if( fname.empty() && !sct.empty() )
00095 fname = sct;
00096
00097 if( !fname.empty() )
00098 {
00099 Cfg::Handler &h = Cfg::GetCfg( fname );
00100 if( m_ScrollBarType = HORIZONTAL )
00101 {
00102 m_pBtnUpLeft->ChangeImage( h.GetCfgFile( "scrollbar" , "left" ) );
00103 m_pBtnDownRight->ChangeImage( h.GetCfgFile( "scrollbar" , "right" ) );
00104 }
00105 else
00106 {
00107 m_pBtnUpLeft->ChangeImage( h.GetCfgFile( "scrollbar" , "up" ) );
00108 m_pBtnDownRight->ChangeImage( h.GetCfgFile( "scrollbar" , "down" ) );
00109 }
00110 }
00111 m_ThumbRect = GetClientRect();
00112
00113 m_pBtnUpLeft->SetParent( this );
00114 m_pBtnUpLeft->SetupWindow( msg );
00115 m_pBtnDownRight->SetParent( this );
00116 m_pBtnDownRight->SetupWindow( msg );
00117
00118 SetPosition( 0 );
00119
00120 MessageServer::Instance().RegisterMessageClient(this, Message::MOUSE_BUTTONDOWN);
00121 MessageServer::Instance().RegisterMessageClient(this, Message::MOUSE_BUTTONUP);
00122 MessageServer::Instance().RegisterMessageClient(this, Message::MOUSE_MOVE);
00123 MessageServer::Instance().RegisterMessageClient(this, Message::CTRL_LCLICK);
00124
00125 return true;
00126 }
|
|
|
Giving a control a new WindowRect will move and resize the control
Reimplemented from Ars::Window. Definition at line 175 of file xscrollbar.cpp. References Ars::XRect::Bottom(), Ars::XRect::BottomRight(), Ars::Window::clientRect, Ars::XRect::Height(), HORIZONTAL, m_iPosition, m_pBtnDownRight, m_pBtnUpLeft, m_ScrollBarType, m_ThumbRect, Ars::XRect::Right(), Ars::XRect::SetBottom(), SetPosition(), Ars::XRect::SetRight(), Ars::Window::SetWindowRect(), Ars::XRect::TopLeft(), VERTICAL, Ars::XRect::Width(), and Ars::XRect::XRect(). Referenced by Ars::XTextBox::Init(), Init(), Ars::XListBox::Init(), Ars::XTextBox::SetWindowRect(), and Ars::XListBox::SetWindowRect().
00176 {
00177 XBox::SetWindowRect( WindowRect );
00178
00179 // Resposition the thumb rect and the button controls
00180 SetPosition( m_iPosition );
00181
00182 switch( m_ScrollBarType )
00183 {
00184 case VERTICAL:
00185 {
00186 m_ThumbRect.x = x;
00187 m_ThumbRect.SetRight( Right() );
00188 m_pBtnUpLeft->SetWindowRect( XRect( TopLeft(), XPoint( Right(), y + Width() ) ) );
00189 m_pBtnDownRight->SetWindowRect( XRect( XPoint( x , Bottom() - Width() ), BottomRight() ) );
00190 clientRect.y = m_pBtnUpLeft->Height() + 1;
00191 clientRect.SetBottom( Height() - m_pBtnUpLeft->Height() - 1 );
00192 break;
00193 }
00194 case HORIZONTAL:
00195 {
00196 m_ThumbRect.y = y;
00197 m_ThumbRect.SetBottom( Bottom() );
00198 m_pBtnUpLeft->SetWindowRect( XRect( TopLeft() , XPoint( x + Height(), Bottom() ) ) );
00199 m_pBtnDownRight->SetWindowRect( XRect( XPoint( Right() - Height(), y ), BottomRight() ) );
00200 clientRect.x = m_pBtnUpLeft->Width() + 1;
00201 clientRect.SetRight( Width() - m_pBtnUpLeft->Width() - 1 );
00202 break;
00203 }
00204 default:
00205 // throw(ExceptionApp("CScrollBar::SetWindowRect: Unrecognized ScrollBar Type."));
00206 break;
00207 }
00208 }
|
|
|
Definition at line 25 of file xscrollbar.h. Referenced by Init(), and SetupWindow(). |
|
|
Definition at line 25 of file xscrollbar.h. Referenced by Init(), and SetupWindow(). |
|
|
Indicates if the thumb is currently being dragged.
Definition at line 23 of file xscrollbar.h. Referenced by evMouseButtonDown(), evMouseButtonUp(), and evMouseMove(). |
|
|
The maximum value of the scroll bar.
Definition at line 18 of file xscrollbar.h. Referenced by evMouseMove(), GetMaxLimit(), Init(), SetLimits(), and SetPosition(). |
|
|
The minimum value of the scroll bar.
Definition at line 17 of file xscrollbar.h. Referenced by evMouseMove(), GetMinLimit(), SetLimits(), and SetPosition(). |
|
|
The current position of the scroll bar thumb.
Definition at line 19 of file xscrollbar.h. Referenced by evMouseButtonUp(), evMouseLClick(), evMouseMove(), GetPosition(), SetPosition(), and SetWindowRect(). |
|
|
Definition at line 21 of file xscrollbar.h. Referenced by evMouseLClick(), Init(), SetupWindow(), SetWindowRect(), and ~XScrollBar(). |
|
|
A pointer to the Up or Left button.
Definition at line 20 of file xscrollbar.h. Referenced by evMouseLClick(), Init(), SetupWindow(), SetWindowRect(), and ~XScrollBar(). |
|
|
The type of scroll bar.
Definition at line 16 of file xscrollbar.h. Referenced by evMouseMove(), Init(), SetPosition(), SetupWindow(), and SetWindowRect(). |
|
|
The thumb rect.
Definition at line 22 of file xscrollbar.h. Referenced by Draw(), evMouseButtonDown(), SetPosition(), SetupWindow(), and SetWindowRect(). |
|
|
Definition at line 25 of file xscrollbar.h. Referenced by Init(), and SetupWindow(). |
1.3.3