Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

sjgui::CDlgCtrlTmpl< Tbutton, Tcaption, TclientPanel, TbuttonPanel, Tbase > Class Template Reference

Dialog window with Caption label,Ok and Cancel buttons. More...

#include <dlg.h>

Inheritance diagram for sjgui::CDlgCtrlTmpl< Tbutton, Tcaption, TclientPanel, TbuttonPanel, Tbase >:

sjgui::classic::CDlgTmpl< Tbutton, Tcaption, TclientPanel, TbuttonPanel, Tbase > sjgui::modern::CDlgTmpl< Tbutton, Tcaption, TclientPanel, TbuttonPanel, Tbase > List of all members.

Public Member Functions

virtual void Reshape ()
 Places controls.

virtual void OnComplete ()
 Event called by Ok or Cancel button.

virtual void KeyDown (int &iKey)
 Process TAB key.

virtual void KeyUp (int &iKey)
 Calls Complete() if Ok or Cancel were pressed.

void SetAutoHide (bool b=true)
 Set AutoHide flag.

bool IsAutoHide ()
 Report AutoHide flag.

void SetCaption (const char *str)
 Set caption text.

void SetCaptionColor (GLfloat R, GLfloat G, GLfloat B, GLfloat A=1.0f)
 Set caption color.

void SetCaptionColor (GLfloat *col)
 Set caption color.

const char * GetCaption ()
 Get caption text.

virtual void Reset ()
 Enables dialog and resets buttons.

bool IsOk ()
 Returns true if button Ok was pressed.

bool IsCancel ()
 Returns true if button Cancel was pressed.

virtual void OnShow ()
 Set focus to itself when shown.

void RegisterButton (CWnd *pWnd)
 Add control to the button area.

void UnRegisterButton (CWnd *pWnd)
 Remove control from the button area.

void RegisterToClientArea (CWnd *pWnd)
 Add control to the client area.

virtual void UnRegisterToClientArea (CWnd *pWnd)
 Remove control from the client area.

int GetClientAreaWidth ()
 Client area width.

int GetClientAreaHeight ()
 Client area height.

TclientPanel & GetClientArea ()
 Direct access to the client are class.

TbuttonPanel & GetButtonArea ()
 Direct access to button area.


Protected Member Functions

virtual void Complete ()
 Calls OnComplete if Ok or Cancel buttons were pressed.


Protected Attributes

Tcaption m_Caption
 Caption label.

Tbutton m_btnOk
 Ok button.

Tbutton m_btnCancel
 Cancel button.

TbuttonPanel m_pnlButtons
 Button ordering panel.

TclientPanel m_pnlClientArea
 Client Area.


Detailed Description

template<class Tbutton, class Tcaption, class TclientPanel, class TbuttonPanel, class Tbase>
class sjgui::CDlgCtrlTmpl< Tbutton, Tcaption, TclientPanel, TbuttonPanel, Tbase >

Dialog window with Caption label,Ok and Cancel buttons.

Dialog window with Ok and Cancel buttons positioned at the lower-right corner of the window.

