Class CBaseGUIWindow
Defined in File CBaseGUIWindow.h
Inheritance Relationships
Base Type
public mrpt::system::CObservable
Derived Types
public mrpt::gui::CDisplayWindow(Class CDisplayWindow)public mrpt::gui::CDisplayWindow3D(Class CDisplayWindow3D)public mrpt::gui::CDisplayWindowPlots(Class CDisplayWindowPlots)
Class Documentation
-
class CBaseGUIWindow : public mrpt::system::CObservable
The base class for GUI window classes based on wxWidgets.
This class can be observed (see mrpt::system::CObserver) for the following events (see mrpt::system::mrptEvent):
See derived classes to check if they emit other additional events.
IMPORTANTE NOTICE: Event handlers in your observer class will be invoked from the wxWidgets internal MRPT thread, so all your code in the handler must be thread safe.
Subclassed by mrpt::gui::CDisplayWindow, mrpt::gui::CDisplayWindow3D, mrpt::gui::CDisplayWindowPlots
Public Functions
-
void *getWxObject()
Read-only access to the wxDialog object.
-
void notifyChildWindowDestruction()
Called by wx main thread to set m_hwnd to NULL.
-
void notifySemThreadReady()
Called by wx main thread to signal the semaphore that the wx window is built and ready.
-
CBaseGUIWindow(void *winobj_voidptr, uint16_t CMD_CREATE_WIN, uint16_t CMD_DESTROY_WIN, std::string initial_caption = {})
CMD_DESTROY_WIN can be 299,399,499… See WxSubsystem
-
~CBaseGUIWindow() override
-
CBaseGUIWindow(const CBaseGUIWindow&) = delete
-
CBaseGUIWindow &operator=(const CBaseGUIWindow&) = delete
-
CBaseGUIWindow(CBaseGUIWindow&&) = delete
-
CBaseGUIWindow &operator=(CBaseGUIWindow&&) = delete
-
bool isOpen()
Returns false if the user has already closed the window.
-
virtual void resize(unsigned int width, unsigned int height) = 0
Resizes the window, stretching the image to fit into the display area.
-
virtual void setPos(int x, int y) = 0
Changes the position of the window on the screen.
-
virtual void setWindowTitle(const std::string &str) = 0
Changes the window title text.
-
virtual std::optional<mrpt::img::TPixelCoord> getLastMousePosition() const = 0
Gets the last x,y pixel coordinates of the mouse.
- Returns:
nullopt if the window is closed.
-
virtual void setCursorCross(bool cursorIsCross) = 0
Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true)
-
int waitForKey(bool ignoreControlKeys = true, mrptKeyModifier *out_pushModifier = nullptr)
Waits for any key to be pushed on the image or the console, and returns the key code. This method remove key strokes previous to its call, so it will always wait. To get the latest pushed key, see
See also
getPushedKey, Key codes in the enum mrptKeyCode
- Parameters:
ignoreControlKeys – If set to false, any push of shift, cmd, control, etc… will make this method to return.
out_pushModifier – If set to !=nullptr, the modifiers of the key stroke will be saved here.
- Returns:
The virtual key code, as defined in mrptKeyCode (a replication of wxWidgets key codes).
-
inline bool keyHit() const
Returns true if a key has been pushed, without blocking waiting for a new key being pushed.
See also
-
inline void clearKeyHitFlag()
Assure that “keyHit” will return false until the next pushed key.
See also
-
int getPushedKey(mrptKeyModifier *out_pushModifier = nullptr)
Returns the latest pushed key, or 0 if there is no new key stroke.
See also
- Parameters:
out_pushModifier – If set to !=nullptr, the modifiers of the key stroke will be saved here.
- Returns:
The virtual key code, as defined in <mrpt/gui/keycodes.h> (a replication of wxWidgets key codes).
Protected Functions
-
void createWxWindow(unsigned int initialWidth, unsigned int initialHeight)
Must be called by child classes just within the constructor.
-
void destroyWxWindow()
Must be called by child classes in their destructors. The code cannot be put into this class’ destructor.
Protected Attributes
-
mutable std::promise<void> m_threadReady
This semaphore will be signaled when the wx window is built and ready.
-
mutable std::promise<void> m_windowDestroyed
This semaphore will be signaled when the wx window is destroyed.
-
mutable std::mutex m_mtx
this protects access to the fields below
-
std::string m_caption
The caption of the window
-
mrpt::void_ptr_noncopy m_hwnd = nullptr
The window handle
-
bool m_keyPushed = false
-
int m_keyPushedCode = 0
-
mrptKeyModifier m_keyPushedModifier = MRPTKMOD_NONE