1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "scrollable_control.h"
27 CScrollableControl::CScrollableControl(uint id
)
39 CScrollableControl::~CScrollableControl()
41 if ( _HScroll
!= NULL
)
44 if ( _VScroll
!= NULL
)
52 void CScrollableControl::hScroll( bool on
)
54 // if we want to show a HScroll bar and that it doesn't exist, build a new one
55 if ( (on
== true) && ( _HScroll
== NULL
) )
57 _HScroll
= new CScrollBar(0, 0, 0, 0, 0, _W
, 0, _W_Pixel
, 16, false, this);
58 _HScroll
->hotSpot( CControl::THotSpot::HS_TR
);
59 _HScroll
->origin( CControl::THotSpot::HS_BL
);
61 _Children
.push_back( _HScroll
);
63 // hide the scroll bar
64 else if ( (on
== false) && ( _HScroll
!= NULL
) )
66 if (_AutoHide
== true)
67 _HScroll
->show( false );
69 _HScroll
->enable( false );
71 // show the scroll bar
72 else if ( (on
== true)&& ( _HScroll
!= NULL
) )
74 _HScroll
->show( true );
75 _HScroll
->enable( true );
82 void CScrollableControl::vScroll( bool on
)
84 if ( (on
== true) && ( _VScroll
== NULL
) )
86 _VScroll
= new CScrollBar(0, 0, 0, 0, 0, 0 , _H
, 16 , _H_Pixel
, false, this);
88 _HScroll
->hotSpot( CControl::THotSpot::HS_TL
);
89 _HScroll
->origin( CControl::THotSpot::HS_BR
);
91 _Children
.push_back( _VScroll
);
93 // hide the scroll bar
94 else if ( (on
== false) && ( _VScroll
!= NULL
) )
96 if (_AutoHide
== true)
97 _VScroll
->show( false );
99 _VScroll
->enable( false );
101 // show the scroll bar
102 else if ( (on
== true)&& ( _VScroll
!= NULL
) )
104 _VScroll
->show( true );
105 _VScroll
->enable( true );
113 void CScrollableControl::autoHide(bool on
)
119 //-----------------------------------------------
121 //-----------------------------------------------
122 void CScrollableControl::click(float x
, float y
, bool &taken
)
124 if (_VScroll
!= NULL
)
125 _VScroll
->click(x
,y
,taken
);
126 if (_HScroll
!= NULL
)
127 _HScroll
->click(x
,y
,taken
);
131 //-----------------------------------------------
133 //-----------------------------------------------
134 void CScrollableControl::clickRight(float x
, float y
, bool &taken
)
136 if (_VScroll
!= NULL
)
137 _VScroll
->clickRight(x
,y
,taken
);
138 if (_HScroll
!= NULL
)
139 _HScroll
->clickRight(x
,y
,taken
);