X-Plane Remote Access Plugin and Client Library
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
xplra::MessageWindow Class Reference

#include <MessageWindow.h>

Public Member Functions

 MessageWindow ()
 
 ~MessageWindow ()
 
void show ()
 
void hide ()
 
void reset ()
 

Private Types

enum  { MOUSE_MOVE , MOUSE_RESIZE_LEFT , MOUSE_RESIZE_RIGHT }
 

Private Member Functions

void drawWindow ()
 
void handleKey (char key, XPLMKeyFlags flags, char virtualKey, bool losingFocus)
 
bool handleMouseClick (int x, int y, XPLMMouseStatus mouse)
 
float getNewMessage (std::string &dest)
 
void setNewMessage (const std::string &msg, float d)
 
void resetLocation ()
 
void recalculateMaxMessageLength ()
 

Static Private Member Functions

static void drawWindowCallback (XPLMWindowID windowID, void *refCon)
 
static void handleKeyCallback (XPLMWindowID windowID, char key, XPLMKeyFlags flags, char virtualKey, void *refCon, int losingFocus)
 
static int handleMouseClickCallback (XPLMWindowID windowID, int x, int y, XPLMMouseStatus mouse, void *refCon)
 

Private Attributes

XPLMDataRef widthDataRef
 
XPLMDataRef heightDataRef
 
int fontWidth
 
int fontHeight
 
XPLMWindowID windowID
 
int left
 
int top
 
int right
 
int bottom
 
size_t maxMessageLength
 
bool showForced
 
std::string displayedMessage
 
float showTime
 
float hideTime
 
enum xplra::MessageWindow:: { ... }  mouseMode
 
int clickedX
 
int clickedY
 
int clickedLeft
 
int clickedTop
 
int clickedRight
 
int clickedBottom
 
hu::varadiistvan::scpl::Mutex mutex
 
std::string message
 
float duration
 

Static Private Attributes

static const int minimalWidth = 150
 
static const int resizeArea = 50
 
static const int horizontalMarginSize = 25
 
static const int verticalMarginSize = 5
 
static const int baseLineSize = 2
 
static constexpr float scrollTimeout = 1.0
 
static constexpr float scrollInterval = 0.1
 

Friends

class MessageRequest
 

Detailed Description

Class to handle the activities related to the message window.

Definition at line 49 of file MessageWindow.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

The mouse mode

Definition at line 182 of file MessageWindow.h.

Constructor & Destructor Documentation

◆ MessageWindow()

MessageWindow::MessageWindow ( )

Construct the message window. It creates the X-Plane window and registers the callback functions. The window is hidden initially.

Definition at line 78 of file MessageWindow.cc.

◆ ~MessageWindow()

MessageWindow::~MessageWindow ( )

Destroy the message window. It destroys the X-Plane window.

Definition at line 110 of file MessageWindow.cc.

Member Function Documentation

◆ drawWindow()

void MessageWindow::drawWindow ( )
private

Called from the window drawing callback.

Definition at line 141 of file MessageWindow.cc.

◆ drawWindowCallback()

void MessageWindow::drawWindowCallback ( XPLMWindowID  windowID,
void *  refCon 
)
staticprivate

Window drawing callback.

Definition at line 50 of file MessageWindow.cc.

◆ getNewMessage()

float MessageWindow::getNewMessage ( std::string &  dest)
private

Get the new message, if any.

Returns
the duration of the message, or 0.0 if there is no new message. The message will be cleared.

Definition at line 253 of file MessageWindow.cc.

◆ handleKey()

void MessageWindow::handleKey ( char  key,
XPLMKeyFlags  flags,
char  virtualKey,
bool  losingFocus 
)
private

Called from the key handling callback.

Definition at line 183 of file MessageWindow.cc.

◆ handleKeyCallback()

void MessageWindow::handleKeyCallback ( XPLMWindowID  windowID,
char  key,
XPLMKeyFlags  flags,
char  virtualKey,
void *  refCon,
int  losingFocus 
)
staticprivate

Handle the keypresses.

Definition at line 58 of file MessageWindow.cc.

◆ handleMouseClick()

bool MessageWindow::handleMouseClick ( int  x,
int  y,
XPLMMouseStatus  mouse 
)
private

Called from the mouse click handling callback.

Returns
true if the click is consumed, false otherwise.

Definition at line 192 of file MessageWindow.cc.

◆ handleMouseClickCallback()

int MessageWindow::handleMouseClickCallback ( XPLMWindowID  windowID,
int  x,
int  y,
XPLMMouseStatus  mouse,
void *  refCon 
)
staticprivate

Handle the mouse clicks.

Definition at line 68 of file MessageWindow.cc.

◆ hide()

void MessageWindow::hide ( )

Hide the message window if it does not have to display an actual message.

Definition at line 126 of file MessageWindow.cc.

◆ recalculateMaxMessageLength()

void MessageWindow::recalculateMaxMessageLength ( )
private

Recalculate the maximal message length.

Definition at line 303 of file MessageWindow.cc.

◆ reset()

void MessageWindow::reset ( )

Reset the location of the message window.

Definition at line 133 of file MessageWindow.cc.

◆ resetLocation()

void MessageWindow::resetLocation ( )
private

Reset the location of the message window.

Definition at line 284 of file MessageWindow.cc.

◆ setNewMessage()

void MessageWindow::setNewMessage ( const std::string &  msg,
float  d 
)
private

Set the new message, if any.

