# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

window_displayer.h

Go to the documentation of this file.
00001 
00008 /* Copyright, 2001 Nevrax Ltd.
00009  *
00010  * This file is part of NEVRAX NEL.
00011  * NEVRAX NEL is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2, or (at your option)
00014  * any later version.
00015 
00016  * NEVRAX NEL is distributed in the hope that it will be useful, but
00017  * WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00019  * General Public License for more details.
00020 
00021  * You should have received a copy of the GNU General Public License
00022  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00023  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00024  * MA 02111-1307, USA.
00025  */
00026 
00027 #ifndef NL_WINDOW_DISPLAYER_H
00028 #define NL_WINDOW_DISPLAYER_H
00029 
00030 #include "nel/misc/types_nl.h"
00031 
00032 #include "nel/misc/displayer.h"
00033 #include "nel/misc/mutex.h"
00034 #include "nel/misc/thread.h"
00035 
00036 namespace NLMISC {
00037 
00038 
00046 class CWindowDisplayer : public NLMISC::IDisplayer
00047 {
00048 public:
00049 
00050         CWindowDisplayer (const char *displayerName = "") :
00051           IDisplayer(displayerName), 
00052                 _Buffer("CWindowDisplayer::_Buffer"), _Labels("CWindowDisplayer::_Labels"), _CommandsToExecute("CWindowDisplayer::_CommandsToExecute"),
00053                 _Continue(true), _Init(false), _ToolBarHeight(22), _InputEditHeight(25), _Thread(NULL)
00054           { }
00055 
00056         virtual ~CWindowDisplayer ();
00057 
00058         // open the window and run the display thread (MT)
00059         void    create (std::string titleBar = "", bool iconified = false, sint x = -1, sint y = -1, sint w = -1, sint h = -1, sint hs = -1, sint fs = 0, const std::string &fn = "", bool ww = false);
00060 
00061         // create a new label. empty string mean separator. start with @ means that is a command (MT)
00062         uint    createLabel (const char *value = "?");
00063 
00064         // change the value of a label (MT)
00065         void    setLabel (uint label, const std::string &value);
00066 
00067         // execute user commands (MT) return false to quit
00068         bool    update ();
00069 
00070         // set a special title to the window bar
00071         virtual void    setTitleBar (const std::string &titleBar) { }
00072 
00073         virtual void    getWindowPos (uint32 &x, uint32 &y, uint32 &w, uint32 &h) { x=y=w=h=0; }
00074 
00075 protected:
00076 
00077         // display a string (MT)
00078         virtual void doDisplay (const NLMISC::TDisplayInfo &args, const char *message);
00079 
00080         // true for windows
00081         bool needSlashR;
00082 
00083         struct CLabelEntry
00084         {
00085                 CLabelEntry (const std::string &value) : Hwnd(NULL), Value(value), NeedUpdate(true) { }
00086                 void            *Hwnd;
00087                 std::string      Value;
00088                 bool             NeedUpdate;
00089         };
00090 
00091         // buffer that contains the text that the DT will have to display
00092         // uint32 is the color of the string
00093         CSynchronized<std::vector<std::pair<uint32, std::string> > >    _Buffer;
00094         CSynchronized<std::vector<CLabelEntry> >                                                _Labels;
00095         CSynchronized<std::vector<std::string> >                                                _CommandsToExecute;
00096 
00097         // called by DT only
00098         virtual void    open (std::string windowNameEx, bool iconified, sint x, sint y, sint w, sint h, sint hs, sint fs, const std::string &fn, bool ww) = 0;
00099         // called by DT only
00100         virtual void    display_main () = 0;
00101 
00102         // all these variables above is used only by the DT
00103 
00104         bool _Continue;
00105 
00106         std::vector<std::string>        _History;
00107         uint                                            _PosInHistory;
00108         bool _Init;
00109         sint _HistorySize;
00110         sint _ToolBarHeight;
00111         sint _InputEditHeight;
00112 
00113         // the thread used to update the display
00114         NLMISC::IThread *_Thread;
00115 
00116         friend class CUpdateThread;
00117 };
00118 
00119 } // NLMISC
00120 
00121 #endif // NL_WINDOW_DISPLAYER_H
00122 
00123 /* End of window_displayer.h */