31 #include "MessageWindow.h"
33 #include <hu/varadiistvan/xplcommon/Util.h>
35 #include <XPLMProcessing.h>
36 #include <XPLMGraphics.h>
42 using hu::varadiistvan::xplcommon::Util;
50 void MessageWindow::drawWindowCallback(XPLMWindowID ,
void* refCon)
59 XPLMKeyFlags flags,
char virtualKey,
60 void* refCon,
int losingFocus)
63 messageWindow->
handleKey(key, flags, virtualKey, losingFocus!=0);
70 XPLMMouseStatus mouse,
void* refCon)
91 widthDataRef = XPLMFindDataRef(
"sim/graphics/view/window_width");
92 heightDataRef = XPLMFindDataRef(
"sim/graphics/view/window_height");
97 Util::debug(
"hu.varadiistvan.xplra.MessageWindow: fontWidth=%d, fontHeight=%d\n",
112 XPLMSetWindowIsVisible(
windowID, 0);
121 XPLMSetWindowIsVisible(
windowID, 1);
143 static float colour[3] = { 0.2, 1.0, 0.65 };
145 float now = XPLMGetElapsedTime();
156 XPLMSetWindowIsVisible(
windowID, 0);
172 XPLMDrawString(colour,
175 const_cast<char*
>(dm.c_str()), 0,
186 Util::debug(
"hu.varadiistvan.xplra.MessageWindow.handleKey: key=0x%02d (%c), flags=0x%04x, virtualKey=0x%02d (%c), losingFocus=%d\n",
187 key, key, flags, virtualKey, virtualKey, losingFocus);
194 if (mouse==xplm_MouseDown) {
208 }
else if (mouse==xplm_MouseDrag) {
216 if (newLeft>=0 && newRight<screenWidth) {
226 if (newTop<screenHeight && newBottom>=0) {
230 }
else if (
mouseMode==MOUSE_RESIZE_LEFT) {
236 }
else if (
mouseMode==MOUSE_RESIZE_RIGHT) {
279 XPLMSetWindowIsVisible(
windowID, 1);
295 top = screenHeight * 9 / 10;
void setNewMessage(const std::string &msg, float d)
static const int resizeArea
static void handleKeyCallback(XPLMWindowID windowID, char key, XPLMKeyFlags flags, char virtualKey, void *refCon, int losingFocus)
static constexpr float scrollTimeout
static void drawWindowCallback(XPLMWindowID windowID, void *refCon)
void handleKey(char key, XPLMKeyFlags flags, char virtualKey, bool losingFocus)
static const int verticalMarginSize
enum xplra::MessageWindow::@0 mouseMode
bool handleMouseClick(int x, int y, XPLMMouseStatus mouse)
hu::varadiistvan::scpl::Mutex mutex
std::string displayedMessage
void recalculateMaxMessageLength()
float getNewMessage(std::string &dest)
static const int horizontalMarginSize
static const int baseLineSize
static int handleMouseClickCallback(XPLMWindowID windowID, int x, int y, XPLMMouseStatus mouse, void *refCon)
static const int minimalWidth
XPLMDataRef heightDataRef
static constexpr float scrollInterval