00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 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 00035 namespace mrpt 00036 { 00037 namespace gui 00038 { 00039 using namespace mrpt::utils; 00040 00041 class CWindowDialog; 00042 class CWindowDialogPlots; 00043 class C3DWindowDialog; 00044 00045 /** The base class for GUI window classes. 00046 */ 00047 class MRPTDLLIMPEXP CBaseGUIWindow 00048 { 00049 friend class CWindowDialog; 00050 friend class C3DWindowDialog; 00051 friend class CWindowDialogPlots; 00052 00053 protected: 00054 synch::CSemaphore m_semThreadReady; //!< This semaphore will be signaled when the wx window is built and ready. 00055 synch::CSemaphore m_semWindowDestroyed; //!< This semaphore will be signaled when the wx window is destroyed. 00056 std::string m_caption; //!< The caption of the window 00057 void_ptr_noncopy m_hwnd; //!< The window handle 00058 00059 /* Auxiliary */ 00060 volatile bool m_keyPushed; 00061 volatile int m_keyPushedCode; 00062 00063 public: 00064 void * getWxObject() { return m_hwnd.get(); } //!< Read-only access to the wxDialog object. 00065 void notifyChildWindowDestruction(); //!< Called by wx main thread to set m_hwnd to NULL. 00066 void notifySemThreadReady(); //!< Called by wx main thread to signal the semaphore that the wx window is built and ready. 00067 00068 public: 00069 CBaseGUIWindow(const std::string &initial_caption = std::string() ); 00070 virtual ~CBaseGUIWindow(); 00071 00072 /** Returns false if the user has already closed the window. 00073 */ 00074 bool isOpen(); 00075 00076 /** Resizes the window, stretching the image to fit into the display area. 00077 */ 00078 virtual void resize( unsigned int width, unsigned int height ) = 0; 00079 00080 /** Changes the position of the window on the screen. 00081 */ 00082 virtual void setPos( int x, int y ) = 0; 00083 00084 /** Changes the window title text. 00085 */ 00086 virtual void setWindowTitle( const std::string &str )=0; 00087 00088 /** Waits for any key to be pushed on the image or the console, and returns the key code. 00089 * Key codes are Virtual Key Codes from wxWidgets: http://docs.wxwidgets.org/stable/wx_keycodes.html 00090 */ 00091 int waitForKey(bool ignoreControlKeys = true); 00092 00093 /** Returns true if a key has been pushed, without blocking waiting for a new key being pushed. 00094 * \sa waitForKey, clearKeyHitFlag 00095 */ 00096 bool keyHit() const 00097 { 00098 return m_keyPushed; 00099 } 00100 00101 /** Assure that "keyHit" will return false until the next pushed key. 00102 * \sa keyHit, waitForKey 00103 */ 00104 void clearKeyHitFlag() 00105 { 00106 m_keyPushed = false; 00107 } 00108 00109 00110 }; // End of class def. 00111 00112 } // End of namespace 00113 00114 } // End of namespace 00115 00116 #endif
Page generated by Doxygen 1.6.1 for MRPT 0.7.1 SVN: at Tue Dec 22 08:29:35 CET 2009 |