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 protected: 00055 synch::CSemaphore m_semThreadReady; //!< This semaphore will be signaled when the wx window is built and ready. 00056 synch::CSemaphore m_semWindowDestroyed; //!< This semaphore will be signaled when the wx window is destroyed. 00057 std::string m_caption; //!< The caption of the window 00058 void_ptr_noncopy m_hwnd; //!< The window handle 00059 00060 /* Auxiliary */ 00061 volatile bool m_keyPushed; 00062 volatile int m_keyPushedCode; 00063 volatile mrptKeyModifier m_keyPushedModifier; 00064 00065 public: 00066 void * getWxObject() { return m_hwnd.get(); } //!< Read-only access to the wxDialog object. 00067 void notifyChildWindowDestruction(); //!< Called by wx main thread to set m_hwnd to NULL. 00068 void notifySemThreadReady(); //!< Called by wx main thread to signal the semaphore that the wx window is built and ready. 00069 00070 public: 00071 CBaseGUIWindow(const std::string &initial_caption = std::string() ); 00072 virtual ~CBaseGUIWindow(); 00073 00074 /** Returns false if the user has already closed the window. 00075 */ 00076 bool isOpen(); 00077 00078 /** Resizes the window, stretching the image to fit into the display area. 00079 */ 00080 virtual void resize( unsigned int width, unsigned int height ) = 0; 00081 00082 /** Changes the position of the window on the screen. 00083 */ 00084 virtual void setPos( int x, int y ) = 0; 00085 00086 /** Changes the window title text. 00087 */ 00088 virtual void setWindowTitle( const std::string &str )=0; 00089 00090 /** Waits for any key to be pushed on the image or the console, and returns the key code. 00091 * This method remove key strokes previous to its call, so it will always wait. To get 00092 * the latest pushed key, see 00093 * 00094 * \param ignoreControlKeys If set to false, any push of shift, cmd, control, etc... will make this method to return. 00095 * \param out_pushModifier If set to !=NULL, the modifiers of the key stroke will be saved here. 00096 * \return The virtual key code, as defined in mrptKeyCode (a replication of wxWidgets key codes). 00097 * 00098 * \sa getPushedKey, Key codes in the enum mrptKeyCode 00099 */ 00100 int waitForKey(bool ignoreControlKeys = true, mrptKeyModifier *out_pushModifier=NULL); 00101 00102 /** Returns true if a key has been pushed, without blocking waiting for a new key being pushed. 00103 * \sa waitForKey, clearKeyHitFlag 00104 */ 00105 bool keyHit() const { return m_keyPushed; } 00106 00107 /** Assure that "keyHit" will return false until the next pushed key. 00108 * \sa keyHit, waitForKey 00109 */ 00110 void clearKeyHitFlag() { m_keyPushed = false; } 00111 00112 /** Returns the latest pushed key, or 0 if there is no new key stroke. 00113 * \param out_pushModifier If set to !=NULL, the modifiers of the key stroke will be saved here. 00114 * \return The virtual key code, as defined in mrptKeyCode (a replication of wxWidgets key codes). 00115 * 00116 * \sa keyHit, waitForKey 00117 */ 00118 int getPushedKey(mrptKeyModifier *out_pushModifier=NULL); 00119 00120 00121 }; // End of class def. 00122 00123 } // End of namespace 00124 00125 } // End of namespace 00126 00127 #endif
| Page generated by Doxygen 1.6.2 for MRPT 0.8.1 SVN:exported at Mon Feb 15 22:01:07 UTC 2010 |
