Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

pglineedit.h

Go to the documentation of this file.
00001 /*
00002     ParaGUI - crossplatform widgetset
00003     Copyright (C) 2000,2001,2002  Alexander Pipelka
00004  
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009  
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014  
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  
00019     Alexander Pipelka
00020     pipelka@teleweb.at
00021  
00022     Last Update:      $Author: mbickel $
00023     Update Date:      $Date: 2007-04-13 16:15:56 $
00024     Source File:      $Source: /home/cvspsrv/cvsroot/games/asc/source/libs/paragui/include/pglineedit.h,v $
00025     CVS/RCS Revision: $Revision: 1.2 $
00026     Status:           $State: Exp $
00027 */
00028 
00029 #ifndef PG_LINEEDIT
00030 #define PG_LINEEDIT
00031 
00032 #include "pgthemewidget.h"
00033 #include "pgsignals.h"
00034 #include "pgstring.h"
00035 
00052 class DECLSPEC PG_LineEdit : public PG_ThemeWidget {
00053 public:
00054 
00058         template<class datatype = PG_Pointer>
00059 class SignalEditBegin : public PG_Signal1<PG_LineEdit*, datatype> {}
00060         ;
00061         template<class datatype = PG_Pointer>
00062 class SignalEditEnd : public PG_Signal1<PG_LineEdit*, datatype> {}
00063         ;
00064         template<class datatype = PG_Pointer>
00065 class SignalEditReturn : public PG_Signal1<PG_LineEdit*, datatype> {}
00066         ;
00067    template<class datatype = PG_Pointer>
00068 class SignalEditUpdate : public PG_Signal1<PG_LineEdit*, datatype> {}
00069    ;
00070 
00072         PG_LineEdit(PG_Widget* parent, const PG_Rect& r = PG_Rect::null, const std::string& style="LineEdit", int maximumLength = 1000000);
00073 
00075         ~PG_LineEdit();
00076 
00077         void LoadThemeStyle(const std::string& widgettype);
00078 
00080         void LoadThemeStyle(const std::string& widgettype, const std::string& objectname);
00081 
00083         void EditBegin();
00084 
00086         void EditEnd();
00087 
00089         virtual void SetCursorPos(int p);
00090 
00092         int GetCursorPos();
00093 
00098         virtual void SetText(const std::string& new_text);
00099 
00101         bool IsCursorVisible();
00102 
00108         void SendChar(PG_Char c);
00109 
00113         void SendDel();
00114 
00118         void SendBackspace();
00119 
00125         void SetValidKeys(const std::string& keys);
00126 
00131         void SetEditable(bool edit);
00132 
00137         bool GetEditable();
00138 
00143         void SetPassHidden(const PG_Char& passchar);
00144 
00149         char GetPassHidden();
00150 
00151         bool Action(KeyAction action);
00152 
00153         SignalEditBegin<> sigEditBegin;
00154         SignalEditEnd<> sigEditEnd;
00155         SignalEditReturn<> sigEditReturn;
00156    SignalEditUpdate<> sigEditUpdate;
00157 
00158 
00159    
00163    static void SetBlinkingTime( int msec );
00164    
00165 protected:
00166 
00168         virtual void InsertChar(const PG_Char& c);
00169 
00171         virtual void DeleteChar(Uint16 pos);
00172 
00174         void CopyText(bool del = false);
00175 
00177         void PasteText(Uint16 pos);
00178 
00180         void StartMark(Uint16 pos);
00181 
00183         void EndMark(Uint16 pos);
00184 
00186         virtual bool eventFilterKey(const SDL_KeyboardEvent* key);
00187 
00189         virtual void eventEditBegin(int id, PG_Widget* widget, unsigned long data, void *clientdata);
00190 
00192         virtual void eventEditEnd(int id, PG_Widget* widget, unsigned long data, void *clientdata);
00193 
00195         void eventBlit(SDL_Surface* surface, const PG_Rect& src, const PG_Rect& dst);
00196 
00198         bool eventKeyDown(const SDL_KeyboardEvent* key);
00199 
00201         bool eventMouseButtonUp(const SDL_MouseButtonEvent* button);
00202 
00204         void eventInputFocusLost(PG_MessageObject* newfocus);
00205 
00206         void eventHide();
00207 
00208         int my_cursorPosition;
00209 
00210         SDL_Surface* my_srfTextCursor;
00211 
00212 private:
00213 
00214         PG_LineEdit(const PG_LineEdit&);
00215 
00216         PG_LineEdit& operator=(PG_LineEdit&);
00217 
00218         DLLLOCAL void DrawText(const PG_Rect& dst);
00219 
00220         DLLLOCAL void DrawTextCursor();
00221 
00222         DLLLOCAL Uint16 GetCursorXPos();
00223 
00224         DLLLOCAL PG_String GetDrawText();
00225 
00226         DLLLOCAL int GetCursorPosFromScreen(int x, int y);
00227 
00228         DLLLOCAL bool IsValidKey(PG_Char c);
00229 
00230    DLLLOCAL bool IdleBlinker();
00231 
00232    DLLLOCAL bool GetBlinkState();
00233    
00234 
00235         std::string my_buffer;
00236 
00237         int my_startMark;
00238 
00239         int my_endMark;
00240 
00241         bool my_isCursorVisible;
00242 
00243    bool my_cursorBlinkState;
00244 
00245         int my_offsetX;
00246 
00247         bool my_isEditable;
00248 
00249         int my_maximumLength;
00250 
00251         PG_String my_validkeys;
00252 
00253         PG_Char my_passchar;
00254 
00256    static int cursorBlinkingTime;
00257 };
00258 
00259 #endif // PG_LINEEDIT

Generated on Tue Jun 24 01:27:48 2008 for Advanced Strategic Command by  doxygen 1.4.2