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

sjgui::CButtonCtrlTmpl< Tlabel, Tbase > Class Template Reference

Button, checkbox, multiple state button, with the text. More...

#include <button.h>

Inheritance diagram for sjgui::CButtonCtrlTmpl< Tlabel, Tbase >:

sjgui::classic::CButtonTmpl< Tlabel, Tbase > sjgui::classic::CCheckBoxTmpl< Tlabel, Tbase > sjgui::modern::CButtonTmpl< Tlabel, Tbase > sjgui::modern::CCheckBoxTmpl< Tlabel, Tbase > List of all members.

Public Member Functions

virtual void OnKeyUp (int &iKey)
 Sets flags.

virtual void OnKeyDown (int &iKey)
 Sets m_yPressed flag.

void SetNumStates (int i)
 Set number of states, at least 1.

int GetNumStates ()
 Get number of states.

int GetState ()
 Get current state.

bool IsChecked ()
 Returns true if checked.

void GoToNextState ()
 Go to next state.

void SetChecked (bool b=true)
 Set checked flag.

void SetTextColor (GLfloat R, GLfloat G, GLfloat B)
 Set color of the text.

void SetTextColor (GLfloat *pC)
 Set color of the text.

GLfloat * GetTextColor ()
 Get color of the text.

void SetLabel (const char *pc)
 Set text of the label.

int GetTextLen ()
 Number of characters in the text.

int GetFontSize ()
 Font size.

virtual void OnReset ()
 Resets m_yPushed flag.

bool IsPushed ()
 Returns true if button was pushed.

void PushIt (bool b=true)
 Set/Clear pushed flag.

Tlabel & GetLabel ()
 Get label object directly.


Protected Attributes

bool m_yPushed
 Is true when button was pushed.

Tlabel m_Label
 Label.

int m_iNumStates
 Number of states.

int m_iState
 Current state.

bool m_yChecked
 Checked state.


Detailed Description

template<class Tlabel, class Tbase>
class sjgui::CButtonCtrlTmpl< Tlabel, Tbase >

Button, checkbox, multiple state button, with the text.

Parameters:
Tlabel - label class used for displaying label (use CLabelCtrlTmpl)
Tbase - base class (use CWndCtrlBase) It can serve as push button, as check box, as multiple state button. with the text label. When button was pressed, function IsPushed() returns true, then IsPushed() will return true, unless you reset the button state with Reset(). Button could be pressed when it is in focus by LEFT MOUSE BUTTON, SPACE or ENTER keys. Usual usage is in the OnKeyUp(iKey) function. The following is an example of ussage as a push button:
 // class with a button
 class CYourClass: public sjgui::CWnd
 {
    sjgui::CButton  m_btnOk;
 public:
    // one should register child in constructor
    CYourClass(){RegisterChild(&m_btnOk);}
    // in this function one process the event
    virtual void OnKeyUp(int& iKey)
    {
        if(m_btnOk.IsPushed())
        {
            m_btnOk.Reset(); // important to call this
            // ... do what you want to do
        }
    }
 }
IsChecked() acts like it is a check box (it is negated on each click) GetState() returns state of the button (sequentially changing on each click) number of states is set by SetNumStates().
See also:
CLabel,lesson6
Author:
Alexander Shyrokov
Version:
Revision
1.1.1.1


Member Function Documentation

template<class Tlabel, class Tbase>
bool sjgui::CButtonCtrlTmpl< Tlabel, Tbase >::IsPushed  )  [inline]
 

Returns true if button was pushed.

Do not forget to reset the button with Reset() command.


Member Data Documentation

template<class Tlabel, class Tbase>
Tlabel sjgui::CButtonCtrlTmpl< Tlabel, Tbase >::m_Label [protected]
 

Label.

Must be positioned in the derived class.


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