#define SJGUI_USE_STYLE own_style
#include <sjgui/sjgui.h>
namespace sjgui
{
namespace own_style
{
class CWndCtrl : public CWndCtrlBase
{
public:
virtual void Draw()
{
CWndCtrlBase::Draw();
}
};
template<class Tbase=CWndCtrl>
class CLabelTmpl: public CLabelCtrlTmpl<Tbase>{};
template<class Tbase=CWndCtrl>
class CTextTmpl : public CTextCtrlTmpl<Tbase>{};
template<class Tbase=CWndCtrl>
class CPlaneWndTmpl : public CPlaneWndCtrlTmpl<Tbase>
{
public:
virtual void OnDraw()
{
CPlaneWndCtrlTmpl<Tbase>::OnDraw();
}
};
template<class Tbase=CWndCtrl>
class CSliderTmpl : public CSliderCtrlTmpl<Tbase>{};
template<class Ttext=CText>
class CEditTmpl : public CEditCtrlTmpl<Ttext>{};
template<class Tlabel=CLabel,class Tbase=CWndCtrl>
class CCheckBoxTmpl : public CButtonCtrlTmpl<Tlabel,Tbase>
{
protected:
virtual void OnUpdatePos()
{
CButtonCtrlTmpl<Tlabel,Tbase>::OnUpdatePos();
m_Label.PosWnd(GetClAr());
}
public:
CCheckBoxTmpl():CButtonCtrlTmpl<Tlabel,Tbase>()
{
m_Label.SetText("ChBox");
m_Label.SetAlign(ALIGN_LEFT,ALIGN_CENTER);
}
virtual void OnDraw()
{
CButtonCtrlTmpl<Tlabel,Tbase>::OnDraw();
}
};
template<class Tlabel=CLabel,class Tbase=CWndCtrl>
class CButtonTmpl : public CButtonCtrlTmpl<Tlabel,Tbase>
{
protected:
virtual void OnUpdatePos()
{
CButtonCtrlTmpl<Tlabel,Tbase>::OnUpdatePos();
m_Label.PosWnd(GetClAr());
}
public:
CButtonTmpl():CButtonCtrlTmpl<Tlabel,Tbase>()
{
SetLabel("Button");
}
virtual void OnDraw()
{
CButtonCtrlTmpl<Tlabel,Tbase>::OnDraw();
}
};
template<class Ttext=CText,class Tslider=CSlider, class Tbase=CWndCtrl>
class CTextBoxTmpl : public CTextBoxCtrlTmpl<Ttext,Tslider,Tbase>{};
template<class Tslider=CSlider,class Tbase=CWndCtrl>
class CPanelTmpl : public CPanelCtrlTmpl<Tslider,Tbase>{};
template<class Tslider=CSlider,class Tbase=CWndCtrl>
class CStackPanelTmpl: public CStackPanelCtrlTmpl<Tslider,Tbase>{};
template<class Tslider=CSlider,class Tbase=CWndCtrl>
class CSqueezePanelTmpl : public CSqueezePanelCtrlTmpl<Tslider,Tbase>{};
template<class Tbutton=CButton,class Tcaption=CLabel,class TclientPanel=CPanel, class TbuttonPanel=CStackPanel, class Tbase=CPlaneWnd>
class CDlgTmpl : public CDlgCtrlTmpl<Tbutton,Tcaption,TclientPanel,TbuttonPanel,Tbase>{};
typedef CLabelTmpl<> CLabel;
typedef CTextTmpl<> CText;
typedef CButtonTmpl<> CButton;
typedef CPlaneWndTmpl<> CPlaneWnd;
typedef CSliderTmpl<> CSlider;
typedef CTextBoxTmpl<> CTextBox;
typedef CEditTmpl<> CEdit;
typedef CPanelTmpl<> CPanel;
typedef CStackPanelTmpl<> CStackPanel;
typedef CSqueezePanelTmpl<> CSqueezePanel;
typedef CDlgTmpl<> CDlg;
typedef CCheckBoxTmpl<> CCheckBox;
}
}
namespace sjgui
{
namespace own_style
{
CWnd::CSize def_wnd_min_size(0,0);
GLfloat def_wnd_ctrl_border_light_color[4]={1.0f,1.0f,1.0f,1.0f};
GLfloat def_wnd_ctrl_border_dark_color[4]={0.3f,0.3f,0.3f,0.3f};
GLfloat def_wnd_ctrl_border_color[4]={1.0f,1.0f,1.0f,1.0f};
GLfloat def_wnd_ctrl_shadow_color[4]={0.3f,0.3f,0.3f,0.5f};
GLfloat def_wnd_ctrl_bg_color[4]={0.3f,0.5f,0.7f,1.0f};
GLfloat def_wnd_ctrl_bg_sel_color[4]={0.6f,0.5f,0.7f,1.0f};
CWnd::CSize def_button_size(100,30);
GLfloat def_dlg_caption_color[4] ={0.1f,0.9f,1.0f,1.0f};
GLfloat def_dlg_button_text_color[4]={0.1f,0.9f,1.0f,1.0f};
CWnd::CSize def_dlg_min_size(240,50);
int def_dlg_btn_dist =5;
int def_dlg_btn_offset =5;
int def_dlg_btn_panel_height =40;
GLfloat def_dlg_wnd_border_color[4] ={0.5f,0.5f,0.5f,1.0f};
GLfloat def_dlg_wnd_bg_color[4] ={0.1f,0.5f,0.5f,1.0f};
GLfloat def_dlg_wnd_bg_sel_color[4] ={0.11f,0.51f,0.51f,1.0f};
int def_edit_font_size =10;
int def_edit_blink_period =750;
CWnd::CSize def_edit_size(100,12);
GLfloat def_label_color[4] ={1.0f,1.0f,1.0f,1.0f};
CWnd::eAligns def_label_hor_aling =CWnd::ALIGN_CENTER;
CWnd::eAligns def_label_ver_aling =CWnd::ALIGN_CENTER;
CWnd::CSize def_slider_size(16,16);
float def_slider_length =0.2f;
CWnd::eOrient def_slider_orientation=CWnd::HORIZONTAL;
GLfloat def_text_color[4] ={1.0f,1.0f,1.0f,1.0f};
GLfloat def_text_box_text_color[4] ={0.8f,1.0f,0.8f,1.0f};
int def_text_box_fonst_size =12;
}
}
typedef CDlgTmpl<sjgui::CButton,sjgui::CLabel,sjgui::CSqueezePanel> CMyDlg;
class CTestDlg: public CMyDlg
{
sjgui::CEdit m_edt;
sjgui::CTextBox m_txb;
sjgui::CCheckBox m_chb;
public:
CTestDlg():CMyDlg()
{
RegisterToClientArea(&m_edt);
RegisterToClientArea(&m_txb);
RegisterToClientArea(&m_chb);
m_pnlClientArea.SetVertMode();
SetSize(200,200);
m_txb.SetSize(100,100);
m_txb.LoadTextFromFile("own_style.cpp");
m_txb.SetSelectLines();
}
};
class CSpcWnd : public sjgui::CWnd
{
CTestDlg m_dlg;
sjgui::CButton m_btn;
public:
CSpcWnd():CWnd(){RegisterChild(&m_btn);RegisterChild(&m_dlg);m_dlg.Show();}
virtual void OnReshape(){m_btn.ToCenter();m_dlg.ToCenter();}
virtual void OnKeyUp(int &iKey)
{
if(m_dlg.IsVisible() && !m_dlg.IsEnabled())
m_dlg.Reset();
if(m_btn.IsPushed())
{
m_btn.Reset();
m_dlg.Show(!m_dlg.IsVisible());
}
}
virtual void OnDraw()
{
Animate();
SET_GL_FOR_GUI_DRAW;
}
};
int main(int argc, char* argv[])
{
CSpcWnd SpcWnd;
SpcWnd.PosWnd(20,50,320,240);
if(sjgui::Create(argv[0],&SpcWnd))
{
sjgui::GlobalMainLoop();
}
else
printf("Could not create opengl window.\n");
return 0;
}