File: wf_menubar.h

package info (click to toggle)
mysql-workbench 5.2.40%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 53,880 kB
  • sloc: cpp: 419,850; yacc: 74,784; xml: 54,510; python: 31,455; sh: 9,423; ansic: 4,736; makefile: 2,442; php: 529; java: 237
file content (89 lines) | stat: -rw-r--r-- 3,752 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* 
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; version 2 of the
 * License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#ifndef _WF_MENUBAR_H_
#define _WF_MENUBAR_H_

#include "mforms/menubar.h"
#include "wf_mforms.h"

using namespace System;
using namespace Windows::Forms;

namespace MySQL {
  namespace Forms {

    /**
     * Managed implementation of a menu item.
     */
    public ref class MenuItemImpl : public ObjectImpl
    {
    public:
      MenuItemImpl(mforms::MenuItem* item);

      void menuItemClick(Object^ sender, System::EventArgs^ e);
    };

    /**
     * Managed implementation of a menu strip.
     */
    public ref class MenuBarImpl : public ObjectImpl
    {
    protected:
      MenuBarImpl(mforms::MenuBar *self);
      ~MenuBarImpl();

      static bool create_menu_bar(mforms::MenuBar* item);
      static bool create_menu_item(mforms::MenuItem* item, const std::string& title,
        const mforms::MenuItemType type);
      static void set_title(mforms::MenuItem* item, const std::string& title);
      static std::string get_title(mforms::MenuItem* item);
      static void set_shortcut(mforms::MenuItem* item, const std::string& value);
      static void set_enabled(mforms::MenuBase* item, bool state);
      static bool get_enabled(mforms::MenuBase* item);
      static void set_checked(mforms::MenuItem* item, bool state);
      static bool get_checked(mforms::MenuItem* item);

      static void insert_item(mforms::MenuBase* menu, int index, mforms::MenuItem* item);
      static void remove_item(mforms::MenuBase* menu, mforms::MenuItem* item); // NULL item to remove all

      static void DropDownOpened(Object^ sender, System::EventArgs^ e);
    public:
      static void init(Manager^ mgr)
      {
        mforms::ControlFactory* f= mforms::ControlFactory::get_instance();

        DEF_CALLBACK1(bool, mforms::MenuBar*, mgr, f->_menu_item_impl, MenuBarImpl, create_menu_bar);
        DEF_CALLBACK3(bool, mforms::MenuItem*, const std::string&, const mforms::MenuItemType, mgr, f->_menu_item_impl, MenuBarImpl, create_menu_item);
        DEF_CALLBACK2(void, mforms::MenuItem*, const std::string&, mgr, f->_menu_item_impl, MenuBarImpl, set_title);
        DEF_CALLBACK1(std::string, mforms::MenuItem*, mgr, f->_menu_item_impl, MenuBarImpl, get_title);
        DEF_CALLBACK2(void, mforms::MenuItem*, const std::string&, mgr, f->_menu_item_impl, MenuBarImpl, set_shortcut);
        DEF_CALLBACK2(void, mforms::MenuBase*, bool, mgr, f->_menu_item_impl, MenuBarImpl, set_enabled);
        DEF_CALLBACK1(bool, mforms::MenuBase*, mgr, f->_menu_item_impl, MenuBarImpl, get_enabled);
        DEF_CALLBACK2(void, mforms::MenuItem*, bool, mgr, f->_menu_item_impl, MenuBarImpl, set_checked);
        DEF_CALLBACK1(bool, mforms::MenuItem*, mgr, f->_menu_item_impl, MenuBarImpl, get_checked);
        DEF_CALLBACK3(void, mforms::MenuBase*, int, mforms::MenuItem*, mgr, f->_menu_item_impl, MenuBarImpl, insert_item);
        DEF_CALLBACK2(void, mforms::MenuBase*, mforms::MenuItem*, mgr, f->_menu_item_impl, MenuBarImpl, remove_item);
      }
    };

  };
};

#endif // _WF_MENUBAR_H_