00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2010 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef CBaseGUIWindow_H 00029 #define CBaseGUIWindow_H 00030 00031 #include <mrpt/synch.h> 00032 #include <mrpt/utils/CSerializable.h> 00033 #include <mrpt/utils/safe_pointers.h> 00034 #include <mrpt/gui/keycodes.h> 00035 00036 namespace mrpt 00037 { 00038 namespace gui 00039 { 00040 using namespace mrpt::utils; 00041 00042 class CWindowDialog; 00043 class CWindowDialogPlots; 00044 class C3DWindowDialog; 00045 00046 /** The base class for GUI window classes. 00047 */ 00048 class MRPTDLLIMPEXP CBaseGUIWindow 00049 { 00050 friend class CWindowDialog; 00051 friend class C3DWindowDialog; 00052 friend class CWindowDialogPlots; 00053 00054 private: 00055 const int m_CMD_CREATE_WIN; //!< can be 200,300,400... See WxSubsystem 00056 const int m_CMD_DESTROY_WIN; //!< can be 299,399,499... See WxSubsystem 00057 void* m_winobj_voidptr; 00058 00059 protected: 00060 synch::CSemaphore m_semThreadReady; //!< This semaphore will be signaled when the wx window is built and ready. 00061 synch::CSemaphore m_semWindowDestroyed; //!< This semaphore will be signaled when the wx window is destroyed. 00062 std::string m_caption; //!< The caption of the window 00063 void_ptr_noncopy m_hwnd; //!< The window handle 00064 00065 /* Auxiliary */ 00066 volatile bool m_keyPushed; 00067 volatile int m_keyPushedCode; 00068 volatile mrptKeyModifier m_keyPushedModifier; 00069 00070 void createWxWindow(unsigned int initialWidth, unsigned int initialHeight); //!< Must be called by child classes just within the constructor. 00071 00072 public: 00073 void * getWxObject() { return m_hwnd.get(); } //!< Read-only access to the wxDialog object. 00074 void notifyChildWindowDestruction(); //!< Called by wx main thread to set m_hwnd to NULL. 00075 void notifySemThreadReady(); //!< Called by wx main thread to signal the semaphore that the wx window is built and ready. 00076 00077 public: 00078 /** CMD_DESTROY_WIN can be 299,399,499... See WxSubsystem */ 00079 CBaseGUIWindow(void* winobj_voidptr, int CMD_CREATE_WIN, int CMD_DESTROY_WIN, const std::string &initial_caption = std::string() ); 00080 virtual ~CBaseGUIWindow(); 00081 00082 /** Returns false if the user has already closed the window. 00083 */ 00084 bool isOpen(); 00085 00086 /** Resizes the window, stretching the image to fit into the display area. 00087 */ 00088 virtual void resize( unsigned int width, unsigned int height ) = 0; 00089 00090 /** Changes the position of the window on the screen. 00091 */ 00092 virtual void setPos( int x, int y ) = 0; 00093 00094 /** Changes the window title text. 00095 */ 00096 virtual void setWindowTitle( const std::string &str )=0; 00097 00098 /** Waits for any key to be pushed on the image or the console, and returns the key code. 00099 * This method remove key strokes previous to its call, so it will always wait. To get 00100 * the latest pushed key, see 00101 * 00102 * \param ignoreControlKeys If set to false, any push of shift, cmd, control, etc... will make this method to return. 00103 * \param out_pushModifier If set to !=NULL, the modifiers of the key stroke will be saved here. 00104 * \return The virtual key code, as defined in mrptKeyCode (a replication of wxWidgets key codes). 00105 * 00106 * \sa getPushedKey, Key codes in the enum mrptKeyCode 00107 */ 00108 int waitForKey(bool ignoreControlKeys = true, mrptKeyModifier *out_pushModifier=NULL); 00109 00110 /** Returns true if a key has been pushed, without blocking waiting for a new key being pushed. 00111 * \sa waitForKey, clearKeyHitFlag 00112 */ 00113 bool keyHit() const { return m_keyPushed; } 00114 00115 /** Assure that "keyHit" will return false until the next pushed key. 00116 * \sa keyHit, waitForKey 00117 */ 00118 void clearKeyHitFlag() { m_keyPushed = false; } 00119 00120 /** Returns the latest pushed key, or 0 if there is no new key stroke. 00121 * \param out_pushModifier If set to !=NULL, the modifiers of the key stroke will be saved here. 00122 * \return The virtual key code, as defined in mrptKeyCode (a replication of wxWidgets key codes). 00123 * 00124 * \sa keyHit, waitForKey 00125 */ 00126 int getPushedKey(mrptKeyModifier *out_pushModifier=NULL); 00127 00128 00129 }; // End of class def. 00130 00131 } // End of namespace 00132 00133 } // End of namespace 00134 00135 #endif
| Page generated by Doxygen 1.7.1 for MRPT 0.8.1 SVN:exported at Sun Sep 19 14:53:45 UTC 2010 |
