Changeset 47:411a69092798 in xplra


Ignore:
Timestamp:
02/16/13 09:24:42 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 3 'hg:/home/ivaradi/xplane/hg/xplra' '/'>, 'public')
Message:

Added a menu option to reset the message area

Location:
src/plugin/src/xplra
Files:
4 edited

Legend:

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

    r43 r47  
    3939//------------------------------------------------------------------------------
    4040
     41void* const Menu::showMessageAreaRef = reinterpret_cast<void*>(1);
     42
     43void* const Menu::resetMessageAreaRef = reinterpret_cast<void*>(2);
     44
     45//------------------------------------------------------------------------------
     46
    4147void Menu::menuHandlerCallback(void* menuRef, void* itemRef)
    4248{
     
    5864                            &menuHandlerCallback, this);
    5965    showMessageAreaIndex = XPLMAppendMenuItem(menuID, "Show message area",
    60                                               0, 1);
     66                                              showMessageAreaRef, 1);
    6167    XPLMCheckMenuItem(menuID, showMessageAreaIndex, xplm_Menu_Unchecked);
     68    XPLMAppendMenuItem(menuID, "Reset message area", resetMessageAreaRef, 1);
    6269}
    6370
    6471//------------------------------------------------------------------------------
    6572
    66 void Menu::handleMenu(void* /*itemRef*/)
     73void Menu::handleMenu(void* itemRef)
    6774{
    68     XPLMMenuCheck checked = xplm_Menu_NoCheck;
    69     XPLMCheckMenuItemState(menuID, showMessageAreaIndex, &checked);
    70     if (checked==xplm_Menu_Unchecked) {
    71         XPLMCheckMenuItem(menuID, showMessageAreaIndex, xplm_Menu_Checked);
    72         messageWindow.show();
    73     } else if (checked==xplm_Menu_Checked) {
    74         XPLMCheckMenuItem(menuID, showMessageAreaIndex, xplm_Menu_Unchecked);
    75         messageWindow.hide();
     75    if (itemRef==showMessageAreaRef) {
     76        XPLMMenuCheck checked = xplm_Menu_NoCheck;
     77        XPLMCheckMenuItemState(menuID, showMessageAreaIndex, &checked);
     78        if (checked==xplm_Menu_Unchecked) {
     79            XPLMCheckMenuItem(menuID, showMessageAreaIndex, xplm_Menu_Checked);
     80            messageWindow.show();
     81        } else if (checked==xplm_Menu_Checked) {
     82            XPLMCheckMenuItem(menuID, showMessageAreaIndex, xplm_Menu_Unchecked);
     83            messageWindow.hide();
     84        }
     85    } else if (itemRef==resetMessageAreaRef) {
     86        messageWindow.reset();
    7687    }
    7788}
  • src/plugin/src/xplra/Menu.h

    r43 r47  
    5555
    5656    /**
     57     * Item reference for the show message area menu item.
     58     */
     59    static void* const showMessageAreaRef;
     60
     61    /**
     62     * Item reference for the show message area menu item.
     63     */
     64    static void* const resetMessageAreaRef;
     65
     66    /**
    5767     * Reference to the message window.
    5868     */
  • src/plugin/src/xplra/MessageWindow.cc

    r46 r47  
    8080    heightDataRef = XPLMFindDataRef("sim/graphics/view/window_height");
    8181
    82     int screenWidth = XPLMGetDatai(widthDataRef);
    83     int screenHeight = XPLMGetDatai(heightDataRef);
    84 
    85     // Util::debug("hu.varadiistvan.xplra.MessageWindow: screenWidth=%d, screenHeight=%d\n",
    86     //             screenWidth, screenHeight);
    87 
    88     left = 50; right = screenWidth - left;
    89     top = screenHeight * 9 / 10; bottom = top - 25;
     82    resetLocation();
    9083
    9184    windowID = XPLMCreateWindow(left, top, right, bottom, 0,
     
    116109{
    117110    showForced = false;
     111}
     112
     113//------------------------------------------------------------------------------
     114
     115void MessageWindow::reset()
     116{
     117    resetLocation();
     118    XPLMSetWindowGeometry(windowID, left, top, right, bottom);
    118119}
    119120
     
    196197//------------------------------------------------------------------------------
    197198
     199void MessageWindow::resetLocation()
     200{
     201    int screenWidth = XPLMGetDatai(widthDataRef);
     202    int screenHeight = XPLMGetDatai(heightDataRef);
     203
     204    // Util::debug("hu.varadiistvan.xplra.MessageWindow: screenWidth=%d, screenHeight=%d\n",
     205    //             screenWidth, screenHeight);
     206
     207    left = 50; right = screenWidth - left;
     208    top = screenHeight * 9 / 10; bottom = top - 25;
     209}
     210
     211//------------------------------------------------------------------------------
     212
    198213// Local Variables:
    199214// mode: C++
  • src/plugin/src/xplra/MessageWindow.h

    r42 r47  
    161161    void hide();
    162162
     163    /**
     164     * Reset the location of the message window.
     165     */
     166    void reset();
     167
    163168private:
    164169    /**
     
    192197     */
    193198    void setNewMessage(const std::string& msg, float d);
     199
     200    /**
     201     * Reset the location of the message window.
     202     */
     203    void resetLocation();
    194204
    195205    friend class MessageRequest;
Note: See TracChangeset for help on using the changeset viewer.