Changeset 43:d05df1944444 in xplra for src


Ignore:
Timestamp:
02/15/13 18:40:40 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Moved the menu handling into its own class

Location:
src/plugin/src/xplra
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/plugin/src/xplra/Makefile.am

    r39 r43  
    1919        ReloadPluginsRequest.cc         \
    2020        MessageWindow.cc                \
    21         MessageRequest.cc
     21        MessageRequest.cc               \
     22        Menu.cc
    2223
    2324noinst_HEADERS= \
     
    3738        ReloadPluginsRequest.h          \
    3839        MessageWindow.h                 \
    39         MessageRequest.h
     40        MessageRequest.h                \
     41        Menu.h
    4042
    4143if TARGET_API_POSIX
  • src/plugin/src/xplra/plugin.cc

    r42 r43  
    3232
    3333#include "MessageWindow.h"
     34#include "Menu.h"
    3435
    3536#include <hu/varadiistvan/xplcommon/Util.h>
     
    5354using xplra::ListenThread;
    5455using xplra::MessageWindow;
     56using xplra::Menu;
    5557
    5658using hu::varadiistvan::xplcommon::Util;
     
    6466
    6567/**
     68 * The menu.
     69 */
     70static Menu* menu = 0;
     71
     72/**
    6673 * The thread to use to listen for incoming connections.
    6774 */
    6875static ListenThread* listenThread = 0;
    69 
    70 /**
    71  * The ID of the menu of the plugin.
    72  */
    73 static XPLMMenuID menuID = 0;
    74 
    75 /**
    76  * The index of the show message area menu item.
    77  */
    78 static int showMessageAreaIndex = 0;
    79 
    80 //------------------------------------------------------------------------------
    81 
    82 static void menuHandler(void* /*menuRef*/, void* /*itemRef*/)
    83 {
    84     // Util::debug("hu.varadiistvan.xplra menuHandler called\n");
    85     XPLMMenuCheck checked = xplm_Menu_NoCheck;
    86     XPLMCheckMenuItemState(menuID, showMessageAreaIndex, &checked);
    87     if (checked==xplm_Menu_Unchecked) {
    88         XPLMCheckMenuItem(menuID, showMessageAreaIndex, xplm_Menu_Checked);
    89         messageWindow->show();
    90     } else if (checked==xplm_Menu_Checked) {
    91         XPLMCheckMenuItem(menuID, showMessageAreaIndex, xplm_Menu_Unchecked);
    92         messageWindow->hide();
    93     }
    94 }
    9576
    9677//------------------------------------------------------------------------------
     
    124105    XPLMGetVersions(&xplaneVersion, &xplmVersion, &hostID);
    125106
    126     int menuIndex = XPLMAppendMenuItem(XPLMFindPluginsMenu(),
    127                                        "Remote Access", NULL, 1);
    128     menuID = XPLMCreateMenu("Remote Access", XPLMFindPluginsMenu(), menuIndex,
    129                             &menuHandler, 0);
    130     showMessageAreaIndex = XPLMAppendMenuItem(menuID, "Show message area",
    131                                               0, 1);
    132     XPLMCheckMenuItem(menuID, showMessageAreaIndex, xplm_Menu_Unchecked);
    133 
    134107    messageWindow = new MessageWindow();
     108    menu = new Menu(*messageWindow);
    135109
    136110    listenThread = new ListenThread(xplaneVersion, xplmVersion,
     
    160134    }
    161135
     136    delete menu; menu = 0;
    162137    delete messageWindow; messageWindow = 0;
    163138}
Note: See TracChangeset for help on using the changeset viewer.