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 "dbview_bar.h"
22 #include "interface_manager.h"
29 CDBViewBar::CDBViewBar
: CViewBitmap()
34 * parse an xml node and initialize the base view mambers. Must call CViewBase::parse
35 * \param cur : pointer to the xml node to be parsed
36 * \param parentGroup : the parent group of the view
37 * \partam id : a refence to the string that will receive the view ID
38 * \return true if success
40 bool CDBViewBar::parse(xmlNodePtr cur
,CInterfaceGroup
* parentGroup
)
42 if (!CViewBitmap::parse(cur
,parentGroup
))
44 string tmp
= "cannot parse view:"+getId()+", parent:"+parentGroup
->getId();
50 //try to get the NEEDED specific props
51 CXMLAutoPtr prop
= (char*) xmlGetProp( cur
, (xmlChar
*)"range" );
54 _Range
.readSInt32(prop
,_Id
+":range");
58 string tmp
= "cannot getprop:range, view:"+getId()+", parent:"+parentGroup
->getId();
63 prop
= (char*) xmlGetProp( cur
, (xmlChar
*)"rangemax" );
66 _RangeMax
.readSInt32(prop
,_Id
+":rangemax");
70 string tmp
= "cannot getprop:rangemax, view:"+getId()+", parent:"+parentGroup
->getId();
75 prop
= (char*) xmlGetProp( cur
, (xmlChar
*)"vertical" );
77 _Vertical
.readBool (prop
, _Id
+":vertical");
79 _Vertical
.readBool ("false", _Id
+":vertical");
87 void CDBViewBar::draw ()
89 float wBar
= (float)_WReal
, hBar
= (float)_HReal
;
90 if (_Vertical
.getBool())
92 if (_RangeMax
.getSInt32())
93 hBar
= _HReal
* ( (float)_Range
.getSInt32() / (float)_RangeMax
.getSInt32() );
99 if (_RangeMax
.getSInt32())
100 wBar
= _WReal
* ( (float)_Range
.getSInt32() / (float)_RangeMax
.getSInt32() );
105 // Backup scissor and create the new scissor to clip the bar correctly.
106 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
107 CViewRenderer
&rVR
= pIM
->getViewRenderer();
109 sint32 oldScissorX
, oldScissorY
, oldScissorW
, oldScissorH
;
110 rVR
.getClipWindow (oldScissorX
, oldScissorY
, oldScissorW
, oldScissorH
);
112 sint32 scisX
, scisY
, scisWidth
, scisHeight
;
115 scisWidth
= oldScissorW
;
116 scisHeight
= oldScissorH
;
118 //the previous scissor must be taken in account.
119 sint32 xabs
= _XReal
;
120 sint32 yabs
= _YReal
;
127 scisWidth
= std::min(scisWidth
+ oldScissorX
, (sint32
)(xabs
+ wBar
)) - scisX
;
128 scisHeight
= std::min(scisHeight
+ oldScissorY
, (sint32
)(yabs
+ hBar
)) - scisY
;
130 rVR
.setClipWindow (scisX
, scisY
, scisWidth
, scisHeight
);
132 // display progress bitmap
133 //if (_TextureId == -2)
134 // _TextureId = rVR.getTextureIdFromName (_TextureName);
135 rVR
.drawRotFlipBitmap (_RenderLayer
, _XReal
, _YReal
,
136 _WReal
, _HReal
, (uint8
)_Rot
, _Flip
,
137 _TextureId
, _Color
);
139 // restore old scissor
140 rVR
.setClipWindow (oldScissorX
, oldScissorY
, oldScissorW
, oldScissorH
);