00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #if !defined(SJGUI_CLASSIC_H_INCLUDED)
00013 #define SJGUI_CLASSIC_H_INCLUDED
00014
00015 #include "controls.h"
00016
00017 namespace sjgui
00018 {
00031 namespace classic
00032 {
00034 class CWndCtrl : public CWndCtrlBase
00035 {
00036 protected:
00037 GLfloat m_DarkSideCol[4];
00038 GLfloat m_BrightSideCol[4];
00039 CWnd::CRect m_3dBorder;
00040 public:
00041 CWndCtrl():CWndCtrlBase()
00042 {
00043 m_DarkSideCol[0]=0.3f;m_DarkSideCol[1]=0.3f;m_DarkSideCol[2]=0.3f;m_DarkSideCol[3]=1.0f;
00044 m_BrightSideCol[0]=0.95f;m_BrightSideCol[1]=0.95f;m_BrightSideCol[2]=0.95f;m_BrightSideCol[3]=1.0f;
00045
00046
00047 }
00053 virtual void Draw()
00054 {
00055
00056 CWndCtrlBase::Draw();
00057
00058 if(!IsEnabled())
00059 {
00060 GLboolean yBlend=glIsEnabled(GL_BLEND);
00061 glEnable(GL_BLEND);
00062
00063
00064 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR);
00065 glColor4fv(m_ShadowColor);
00066 glBegin(GL_TRIANGLE_STRIP);
00067 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00068 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00069 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00070 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00071 glEnd();
00072 if(yBlend)
00073 glEnable(GL_BLEND);
00074 else
00075 glDisable(GL_BLEND);
00076 }
00077 }
00078 };
00080 template<class Tbase=CWndCtrl>
00081 class CLabelTmpl: public CLabelCtrlTmpl<Tbase>{};
00083 template<class Tbase=CWndCtrl>
00084 class CPlaneWndTmpl : public CPlaneWndCtrlTmpl<Tbase>
00085 {
00086 protected:
00088 virtual void OnUpdatePos()
00089 {
00090 CPlaneWndCtrlTmpl<Tbase>::OnUpdatePos();
00091 m_3dBorder=GetAbsPos();
00092 m_3dBorder.Deflate(GetBorderSize());
00093 }
00094 public:
00095 CPlaneWndTmpl():CPlaneWndCtrlTmpl<Tbase>()
00096 {
00097 SetBorderSize(2);
00098 }
00100 virtual void OnDraw()
00101 {
00102
00103 glColor4fv(m_DarkSideCol);
00104 glBegin(GL_TRIANGLES);
00105 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00106 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00107 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00108 glEnd();
00109 glColor4fv(m_BrightSideCol);
00110 glBegin(GL_TRIANGLES);
00111 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00112 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00113 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00114 glEnd();
00115
00116 glColor4fv(m_BgColor);
00117 glBegin(GL_TRIANGLE_STRIP);
00118 glVertex2i(m_3dBorder.GetX(),m_3dBorder.GetBottom());
00119 glVertex2i(m_3dBorder.GetX(),m_3dBorder.GetY());
00120 glVertex2i(m_3dBorder.GetRight(),m_3dBorder.GetBottom());
00121 glVertex2i(m_3dBorder.GetRight(),m_3dBorder.GetY());
00122 glEnd();
00123 }
00124 };
00126 template<class Tbase=CWndCtrl>
00127 class CSliderTmpl : public CSliderCtrlTmpl<Tbase>
00128 {
00129 public:
00131 virtual void OnDraw()
00132 {
00133 glColor4fv(m_ShadowColor);
00134 glBegin(GL_TRIANGLE_STRIP);
00135 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00136 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00137 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00138 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00139 glEnd();
00140
00141 if(IsInFocus())
00142 glColor3fv(m_BgSelColor);
00143 else
00144 glColor3fv(m_BgColor);
00145 glBegin(GL_TRIANGLE_STRIP);
00146 glVertex2i(m_SliderPos.GetX(), m_SliderPos.GetBottom());
00147 glVertex2i(m_SliderPos.GetX(),m_SliderPos.GetY());
00148 glVertex2i(m_SliderPos.GetRight(),m_SliderPos.GetBottom());
00149 glVertex2i(m_SliderPos.GetRight(),m_SliderPos.GetY());
00150 glEnd();
00151 CSliderCtrlTmpl<Tbase>::OnDraw();
00152 }
00153 };
00155 template<class Tlabel=CLabelTmpl<> ,class Tbase=CWndCtrl >
00156 class CCheckBoxTmpl : public CButtonCtrlTmpl<Tlabel,Tbase>
00157 {
00158 CWnd::CRect m_BoxPos;
00159 CWnd::CRect m_CheckSize;
00160 CWnd::CRect m_r2;
00161 protected:
00163 virtual void OnUpdatePos()
00164 {
00165 CButtonCtrlTmpl<Tlabel,Tbase>::OnUpdatePos();
00166 m_BoxPos.SetPos(m_AbsPos.GetX(),m_AbsPos.GetY()+(int)((GetHeight()-m_Label.GetFontSize())/2));
00167 m_BoxPos.SetSize(m_Label.GetFontSize(),m_Label.GetFontSize());
00168 m_BoxPos.Deflate(GetBorderSize());
00169 m_r2=m_BoxPos;
00170 m_r2.Deflate(1);
00171 m_CheckSize=m_BoxPos;
00172 m_CheckSize.Deflate(4);
00173 m_Label.PosWnd( m_BoxPos.GetWidth()+1+GetBorderSize(),
00174 GetBorderSize(),
00175 GetWidth()-(m_BoxPos.GetWidth()+1+GetBorderSize())-1-GetBorderSize(),
00176 GetHeight()-GetBorderSize()*2);
00177 }
00178 public:
00179 CCheckBoxTmpl():CButtonCtrlTmpl<Tlabel,Tbase>()
00180 {
00181 m_Label.SetText("ChBox");
00182 m_Label.SetAlign(ALIGN_LEFT,ALIGN_CENTER);
00183 }
00185 virtual void OnDraw()
00186 {
00187
00188 if(IsMoused())
00189 glColor3fv(m_BgSelColor);
00190 else
00191 glColor3fv(m_BgColor);
00192
00193 if(IsPressed())
00194 glColor4fv(m_BrightSideCol);
00195 else
00196 glColor4fv(m_DarkSideCol);
00197 glBegin(GL_LINE_STRIP);
00198 glVertex2i(m_BoxPos.GetX(),m_BoxPos.GetY());
00199 glVertex2i(m_BoxPos.GetX(),m_BoxPos.GetBottom());
00200 glVertex2i(m_BoxPos.GetRight(),m_BoxPos.GetBottom());
00201 glVertex2i(m_BoxPos.GetRight(),m_r2.GetBottom());
00202 glVertex2i(m_r2.GetX(),m_r2.GetBottom());
00203 glVertex2i(m_r2.GetX(),m_BoxPos.GetY());
00204 glEnd();
00205 if(IsPressed())
00206 glColor4fv(m_DarkSideCol);
00207 else
00208 glColor4fv(m_BrightSideCol);
00209 glBegin(GL_LINE_STRIP);
00210 glVertex2i(m_BoxPos.GetX(),m_BoxPos.GetY());
00211 glVertex2i(m_BoxPos.GetRight(),m_BoxPos.GetY());
00212 glVertex2i(m_BoxPos.GetRight(),m_BoxPos.GetBottom());
00213 glVertex2i(m_r2.GetRight(),m_r2.GetBottom());
00214 glVertex2i(m_r2.GetRight(),m_r2.GetY());
00215 glVertex2i(m_r2.GetX(),m_r2.GetY());
00216 glEnd();
00217
00218 if(m_yChecked)
00219 {
00220 glColor3f(0.0f,0.0f,0.0f);
00221 glBegin(GL_TRIANGLE_STRIP);
00222 glVertex2i(m_CheckSize.GetX(),m_CheckSize.GetBottom());
00223 glVertex2i(m_CheckSize.GetRight(),m_CheckSize.GetBottom());
00224 glVertex2i(m_CheckSize.GetX(), m_CheckSize.GetY());
00225 glVertex2i(m_CheckSize.GetRight(),m_CheckSize.GetY());
00226 glEnd();
00227 }
00228 CButtonCtrlTmpl<Tlabel,Tbase>::OnDraw();
00229 }
00230 };
00232 template<class Tlabel=CLabelTmpl<> ,class Tbase=CWndCtrl>
00233 class CButtonTmpl : public CButtonCtrlTmpl<Tlabel,Tbase>
00234 {
00235 CWnd::CRect m_r1;
00236 CWnd::CRect m_r2;
00237 CWnd::CRect m_r3;
00238 protected:
00240 virtual void OnUpdatePos()
00241 {
00242 CButtonCtrlTmpl<Tlabel,Tbase>::OnUpdatePos();
00243 m_Label.PosWnd(GetClAr());
00244 m_r1=m_r2=m_r3=m_AbsPos;
00245 m_r1.Deflate(1);
00246 m_r2.Deflate(2);
00247 m_r3.Deflate(3);
00248 }
00249 public:
00250 CButtonTmpl():CButtonCtrlTmpl<Tlabel,Tbase>()
00251 {
00252 SetLabel("Button");
00253 SetBorderSize(0);
00254 }
00256 virtual void OnDraw()
00257 {
00258 CButtonCtrlTmpl<Tlabel,Tbase>::OnDraw();
00259
00260 GLfloat dark[4]={0.0f,0.0f,0.0f,1.0f};
00261 glColor4fv(dark);
00262 glBegin(GL_LINE_STRIP);
00263 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00264 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00265 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00266 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00267 glEnd();
00268
00269 if(IsPressed())
00270 glColor4fv(m_BrightSideCol);
00271 else
00272 glColor4fv(m_DarkSideCol);
00273 glBegin(GL_LINE_STRIP);
00274 glVertex2i(m_r1.GetX(),m_r1.GetY());
00275 glVertex2i(m_r1.GetX(),m_r1.GetBottom());
00276 glVertex2i(m_r1.GetRight(),m_r1.GetBottom());
00277 glVertex2i(m_r1.GetRight(),m_r2.GetBottom());
00278 glVertex2i(m_r2.GetX(),m_r2.GetBottom());
00279 glVertex2i(m_r2.GetX(),m_r1.GetY());
00280 glEnd();
00281 if(IsPressed())
00282 glColor4fv(m_DarkSideCol);
00283 else
00284 glColor4fv(m_BrightSideCol);
00285 glBegin(GL_LINE_STRIP);
00286 glVertex2i(m_r1.GetX(),m_r1.GetY());
00287 glVertex2i(m_r1.GetRight(),m_r1.GetY());
00288 glVertex2i(m_r1.GetRight(),m_r1.GetBottom());
00289 glVertex2i(m_r2.GetRight(),m_r2.GetBottom());
00290 glVertex2i(m_r2.GetRight(),m_r2.GetY());
00291 glVertex2i(m_r2.GetX(),m_r2.GetY());
00292 glEnd();
00293
00294 if(IsMoused())
00295 glColor4fv(m_BgSelColor);
00296 else
00297 glColor4fv(m_BgColor);
00298 glBegin(GL_TRIANGLE_STRIP);
00299 glVertex2i(m_r2.GetX(),m_r2.GetBottom());
00300 glVertex2i(m_r2.GetX(),m_r2.GetY());
00301 glVertex2i(m_r2.GetRight(),m_r2.GetBottom());
00302 glVertex2i(m_r2.GetRight(),m_r2.GetY());
00303 glEnd();
00304 }
00305 };
00306
00308 template<class Tbase=CWndCtrl>
00309 class CTextTmpl : public CTextCtrlTmpl<Tbase>
00310 {
00311 protected:
00312 public:
00313 CTextTmpl():CTextCtrlTmpl<Tbase>()
00314 {
00315 GLfloat col[4]={1.0f,1.0f,1.0f,1.0f};
00316
00317 }
00319 virtual void OnDraw()
00320 {
00321
00322 glColor4fv(m_BgColor);
00323 glBegin(GL_TRIANGLE_STRIP);
00324 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00325 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00326 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00327 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00328 glEnd();
00329
00330 glColor4fv(m_BrightSideCol);
00331 glBegin(GL_LINE_STRIP);
00332 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00333 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00334 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00335 glEnd();
00336 glColor4fv(m_DarkSideCol);
00337 glBegin(GL_LINE_STRIP);
00338 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00339 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00340 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00341 glEnd();
00342 CTextCtrlTmpl<Tbase>::OnDraw();
00343 }
00344 };
00346 template<class Ttext=CTextTmpl<> ,class Tslider=CSliderTmpl<> , class Tbase=CWndCtrl>
00347 class CTextBoxTmpl : public CTextBoxCtrlTmpl<Ttext,Tslider,Tbase>
00348 {
00349 public:
00350 CTextBoxTmpl():CTextBoxCtrlTmpl<Ttext,Tslider,Tbase>()
00351 {
00352 SetBorderSize(0);
00353 }
00354 };
00356 template<class Tslider=CSliderTmpl<>,class Tbase=CWndCtrl>
00357 class CPanelTmpl : public CPanelCtrlTmpl<Tslider,Tbase>{};
00359 template<class Tslider=CSliderTmpl<>,class Tbase=CWndCtrl>
00360 class CStackPanelTmpl: public CStackPanelCtrlTmpl<Tslider,Tbase>{};
00362 template<class Tslider=CSliderTmpl<>,class Tbase=CWndCtrl>
00363 class CSqueezePanelTmpl : public CSqueezePanelCtrlTmpl<Tslider,Tbase>{};
00365 template<class Tbutton=CButtonTmpl<>,class Tcaption=CLabelTmpl<>,class TclientPanel=CPanelTmpl<>, class TbuttonPanel=CStackPanelTmpl<>, class Tbase=CPlaneWndTmpl<> >
00366 class CDlgTmpl : public CDlgCtrlTmpl<Tbutton,Tcaption,TclientPanel,TbuttonPanel,Tbase>
00367 {
00368 public:
00369 CDlgTmpl():CDlgCtrlTmpl<Tbutton,Tcaption,TclientPanel,TbuttonPanel,Tbase>()
00370 {
00371 GLfloat col[4]={0.0f,0.0f,1.0f,1.0f};
00372 m_Caption.SetBgColor(col);
00373 m_Caption.SetBorderSize(0);
00374 }
00375 };
00377 template<class Ttext=CTextTmpl<> >
00378 class CEditTmpl : public CEditCtrlTmpl<Ttext>{};
00384 typedef CLabelTmpl<> CLabel;
00385
00388 typedef CTextTmpl<> CText;
00389
00394 typedef CButtonTmpl<> CButton;
00395
00400 typedef CPlaneWndTmpl<> CPlaneWnd;
00401
00406 typedef CSliderTmpl<> CSlider;
00407
00412 typedef CTextBoxTmpl<> CTextBox;
00413
00414
00419 typedef CEditTmpl<> CEdit;
00420
00425 typedef CPanelTmpl<> CPanel;
00430 typedef CStackPanelTmpl<> CStackPanel;
00435 typedef CSqueezePanelTmpl<> CSqueezePanel;
00440 typedef CDlgTmpl<> CDlg;
00445 typedef CCheckBoxTmpl<> CCheckBox;
00447
00448 }
00449 }
00450
00451 #endif // !defined(SJGUI_CLASSIC_H_INCLUDED)