uMenuItemString Class Reference

#include <uMenu.h>

Inheritance diagram for uMenuItemString:

Inheritance graph
[legend]
Collaboration diagram for uMenuItemString:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 uMenuItemString (uMenu *M, const tOutput &desc, const tOutput &help, tString &c, int maxLength=1024)
virtual ~uMenuItemString ()
virtual void Render (REAL x, REAL y, REAL alpha=1, bool selected=0)
virtual bool Event (SDL_Event &e)
uMenuMyMenu ()
void SetColorMode (rTextField::ColorMode colorMode)
rTextField::ColorMode GetColorMode () const

Protected Attributes

tOutput description
tStringcontent
int cursorPos
int maxLength_
rTextField::ColorMode colorMode_


Detailed Description

Definition at line 378 of file uMenu.h.


Constructor & Destructor Documentation

uMenuItemString::uMenuItemString ( uMenu M,
const tOutput desc,
const tOutput help,
tString c,
int  maxLength = 1024 
)

Definition at line 684 of file uMenu.cpp.

References rTextField::COLOR_SHOW, colorMode_, content, cursorPos, and tString::Len().

Referenced by sg_PlayerMenu().

00690         :uMenuItem(M,help),description(de),content(&c),cursorPos(0), maxLength_( maxLength ){
00691     // int len=content->Len();
00692     // if (len==0 || (*content)(len-1)!=0)
00693     //    (*content)[len]=0;
00694     cursorPos=content->Len()-1;
00695     colorMode_ = rTextField::COLOR_SHOW;

Here is the call graph for this function:

Here is the caller graph for this function:

virtual uMenuItemString::~uMenuItemString (  )  [inline, virtual]

Definition at line 390 of file uMenu.h.

00390 {}


Member Function Documentation

void uMenuItemString::Render ( REAL  x,
REAL  y,
REAL  alpha = 1,
bool  selected = 0 
) [virtual]

Reimplemented from uMenuItem.

Reimplemented in eMenuItemPassword, and uMenuItemStringWithHistory.

Definition at line 697 of file uMenu.cpp.

References rTextField::COLOR_SHOW, rTextField::COLOR_USE, colorMode_, content, cursorPos, description, and uMenuItem::DisplayText().

Referenced by eMenuItemPassword::Render().

00699                                                       {
00700 #ifndef DEDICATED
00701     static int counter=0;
00702     counter++;
00703 
00704     int cmode=0;
00705     if (selected){
00706         cmode=1;
00707         if (counter & 32) cmode=2;
00708     }
00709 
00710     // unslected items with COLOR_SHOW should be rendered with COLOR_USE
00711     rTextField::ColorMode colorMode = colorMode_;
00712     if ( colorMode == rTextField::COLOR_SHOW && !selected )
00713         colorMode = rTextField::COLOR_USE;
00714 
00715     DisplayText(x-.02,y,description,selected,alpha,1);
00716     DisplayText(x+.02,y,*content,selected,alpha,-1,cmode,cursorPos,colorMode);
00717 #endif

Here is the call graph for this function:

Here is the caller graph for this function:

bool uMenuItemString::Event ( SDL_Event &  e  )  [virtual]

Reimplemented from uMenuItem.

Reimplemented in eMenuItemUserName, eMenuItemPassword, eMenuItemChat, gMemuItemConsole, and uMenuItemStringWithHistory.

Definition at line 719 of file uMenu.cpp.

References c, content, cursorPos, tString::Len(), maxLength_, tString::PosWordLeft(), tString::PosWordRight(), tString::RemoveSubStr(), tString::RemoveWordLeft(), tString::RemoveWordRight(), and tString::SubStr().

Referenced by eMenuItemPassword::Event(), and eMenuItemUserName::Event().

00720                                        {
00721 #ifndef DEDICATED
00722     if (e.type!=SDL_KEYDOWN)
00723         return false;
00724     bool ret=true;
00725     SDL_keysym &c=e.key.keysym;
00726     SDLMod mod = c.mod;
00727     bool moveWordLeft, moveWordRight, deleteWordLeft, deleteWordRight, moveBeginning, moveEnd, killForwards;
00728     moveWordLeft = moveWordRight = deleteWordLeft = deleteWordRight = moveBeginning = moveEnd = killForwards = false;
00729 
00730 #if defined (MACOSX)
00731     // For moving over/deleting words
00732     if (mod & KMOD_ALT) {
00733         if (c.sym == SDLK_LEFT) {
00734             moveWordLeft = true;
00735         }
00736         else if (c.sym == SDLK_RIGHT) {
00737             moveWordRight = true;
00738         }
00739         else if (c.sym == SDLK_DELETE) {
00740             deleteWordRight = true;
00741         }
00742         else if (c.sym == SDLK_BACKSPACE) {
00743             deleteWordLeft = true;
00744         }
00745     }
00746     // For moving to extremes of the line
00747     else if (mod & KMOD_META) {
00748         if (c.sym == SDLK_LEFT) {
00749             moveBeginning = true;
00750         }
00751         else if (c.sym == SDLK_RIGHT) {
00752             moveEnd = true;
00753         }
00754     }
00755     // Linux and Windows
00756 #else
00757     // Word operations
00758     if (mod & KMOD_CTRL) {
00759         if (c.sym == SDLK_LEFT) {
00760             moveWordLeft = true;
00761         }
00762         else if (c.sym == SDLK_RIGHT) {
00763             moveWordRight = true;
00764         }
00765         else if (c.sym == SDLK_DELETE) {
00766             deleteWordRight = true;
00767         }
00768         else if (c.sym == SDLK_BACKSPACE) {
00769             deleteWordLeft = true;
00770         }
00771     }
00772     else if (c.sym == SDLK_HOME) {
00773         moveBeginning = true;
00774     }
00775     else if (c.sym == SDLK_END) {
00776         moveEnd = true;
00777     }
00778 #endif
00779     // "bash" keys
00780     if (mod & KMOD_CTRL) {
00781         if (c.sym == SDLK_a) {
00782             moveBeginning = true;
00783         }
00784         else if (c.sym == SDLK_e) {
00785             moveEnd = true;
00786         }
00787         else if (c.sym == SDLK_k) {
00788             killForwards = true;
00789         }
00790     }
00791     // moveWordLeft = moveWordRight = deleteWordLeft = deleteWordRight = moveBeginning = moveEnd = killForwards
00792 
00793     if (moveWordLeft) {
00794         cursorPos += content->PosWordLeft(cursorPos);
00795     }
00796     else if (moveWordRight) {
00797         cursorPos += content->PosWordRight(cursorPos);
00798     }
00799     else if (deleteWordLeft) {
00800         cursorPos += content->RemoveWordLeft(cursorPos);
00801     }
00802     else if (deleteWordRight) {
00803         content->RemoveWordRight(cursorPos);
00804     }
00805     else if (moveBeginning) {
00806         cursorPos = 0;
00807     }
00808     else if (moveEnd) {
00809         cursorPos = content->Len()-1;
00810     }
00811     else if (killForwards) {
00812         content->RemoveSubStr(cursorPos,content->Len()-1-cursorPos);
00813     }
00814     else if (c.sym == SDLK_LEFT) {
00815         if (cursorPos > 0) {
00816             cursorPos--;
00817         }
00818     }
00819     else if (c.sym == SDLK_RIGHT) {
00820         if (cursorPos < content->Len()-1) {
00821             cursorPos++;
00822         }
00823     }
00824     else if (c.sym == SDLK_DELETE) {
00825         if (cursorPos < content->Len()-1) {
00826             content->RemoveSubStr(cursorPos,1);
00827         }
00828     }
00829     else if (c.sym == SDLK_BACKSPACE) {
00830         if (cursorPos > 0) {
00831             content->RemoveSubStr(cursorPos,-1);
00832             cursorPos--;
00833         }
00834     }
00835     else if (c.sym == SDLK_KP_ENTER || c.sym == SDLK_RETURN) {
00836         ret = false;
00837         //        c.sym = SDLK_DOWN;
00838     }
00839     else {
00840         if (32 <= c.unicode  && c.unicode < 256)
00841         {
00842             ret=true;
00843 
00844             // insert character if there is room
00845             if (content->Len() < maxLength_)
00846             {
00847                 tString beg = content->SubStr(0,cursorPos);
00848                 tString end = content->SubStr(cursorPos);
00849                 *content = beg;
00850                 *content += tString::CHAR(c.unicode);
00851                 *content += end;
00852                 cursorPos++;
00853             }
00854         }
00855         else {
00856             ret=false;
00857         }
00858     }
00859 
00860     if (cursorPos<0)    cursorPos=0;
00861     if (cursorPos > content->Len()-1) cursorPos=content->Len()-1;
00862 
00863     return ret;
00864 #else
00865     return false;

Here is the call graph for this function:

Here is the caller graph for this function:

uMenu* uMenuItemString::MyMenu (  )  [inline]

Definition at line 396 of file uMenu.h.

References uMenuItem::menu.

Referenced by gMemuItemConsole::Event().

00396 {return menu;}

Here is the caller graph for this function:

void uMenuItemString::SetColorMode ( rTextField::ColorMode  colorMode  )  [inline]

Definition at line 398 of file uMenu.h.

References colorMode_.

Referenced by PasswordCallback(), and sg_PlayerMenu().

00399     {
00400         colorMode_ = colorMode;
00401     }

Here is the caller graph for this function:

rTextField::ColorMode uMenuItemString::GetColorMode (  )  const [inline]

Definition at line 403 of file uMenu.h.

References colorMode_.

00404     {
00405         return colorMode_;
00406     }


Member Data Documentation

tOutput uMenuItemString::description [protected]

Definition at line 380 of file uMenu.h.

Referenced by Render().

tString* uMenuItemString::content [protected]

Definition at line 381 of file uMenu.h.

Referenced by Event(), gMemuItemConsole::Event(), Render(), uMenuItemString(), and uMenuItemStringWithHistory::~uMenuItemStringWithHistory().

int uMenuItemString::cursorPos [protected]

Definition at line 382 of file uMenu.h.

Referenced by Event(), Render(), and uMenuItemString().

int uMenuItemString::maxLength_ [protected]

Definition at line 383 of file uMenu.h.

Referenced by Event().

rTextField::ColorMode uMenuItemString::colorMode_ [protected]

Definition at line 386 of file uMenu.h.

Referenced by GetColorMode(), Render(), SetColorMode(), and uMenuItemString().


The documentation for this class was generated from the following files:
Generated on Sun Mar 16 00:01:18 2008 for Armagetron Advanced by  doxygen 1.5.4