Back to index

extremetuxracer  0.5beta
Public Member Functions | Public Attributes | Protected Attributes | Private Attributes
KeyEntry Class Reference

#include <keyboardconfig.h>

Inheritance diagram for KeyEntry:
Inheritance graph
[legend]
Collaboration diagram for KeyEntry:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 KeyEntry (pp::Vec2d pos, pp::Vec2d size, const char *binding, const char *content="")
 ~KeyEntry ()
void setKeySym (SDLKey keysym)
SDLKey getKeySym ()
void setMaxChars (unsigned int maxchars)
void draw ()
bool keyboardEvent (SDLKey key, SDLMod mod, bool release)
void setContent (std::string string)
std::string & getContent ()
void setEditable (bool editable)
void setSensitive (bool sensitive)
bool getSensitive ()
void setVisible (bool visible)
void setActive (bool active)
void setPosition (pp::Vec2d pos)
bool isInBox (const int x, const int y) const
void mouseDown (int button, int x, int y)
void mouseUp (int button, int x, int y)
void mouseMotion (int x, int y)
void removeFocus ()
void setFocus (bool focus=true)
bool hasFocus ()
void simulateMouseClick ()
double getWidth () const
double getHeight () const

Public Attributes

pp::Signal2< pp::Entry *, SDLKey > signalKeyPressed
pp::Signal0 signalClicked
pp::Alignment alignment
 the alignment of the widgets.

Protected Attributes

pp::Vec2d m_position
pp::Vec2d m_size
bool m_clicked
 is the box currently pushed down?
bool m_focused
 is the mouse pointer currently in the box?
bool m_sensitive
 is the widget sensitive (click event and font)
bool m_visible
 is the box being drawn by the UI manager?
bool m_active
 is the box receiving mouse events?
bool m_hasFocus

Private Attributes

SDLKey keysym

Detailed Description

Definition at line 32 of file keyboardconfig.h.


Constructor & Destructor Documentation

KeyEntry::KeyEntry ( pp::Vec2d  pos,
pp::Vec2d  size,
const char *  binding,
const char *  content = "" 
)

Definition at line 31 of file keyboardconfig.cpp.

                                                                                      : pp::Entry(pos, size, binding, content)
{
keysym = SDLK_BACKSPACE; //Well, just to reserve the memory
}

Definition at line 36 of file keyboardconfig.cpp.

{
}

Member Function Documentation

void pp::Entry::draw ( ) [virtual, inherited]
std::string & pp::Entry::getContent ( ) [inherited]

Definition at line 84 of file entry.cpp.

{
       return m_content;
}

Here is the caller graph for this function:

double pp::Widget::getHeight ( ) const [inline, inherited]

Definition at line 84 of file widget.h.

{return m_size.y;};

Here is the caller graph for this function:

SDLKey KeyEntry::getKeySym ( )

Definition at line 45 of file keyboardconfig.cpp.

{
return keysym;
}

Here is the caller graph for this function:

bool pp::Widget::getSensitive ( ) [inline, inherited]

Definition at line 63 of file widget.h.

{ return m_sensitive; };

Here is the caller graph for this function:

double pp::Widget::getWidth ( ) const [inline, inherited]

Definition at line 83 of file widget.h.

{return m_size.x;};

Here is the caller graph for this function:

bool pp::Widget::hasFocus ( ) [inline, inherited]

Definition at line 77 of file widget.h.

{return m_hasFocus;};

Here is the caller graph for this function:

bool pp::Widget::isInBox ( const int  x,
const int  y 
) const [inherited]

Definition at line 96 of file widget.cpp.

{
    return (bool) (
       ( x >= m_position.x ) &&
       ( x <= m_position.x + m_size.x ) &&
       ( y >= m_position.y ) &&
       ( y <= m_position.y + m_size.y ) );
}

Here is the caller graph for this function:

bool pp::Entry::keyboardEvent ( SDLKey  key,
SDLMod  mod,
bool  release 
) [virtual, inherited]

Reimplemented from pp::Widget.

Definition at line 92 of file entry.cpp.

{
       if(!release){
              if(m_editable){
                     if( islower(key) ){
                            if(m_content.size()<m_maxchars){
                                   if(mod & KMOD_SHIFT){
                                          m_content+=toupper(key);
                                   }else{
                                          m_content+=key;
                                   }
                            }
                     }else if( isdigit(key) ){
                            if(m_content.size()<m_maxchars){
                                   m_content+=key;
                            }
                     }else if( key == SDLK_BACKSPACE){
                            if(!m_content.empty()){
                                   std::string::iterator it = m_content.end();
                                   it--;
                                   m_content.erase(it); 
                                   //i'm stupid... or g++-2.95?
                                   //content.erase( --m_content.end() );
                            }
                     }
              }else{
                     signalKeyPressed.Emit(this,key);
              }
       }
       return true;
}

Here is the call graph for this function:

void pp::Widget::mouseDown ( int  button,
int  x,
int  y 
) [inherited]

Definition at line 127 of file widget.cpp.

{
    if ( button != SDL_BUTTON_LEFT ) {
              return;
    }

    if ( !isInBox(x, y) ) {
              return;
    }

    if ( !m_sensitive ) {
              return;
    }

    if ( m_clicked == false ) {
              print_debug( DEBUG_UI, "Button is down" );
              m_clicked = true;
              UIMgr.setDirty();
    }
}

Here is the call graph for this function:

void pp::Widget::mouseMotion ( int  x,
int  y 
) [inherited]

Definition at line 106 of file widget.cpp.

{
    if ( !m_sensitive ) {
              return;
    }

    if ( isInBox(x, y) ) {
              if ( m_focused == false ) {
                     print_debug( DEBUG_UI, "Mouse entered button" );
                  m_focused = true;
                  UIMgr.setDirty();
              }
    } else {
              if ( m_focused == true ) {
                     print_debug( DEBUG_UI, "Mouse left button" );
                  m_focused = false;
                  UIMgr.setDirty();
              }
    }
}

Here is the call graph for this function:

void pp::Widget::mouseUp ( int  button,
int  x,
int  y 
) [inherited]

Definition at line 149 of file widget.cpp.

{
       if ( button != SDL_BUTTON_LEFT ) {
              return;
       }

    if ( !m_sensitive ) {
              return;
    }

    if ( !isInBox(x, y) ) {
              if ( m_clicked ) {
                  print_debug( DEBUG_UI, "Button is up (not clicked)" );
                  m_clicked = false;
                  UIMgr.setDirty();
              }
              return;
    } 

    if ( m_clicked ) {
              m_clicked = false;
              print_debug( DEBUG_UI, "Button was clicked" );
              performClickAction();
              UIMgr.setDirty();
    }
}

Here is the call graph for this function:

void pp::Widget::removeFocus ( ) [inherited]

Definition at line 183 of file widget.cpp.

{
       m_hasFocus=false;
}

Here is the caller graph for this function:

void pp::Widget::setActive ( bool  active) [inherited]

Definition at line 73 of file widget.cpp.

{
    if ( !m_active && active ) {
              UIMgr.setDirty();
    } else if ( m_active && !active ) {
              UIMgr.setDirty();
    }

    m_active = active;

    if ( !active ) {
              setVisible( false );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pp::Entry::setContent ( std::string  string) [inherited]

Definition at line 78 of file entry.cpp.

{
       m_content = string;
}

Here is the caller graph for this function:

void pp::Entry::setEditable ( bool  editable) [inline, inherited]

Definition at line 51 of file entry.h.

{m_editable=editable;};

Here is the caller graph for this function:

void pp::Widget::setFocus ( bool  focus = true) [inherited]

Definition at line 189 of file widget.cpp.

{
       if(focus!=m_hasFocus){
              UIMgr.grabFocus(this,focus);
              m_hasFocus=focus;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KeyEntry::setKeySym ( SDLKey  keysym)

Definition at line 40 of file keyboardconfig.cpp.

{
keysym = key;
}

Here is the caller graph for this function:

void pp::Entry::setMaxChars ( unsigned int  maxchars) [inherited]

Definition at line 46 of file entry.cpp.

{
       m_maxchars = MAX(1,maxchars);      
}

Here is the caller graph for this function:

void pp::Widget::setPosition ( pp::Vec2d  pos) [inline, inherited]
void pp::Widget::setSensitive ( bool  sensitive) [inherited]

Reimplemented in pp::Listbox< T >, pp::Listbox< multisample_t >, pp::Listbox< bpp_t >, pp::Listbox< button_t >, pp::Listbox< bps_t >, pp::Listbox< CourseData >, pp::Listbox< resolution_t >, pp::Listbox< model_t >, pp::Listbox< freq_t >, pp::Listbox< CupData >, pp::Listbox< HighscoreData >, and pp::Listbox< EventData >.

Definition at line 42 of file widget.cpp.

{
       if ( m_sensitive != sensitive ) {
              UIMgr.setDirty();
    }

    m_sensitive = sensitive;

    if ( !m_sensitive ) {
              m_clicked = false;
              m_focused = false;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pp::Widget::setVisible ( bool  visible) [inherited]

Definition at line 57 of file widget.cpp.

{
    /* This check is necessary to prevent infinite mutual recursion */
    if ( m_active != visible ) {
              setActive( visible );
    }

    if ( !m_visible && visible ) {
              UIMgr.setDirty();
    } else if ( m_visible && !visible ) {
              UIMgr.setDirty();
    }
    m_visible = visible;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pp::Widget::simulateMouseClick ( ) [inherited]

Definition at line 177 of file widget.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

the alignment of the widgets.

Definition at line 90 of file widget.h.

SDLKey KeyEntry::keysym [private]

Definition at line 34 of file keyboardconfig.h.

bool pp::Widget::m_active [protected, inherited]

is the box receiving mouse events?

Definition at line 52 of file widget.h.

bool pp::Widget::m_clicked [protected, inherited]

is the box currently pushed down?

Definition at line 40 of file widget.h.

bool pp::Widget::m_focused [protected, inherited]

is the mouse pointer currently in the box?

Definition at line 43 of file widget.h.

bool pp::Widget::m_hasFocus [protected, inherited]

Definition at line 54 of file widget.h.

pp::Vec2d pp::Widget::m_position [protected, inherited]

Definition at line 36 of file widget.h.

bool pp::Widget::m_sensitive [protected, inherited]

is the widget sensitive (click event and font)

Definition at line 46 of file widget.h.

pp::Vec2d pp::Widget::m_size [protected, inherited]

Definition at line 37 of file widget.h.

bool pp::Widget::m_visible [protected, inherited]

is the box being drawn by the UI manager?

Definition at line 49 of file widget.h.

Definition at line 84 of file widget.h.

Definition at line 51 of file entry.h.


The documentation for this class was generated from the following files: