OpenASIP 2.2
Loading...
Searching...
No Matches
DropDownMenu.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file DropDownMenu.cc
26 *
27 * Definition of DropDownMenu class.
28 *
29 * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include <boost/format.hpp>
34
35#include "DropDownMenu.hh"
36#include "OSEdConstants.hh"
37#include "OSEdTextGenerator.hh"
38#include "OSEd.hh"
39#include "WxConversion.hh"
40#include "GUICommand.hh"
41#include "CommandRegistry.hh"
42
43using boost::format;
44
45BEGIN_EVENT_TABLE(DropDownMenu, wxMenu)
48
49/**
50 * Constructor.
51 *
52 * param type The type of the drop down menu.
53 */
55
57
58 switch (type) {
59 case MENU_PATH: {
61 Append(
63 WxConversion::toWxString(fmt.str()));
64 }
65 break;
66 case MENU_MODULE: {
68 Append(
70 WxConversion::toWxString(fmt.str()));
71
73 Append(
75 WxConversion::toWxString(fmt.str()));
76
78 Append(
80 }
81 break;
82 case MENU_OPERATION: {
84 Append(
86 WxConversion::toWxString(fmt.str()));
87
89 Append(
91 WxConversion::toWxString(fmt.str()));
92
94 Append(
96 WxConversion::toWxString(fmt.str()));
97
99 Append(
101 WxConversion::toWxString(fmt.str()));
102 }
103 break;
104 default:
105 break;
106 }
107
108 updateMenu();
109}
110
111/**
112 * Destructor.
113 */
116
117/**
118 * Handles the menu commands.
119 *
120 * @param event The event to be handled.
121 */
122void
123DropDownMenu::onMenuEvent(wxCommandEvent& event) {
124 wxGetApp().mainFrame()->onCommandEvent(event);
125}
126
127/**
128 * Updates the menus enabled/disabled status.
129 */
130void
132 CommandRegistry* registry = wxGetApp().mainFrame()->registry();
133 GUICommand* command = registry->firstCommand();
134 while (command != NULL) {
135 if (FindItem(command->id()) != NULL) {
136 if (command->isEnabled()) {
137 Enable(command->id(), true);
138 } else {
139 Enable(command->id(), false);
140 }
141 }
142 command = registry->nextCommand();
143 }
144}
END_EVENT_TABLE() using namespace IDF
EVT_MENU_RANGE(ProximConstants::COMMAND_FIRST, ProximConstants::COMMAND_LAST, ProximMainFrame::onCommandEvent) EVT_MENU_RANGE(ProximConstants
GUICommand * firstCommand()
GUICommand * nextCommand()
virtual ~DropDownMenu()
void onMenuEvent(wxCommandEvent &event)
virtual int id() const =0
virtual bool isEnabled()=0
@ CMD_MODIFY_BEHAVIOR
Modify operation behavior command id.
@ CMD_REMOVE_MODULE
Remove module command id.
@ CMD_PROPERTIES
Operation properties command id.
@ CMD_ADD_OPERATION
Add operation command id.
@ CMD_BUILD
Build command id.
@ CMD_SIMULATE
Simulate command id.
@ CMD_ADD_MODULE
Add module command id.
@ CMD_REMOVE_OPERATION
Remove operation command id.
static OSEdTextGenerator & instance()
@ TXT_MENU_SIMULATE
Simulate menu label.
@ TXT_MENU_REMOVE_OPERATION
Remove operation menu label.
@ TXT_MENU_BUILD
Build menu label.
@ TXT_MENU_ADD_OPERATION
Add operation menu label.
@ TXT_MENU_ADD_MODULE
Add module menu label.
@ TXT_MENU_MODIFY_PROPERTIES
Modify properties menu label.
@ TXT_MENU_REMOVE_MODULE
Remove module menu label.
@ TXT_MENU_MODIFY_BEHAVIOR
Modify behavior menu label.
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)