Definition at line 272 of file MessageWindow.cc.

◆ show()

void MessageWindow::show ( )

Force showing the message window.

Definition at line 118 of file MessageWindow.cc.

Member Data Documentation

◆ baseLineSize

const int xplra::MessageWindow::baseLineSize = 2
staticprivate

The size for the baseline above the bottom of the letters.

Definition at line 94 of file MessageWindow.h.

◆ bottom

int xplra::MessageWindow::bottom
private

The Y-coordinate of the bottom of the window.

Definition at line 151 of file MessageWindow.h.

◆ clickedBottom

int xplra::MessageWindow::clickedBottom
private

The bottom coordinate of the window when it was clicked.

Definition at line 221 of file MessageWindow.h.

◆ clickedLeft

int xplra::MessageWindow::clickedLeft
private

The left coordinate of the window when it was clicked.

Definition at line 206 of file MessageWindow.h.

◆ clickedRight

int xplra::MessageWindow::clickedRight
private

The right coordinate of the window when it was clicked.

Definition at line 216 of file MessageWindow.h.

◆ clickedTop

int xplra::MessageWindow::clickedTop
private

The top coordinate of the window when it was clicked.

Definition at line 211 of file MessageWindow.h.

◆ clickedX

int xplra::MessageWindow::clickedX
private

The X-coordinate where the window was clicked.

Definition at line 196 of file MessageWindow.h.

◆ clickedY

int xplra::MessageWindow::clickedY
private

The Y-coordinate where the window was clicked.

Definition at line 201 of file MessageWindow.h.

◆ displayedMessage

std::string xplra::MessageWindow::displayedMessage
private

The currently displayed message.

Definition at line 166 of file MessageWindow.h.

◆ duration

float xplra::MessageWindow::duration
private

The number of seconds for which the message should be shown. If positive, there is a new message.

Definition at line 238 of file MessageWindow.h.

◆ fontHeight

int xplra::MessageWindow::fontHeight
private

The height of one character of the font.

Definition at line 126 of file MessageWindow.h.

◆ fontWidth

int xplra::MessageWindow::fontWidth
private

The width of one character of the font.

Definition at line 121 of file MessageWindow.h.

◆ heightDataRef

XPLMDataRef xplra::MessageWindow::heightDataRef
private

The dataref containing the height of the program's window.

Definition at line 116 of file MessageWindow.h.

◆ hideTime

float xplra::MessageWindow::hideTime
private

The time to hide the current message. If not positive, no message is currently shown.

Definition at line 177 of file MessageWindow.h.

◆ horizontalMarginSize

const int xplra::MessageWindow::horizontalMarginSize = 25
staticprivate

The size of the margins at each side of the window.

Definition at line 84 of file MessageWindow.h.

◆ left

int xplra::MessageWindow::left
private

The X-coordinate of the left side of the window.

Definition at line 136 of file MessageWindow.h.

◆ maxMessageLength

size_t xplra::MessageWindow::maxMessageLength
private

The maximal message length.

Definition at line 156 of file MessageWindow.h.

◆ message

std::string xplra::MessageWindow::message
private

The message to show.

Definition at line 232 of file MessageWindow.h.

◆ minimalWidth

const int xplra::MessageWindow::minimalWidth = 150
staticprivate

The minimal width of the message area.

Definition at line 74 of file MessageWindow.h.

◆ 

enum { ... } xplra::MessageWindow::mouseMode

The mouse mode

◆ mutex

hu::varadiistvan::scpl::Mutex xplra::MessageWindow::mutex
private

The mutex protecting some of the data structures that are used from both the simulator loop and the server thread.

Definition at line 227 of file MessageWindow.h.

◆ resizeArea

const int xplra::MessageWindow::resizeArea = 50
staticprivate

The size of the resize sensitivity area.

Definition at line 79 of file MessageWindow.h.

◆ right

int xplra::MessageWindow::right
private

The X-coordinate of the right side of the window.

Definition at line 146 of file MessageWindow.h.

◆ scrollInterval

constexpr float xplra::MessageWindow::scrollInterval = 0.1
staticconstexprprivate

The amount of time in seconds between each character step.

Definition at line 105 of file MessageWindow.h.

◆ scrollTimeout

constexpr float xplra::MessageWindow::scrollTimeout = 1.0
staticconstexprprivate

The amount of time in seconds after which the message is started to be scrolled, if it should be scrolled.

Definition at line 100 of file MessageWindow.h.

◆ showForced

bool xplra::MessageWindow::showForced
private

Indicate if the message window should be shown

Definition at line 161 of file MessageWindow.h.

◆ showTime

float xplra::MessageWindow::showTime
private

The time the current message was shown.

Definition at line 171 of file MessageWindow.h.

◆ top

int xplra::MessageWindow::top
private

The Y-coordinate of the top of the window.

Definition at line 141 of file MessageWindow.h.

◆ verticalMarginSize

const int xplra::MessageWindow::verticalMarginSize = 5
staticprivate

The size of the margins at the top and the bottom of the window.

Definition at line 89 of file MessageWindow.h.

◆ widthDataRef

XPLMDataRef xplra::MessageWindow::widthDataRef
private

The dataref containing the width of the program's window.

Definition at line 111 of file MessageWindow.h.

◆ windowID

XPLMWindowID xplra::MessageWindow::windowID
private

The window ID.

Definition at line 131 of file MessageWindow.h.


The documentation for this class was generated from the following files: