Changeset 50:d650ff7422a5 in xplra
- Timestamp:
- 02/16/13 10:13:44 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/plugin/src/xplra
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/plugin/src/xplra/MessageWindow.cc
r49 r50 42 42 using hu::varadiistvan::xplcommon::Util; 43 43 44 using std::string; 44 45 using std::min; 45 46 using std::max; … … 76 77 77 78 MessageWindow::MessageWindow() : 79 maxMessageLength(0), 78 80 showForced(false), 79 81 hideTime(0.0), … … 89 91 heightDataRef = XPLMFindDataRef("sim/graphics/view/window_height"); 90 92 93 int digitsOnly = 0; 94 XPLMGetFontDimensions(xplmFont_Basic, &fontWidth, &fontHeight, &digitsOnly); 95 96 Util::debug("hu.varadiistvan.xplra.MessageWindow: fontWidth=%d, fontHeight=%d\n", 97 fontWidth, fontHeight); 98 91 99 resetLocation(); 92 100 … … 148 156 XPLMDrawTranslucentDarkBox(left, top, right, bottom); 149 157 if (hideTime!=0.0) { 150 XPLMDrawString(colour, left + 25, top - 15, 151 const_cast<char*>(displayedMessage.c_str()), 0, 158 159 string dm(displayedMessage, 0, maxMessageLength); 160 161 XPLMDrawString(colour, 162 left + horizontalMarginSize, 163 bottom + verticalMarginSize + baseLineSize, 164 const_cast<char*>(dm.c_str()), 0, 152 165 xplmFont_Basic); 153 166 } … … 208 221 if (newLeft>=0 && (right-newLeft)>=minimalWidth) { 209 222 left = newLeft; 223 recalculateMaxMessageLength(); 210 224 } 211 225 } else if (mouseMode==MOUSE_RESIZE_RIGHT) { … … 214 228 if (newRight<screenWidth && (newRight-left)>=minimalWidth) { 215 229 right = newRight; 230 recalculateMaxMessageLength(); 216 231 } 217 232 } 218 233 219 234 XPLMSetWindowGeometry(windowID, left, top, right, bottom); 220 221 // clickedX = x;222 // clickedY = y;223 235 } 224 236 … … 267 279 // screenWidth, screenHeight); 268 280 269 left = 50; right = screenWidth - left; 270 top = screenHeight * 9 / 10; bottom = top - 25; 281 left = 50; 282 right = screenWidth - left; 283 284 top = screenHeight * 9 / 10; 285 bottom = top - fontHeight - 2*verticalMarginSize; 286 287 recalculateMaxMessageLength(); 288 } 289 290 //------------------------------------------------------------------------------ 291 292 void MessageWindow::recalculateMaxMessageLength() 293 { 294 maxMessageLength = (right + 1 - left) - 2 * horizontalMarginSize; 295 maxMessageLength /= fontWidth; 271 296 } 272 297 -
src/plugin/src/xplra/MessageWindow.h
r49 r50 79 79 static const int resizeArea = 50; 80 80 81 /** 82 * The size of the margins at each side of the window. 83 */ 84 static const int horizontalMarginSize = 25; 85 86 /** 87 * The size of the margins at the top and the bottom of the window. 88 */ 89 static const int verticalMarginSize = 5; 90 91 /** 92 * The size for the baseline above the bottom of the letters. 93 */ 94 static const int baseLineSize = 2; 95 81 96 private: 82 97 /** … … 91 106 92 107 /** 108 * The width of one character of the font. 109 */ 110 int fontWidth; 111 112 /** 113 * The height of one character of the font. 114 */ 115 int fontHeight; 116 117 /** 93 118 * The window ID. 94 119 */ … … 114 139 */ 115 140 int bottom; 141 142 /** 143 * The maximal message length. 144 */ 145 int maxMessageLength; 116 146 117 147 /** … … 257 287 */ 258 288 void resetLocation(); 289 290 /** 291 * Recalculate the maximal message length. 292 */ 293 void recalculateMaxMessageLength(); 259 294 260 295 friend class MessageRequest;
Note:
See TracChangeset
for help on using the changeset viewer.