Parameters:
Tbutton - button class
Tcaption - label for caption
TclientPanel - panel for client area (use CPanelTmpl<>)
TbuttonPanel - panel for button area (use CStackPanelTmpl<>)
Tbase - base class (use CDlgWndTmpl<>)
There is a notation of client area for the dialog, which is all controls added to the dialog are placed in a panel, which takes space between caption and buttons. If you want to add a control next to the button, use RegisterButton() function instead of RegisterChild(). Controls added by RegisterToClientArea() are limitted by the client area of the dialog, i.e. parts outside it will not be shown. If you have another dialog for example, which is child of this one and you want it to be able to move anywhere, then you should use RegisterChild(). If control does not fit the client you can get access to the client area panel, and modify its parameters to eable scrollbars for example. But it depends on how template was instantiated. Events from the pushed button call OnComplete() function, which can be overwritten by child classes. Flag AutomaticHide is used to make simple dialogs, which will be closed, when you click Ok or Cancel button, so the only function you would use is OnComplete(). If AutomaticHide is not set it is your responsibility to reset buttons state. Consider an example of dialog which asks for some text:
class CCustomTextDlg: public sjgui::CDlg
{
    sjgui::CEdit    m_edt; // edit field
    sjgui::CLabel   m_lbl; // label with the hint
public:
    // This string will have the result of user interaction 
    // and it could be accessed by calling class
    std::string m_str;
    CCustomTextDlg()
    {
        sjgui::CDlg();
        SetAutoHide();              // Set autohide option 
        SetCaption("Text Dialog!"); // Change caption
        SetMinSize(200,100);        // Minimum size of the dialog
        SetSize(250,80);            // Default size
        RegisterChild(&m_lbl);      // Register label
        RegisterChild(&m_edt);      // Register edit field
        m_edt.SetText("sjgui");     // New text for edit field
        m_lbl.SetText("New Text:"); // Text for hint
    }
    // Place edit field in a proper position
    virtual void OnReshape()
    {
        // it should be under the caption
        m_lbl.PosWnd(5,m_Caption.GetBottom()+1,GetWidth()-10,m_edt.GetHeight());
        // it should be under the label
        m_edt.PosWnd(5,m_lbl.GetBottom()+1,GetWidth()-10,m_edt.GetHeight());
    }
    // React on closing the window, if it was Ok pressed then change the text
    virtual void OnComplete(){if(m_btnOk.IsPushed())m_str=m_edt.GetText();}
}; // end of CCustomTextDlgManual
See also:
lesson6
Note:
You can place some time consuming processing into your OnComplete() function, and user can press buttons a couple of times. That is why dialog is disabled before calling OnComplete(), this means, that you should call reset before showing window if you do not call Reset() within OnComplete().
Class is made as a template so your application can use its functionality, with different kind of buttons and labels (For instance button with sound effects).
Author:
Alexander Shyrokov
Version:
Revision
1.1.1.1


Member Function Documentation

template<class Tbutton, class Tcaption, class TclientPanel, class TbuttonPanel, class Tbase>
void sjgui::CDlgCtrlTmpl< Tbutton, Tcaption, TclientPanel, TbuttonPanel, Tbase >::Complete  )  [inline, protected, virtual]
 

Calls OnComplete if Ok or Cancel buttons were pressed.

One should override this function to put their actions inside, if they want some fancy behavior.

See also:
OnComplete

template<class Tbutton, class Tcaption, class TclientPanel, class TbuttonPanel, class Tbase>
void sjgui::CDlgCtrlTmpl< Tbutton, Tcaption, TclientPanel, TbuttonPanel, Tbase >::KeyUp int &  iKey  )  [inline, virtual]
 

Calls Complete() if Ok or Cancel were pressed.

ESC button is a shortcut for Cancel button.

template<class Tbutton, class Tcaption, class TclientPanel, class TbuttonPanel, class Tbase>
void sjgui::CDlgCtrlTmpl< Tbutton, Tcaption, TclientPanel, TbuttonPanel, Tbase >::Reshape  )  [inline, virtual]
 

Places controls.

One should override this function to do anything if Ok or Cancel button were pressed.


The documentation for this class was generated from the following file:
sjgui logo
Quick Links:

 News
 Description
 Screen Shots
 Projects
 Downloads
 Source Code
 Help/FAQ
 Want to help?
 Credits
 Disclaimer


Documentation:

 Documentation
 Reference
 Lessons


Useful links:

sjcomp logo
sjcomp

opengl logo

nehe logo

SourceForge.net Logo

Last modified:


Started by Alexander Shyrokov. Generated at Wed Apr 28 12:31:05 2004 for the sjgui by doxygen 1.3.1. SourceForge.net Logo