00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #if !defined(SJGUI_MODERN_H_INCLUDED)
00013 #define SJGUI_MODERN_H_INCLUDED
00014
00015 namespace sjgui
00016 {
00032 namespace modern
00033 {
00035 class CWndCtrl : public CWndCtrlBase
00036 {
00037 public:
00042 virtual void Draw()
00043 {
00044
00045
00046
00047 if(IsDrawBorder() && IsInFocus())
00048 {
00049 glColor3f(1.0f,1.0f,1.0f);
00050 glBegin(GL_LINE_STRIP);
00051 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00052 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00053 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00054 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00055 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00056 glEnd();
00057 }
00058 CWndCtrlBase::Draw();
00059
00060 if(!IsEnabled())
00061 {
00062 GLboolean yBlend=glIsEnabled(GL_BLEND);
00063 glEnable(GL_BLEND);
00064
00065
00066 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR);
00067 glColor4fv(m_ShadowColor);
00068 glBegin(GL_TRIANGLE_STRIP);
00069 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00070 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00071 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00072 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00073 glEnd();
00074 if(yBlend)
00075 glEnable(GL_BLEND);
00076 else
00077 glDisable(GL_BLEND);
00078 }
00079 }
00080 };
00082 template<class Tbase=CWndCtrl>
00083 class CPlaneWndTmpl : public CPlaneWndCtrlTmpl<Tbase>
00084 {
00085 public:
00087 virtual void OnDraw()
00088 {
00089
00090 glColor4fv(m_BgColor);
00091 glBegin(GL_TRIANGLE_STRIP);
00092 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00093 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00094 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00095 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00096 glEnd();
00097
00098 glColor4fv(m_BorderLightColor);
00099 glBegin(GL_LINE_STRIP);
00100 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00101 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00102 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00103 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00104 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00105 glEnd();
00106 CPlaneWndCtrlTmpl<Tbase>::OnDraw();
00107 }
00108 };
00109
00116 template<class Tbase=CWndCtrl>
00117 class CSliderTmpl : public CSliderCtrlTmpl<Tbase>
00118 {
00119 public:
00121 virtual void OnDraw()
00122 {
00123 glColor4fv(m_ShadowColor);
00124 glBegin(GL_TRIANGLE_STRIP);
00125 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00126 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00127 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00128 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00129 glEnd();
00130
00131 if(IsInFocus())
00132 glColor3fv(m_BgSelColor);
00133 else
00134 glColor3fv(m_BgColor);
00135 glBegin(GL_TRIANGLE_STRIP);
00136 glVertex2i(m_SliderPos.GetX(), m_SliderPos.GetBottom());
00137 glVertex2i(m_SliderPos.GetX(),m_SliderPos.GetY());
00138 glVertex2i(m_SliderPos.GetRight(),m_SliderPos.GetBottom());
00139 glVertex2i(m_SliderPos.GetRight(),m_SliderPos.GetY());
00140 glEnd();
00141 CSliderCtrlTmpl<Tbase>::OnDraw();
00142 }
00143 };
00145 template<class Tbase=CWndCtrl>
00146 class CLabelTmpl: public CLabelCtrlTmpl<Tbase>{};
00148 template<class Tbase=CWndCtrl>
00149 class CTextTmpl : public CTextCtrlTmpl<Tbase>{};
00151 template<class Ttext=CText>
00152 class CEditTmpl : public CEditCtrlTmpl<Ttext>
00153 {
00154 public:
00156 virtual void OnDraw()
00157 {
00158 if(IsInFocus())
00159 glColor4fv(m_BgSelColor);
00160 else
00161 glColor4fv(m_BgColor);
00162
00163 glBegin(GL_TRIANGLE_STRIP);
00164 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00165 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00166 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00167 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00168 glEnd();
00169
00170 glColor4fv(m_ShadowColor);
00171 glBegin(GL_LINE_STRIP);
00172 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00173 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00174 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00175 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00176 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00177 glEnd();
00178 CEditCtrlTmpl<Ttext>::OnDraw();
00179 }
00180 };
00182 template<class Tlabel=CLabel,class Tbase=CWndCtrl>
00183 class CCheckBoxTmpl : public CButtonCtrlTmpl<Tlabel,Tbase>
00184 {
00185 CWnd::CRect m_BoxPos;
00186 CWnd::CRect m_CheckSize;
00187 protected:
00189 virtual void OnUpdatePos()
00190 {
00191 CButtonCtrlTmpl<Tlabel,Tbase>::OnUpdatePos();
00192 m_BoxPos.SetPos(m_AbsPos.GetX(),m_AbsPos.GetY()+(int)((GetHeight()-m_Label.GetFontSize())/2));
00193 m_BoxPos.SetSize(m_Label.GetFontSize(),m_Label.GetFontSize());
00194 m_BoxPos.Deflate(GetBorderSize());
00195 m_CheckSize=m_BoxPos;
00196 m_CheckSize.Deflate(4);
00197 m_Label.PosWnd( m_BoxPos.GetWidth()+1+GetBorderSize(),
00198 GetBorderSize(),
00199 GetWidth()-(m_BoxPos.GetWidth()+1+GetBorderSize())-1-GetBorderSize(),
00200 GetHeight()-GetBorderSize()*2);
00201 }
00202 public:
00203 CCheckBoxTmpl():CButtonCtrlTmpl<Tlabel,Tbase>()
00204 {
00205 m_Label.SetText("ChBox");
00206 m_Label.SetAlign(ALIGN_LEFT,ALIGN_CENTER);
00207 }
00209 virtual void OnDraw()
00210 {
00211
00212 if(IsMoused())
00213 glColor3fv(m_BgSelColor);
00214 else
00215 glColor3fv(m_BgColor);
00216
00217 glBegin(GL_TRIANGLE_STRIP);
00218 glVertex2i(m_BoxPos.GetX(),m_BoxPos.GetBottom());
00219 glVertex2i(m_BoxPos.GetRight(),m_BoxPos.GetBottom());
00220 glVertex2i(m_BoxPos.GetX(), m_BoxPos.GetY());
00221 glVertex2i(m_BoxPos.GetRight(),m_BoxPos.GetY());
00222 glEnd();
00223
00224 if(m_yChecked)
00225 {
00226 glColor3f(0.0f,0.0f,0.0f);
00227 glBegin(GL_TRIANGLE_STRIP);
00228 glVertex2i(m_CheckSize.GetX(),m_CheckSize.GetBottom());
00229 glVertex2i(m_CheckSize.GetRight(),m_CheckSize.GetBottom());
00230 glVertex2i(m_CheckSize.GetX(), m_CheckSize.GetY());
00231 glVertex2i(m_CheckSize.GetRight(),m_CheckSize.GetY());
00232 glEnd();
00233 }
00234 CButtonCtrlTmpl<Tlabel,Tbase>::OnDraw();
00235 }
00236 };
00243 template<class Tlabel=CLabel,class Tbase=CWndCtrl>
00244 class CButtonTmpl : public CButtonCtrlTmpl<Tlabel,Tbase>
00245 {
00246 CWnd::CRect m_ShadowPos;
00247 protected:
00249 virtual void OnUpdatePos()
00250 {
00251 CButtonCtrlTmpl<Tlabel,Tbase>::OnUpdatePos();
00252
00253 m_ShadowPos=m_AbsPos;
00254 m_ShadowPos.Translate(2,2);
00255 m_Label.PosWnd(GetClAr());
00256 }
00257 public:
00258 CButtonTmpl():CButtonCtrlTmpl<Tlabel,Tbase>()
00259 {
00260 SetLabel("Button");
00261 }
00263 virtual void OnDraw()
00264 {
00265 if(IsPressed())
00266 {
00267 if(IsInFocus())
00268 glColor4fv(m_BgSelColor);
00269 else
00270 glColor4fv(m_BgColor);
00271 glBegin(GL_TRIANGLE_STRIP);
00272 glVertex2i(m_ShadowPos.GetX(),m_ShadowPos.GetBottom());
00273 glVertex2i(m_ShadowPos.GetRight(),m_ShadowPos.GetBottom());
00274 glVertex2i(m_ShadowPos.GetX(),m_ShadowPos.GetY());
00275 glVertex2i(m_ShadowPos.GetRight(),m_ShadowPos.GetY());
00276 glEnd();
00277 }
00278 else
00279 {
00280
00281 glColor4fv(m_ShadowColor);
00282 glBegin(GL_TRIANGLE_STRIP);
00283 glVertex2i(m_ShadowPos.GetX(),m_ShadowPos.GetBottom());
00284 glVertex2i(m_ShadowPos.GetRight(),m_ShadowPos.GetBottom());
00285 glVertex2i(m_ShadowPos.GetX(),m_ShadowPos.GetY());
00286 glVertex2i(m_ShadowPos.GetRight(),m_ShadowPos.GetY());
00287 glEnd();
00288 if(IsMoused())
00289 glColor4fv(m_BgSelColor);
00290 else
00291 glColor4fv(m_BgColor);
00292 glBegin(GL_TRIANGLE_STRIP);
00293 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetBottom());
00294 glVertex2i(m_AbsPos.GetX(),m_AbsPos.GetY());
00295 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetBottom());
00296 glVertex2i(m_AbsPos.GetRight(),m_AbsPos.GetY());
00297 glEnd();
00298 }
00299 CButtonCtrlTmpl<Tlabel,Tbase>::OnDraw();
00300 }
00301 };
00303 template<class Ttext=CText,class Tslider=CSlider, class Tbase=CWndCtrl>
00304 class CTextBoxTmpl : public CTextBoxCtrlTmpl<Ttext,Tslider,Tbase>{};
00306 template<class Tslider=CSlider,class Tbase=CWndCtrl>
00307 class CPanelTmpl : public CPanelCtrlTmpl<Tslider,Tbase>{};
00309 template<class Tslider=CSlider,class Tbase=CWndCtrl>
00310 class CStackPanelTmpl: public CStackPanelCtrlTmpl<Tslider,Tbase>{};
00312 template<class Tslider=CSlider,class Tbase=CWndCtrl>
00313 class CSqueezePanelTmpl : public CSqueezePanelCtrlTmpl<Tslider,Tbase>{};
00315 template<class Tbutton=CButton,class Tcaption=CLabel,class TclientPanel=CPanel, class TbuttonPanel=CStackPanel, class Tbase=CPlaneWnd>
00316 class CDlgTmpl : public CDlgCtrlTmpl<Tbutton,Tcaption,TclientPanel,TbuttonPanel,Tbase>{};
00322 typedef CLabelTmpl<> CLabel;
00323
00326 typedef CTextTmpl<> CText;
00327
00332 typedef CButtonTmpl<> CButton;
00333
00338 typedef CPlaneWndTmpl<> CPlaneWnd;
00339
00344 typedef CSliderTmpl<> CSlider;
00345
00350 typedef CTextBoxTmpl<> CTextBox;
00351
00352
00357 typedef CEditTmpl<> CEdit;
00358
00363 typedef CPanelTmpl<> CPanel;
00368 typedef CStackPanelTmpl<> CStackPanel;
00373 typedef CSqueezePanelTmpl<> CSqueezePanel;
00378 typedef CDlgTmpl<> CDlg;
00383 typedef CCheckBoxTmpl<> CCheckBox;
00385
00386 }
00387 }
00388
00389 #endif // !defined(SJGUI_MODERN_H_INCLUDED)