Ignore:
Timestamp:
02/16/13 10:13:44 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The font size is now taken into account and the maximal message length is considered

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/plugin/src/xplra/MessageWindow.cc

    r49 r50  
    4242using hu::varadiistvan::xplcommon::Util;
    4343
     44using std::string;
    4445using std::min;
    4546using std::max;
     
    7677
    7778MessageWindow::MessageWindow() :
     79    maxMessageLength(0),
    7880    showForced(false),
    7981    hideTime(0.0),
     
    8991    heightDataRef = XPLMFindDataRef("sim/graphics/view/window_height");
    9092
     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
    9199    resetLocation();
    92100
     
    148156        XPLMDrawTranslucentDarkBox(left, top, right, bottom);
    149157        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,
    152165                           xplmFont_Basic);
    153166        }
     
    208221            if (newLeft>=0 && (right-newLeft)>=minimalWidth) {
    209222                left = newLeft;
     223                recalculateMaxMessageLength();
    210224            }
    211225        } else if (mouseMode==MOUSE_RESIZE_RIGHT) {
     
    214228            if (newRight<screenWidth && (newRight-left)>=minimalWidth) {
    215229                right = newRight;
     230                recalculateMaxMessageLength();
    216231            }
    217232        }
    218233
    219234        XPLMSetWindowGeometry(windowID, left, top, right, bottom);
    220 
    221         // clickedX = x;
    222         // clickedY = y;
    223235    }
    224236
     
    267279    //             screenWidth, screenHeight);
    268280
    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
     292void MessageWindow::recalculateMaxMessageLength()
     293{
     294    maxMessageLength = (right + 1 - left) - 2 * horizontalMarginSize;
     295    maxMessageLength /= fontWidth;
    271296}
    272297
Note: See TracChangeset for help on using the changeset viewer.