OpenASIP  2.0
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 
43 using boost::format;
44 
45 BEGIN_EVENT_TABLE(DropDownMenu, wxMenu)
48 
49 /**
50  * Constructor.
51  *
52  * param type The type of the drop down menu.
53  */
54 DropDownMenu::DropDownMenu(MenuType type) : wxMenu() {
55 
57 
58  switch (type) {
59  case MENU_PATH: {
60  format fmt = texts.text(OSEdTextGenerator::TXT_MENU_ADD_MODULE);
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  */
115 }
116 
117 /**
118  * Handles the menu commands.
119  *
120  * @param event The event to be handled.
121  */
122 void
123 DropDownMenu::onMenuEvent(wxCommandEvent& event) {
124  wxGetApp().mainFrame()->onCommandEvent(event);
125 }
126 
127 /**
128  * Updates the menus enabled/disabled status.
129  */
130 void
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 }
DropDownMenu::onMenuEvent
void onMenuEvent(wxCommandEvent &event)
Definition: DropDownMenu.cc:123
WxConversion::toWxString
static wxString toWxString(const std::string &source)
GUICommand::isEnabled
virtual bool isEnabled()=0
OSEdConstants::CMD_ADD_OPERATION
@ CMD_ADD_OPERATION
Add operation command id.
Definition: OSEdConstants.hh:93
CommandRegistry.hh
OSEdConstants::CMD_BUILD
@ CMD_BUILD
Build command id.
Definition: OSEdConstants.hh:98
OSEdConstants::CMD_REMOVE_OPERATION
@ CMD_REMOVE_OPERATION
Remove operation command id.
Definition: OSEdConstants.hh:96
OSEd.hh
OSEdConstants::CMD_PROPERTIES
@ CMD_PROPERTIES
Operation properties command id.
Definition: OSEdConstants.hh:94
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
OSEdConstants.hh
DropDownMenu::MenuType
MenuType
Definition: DropDownMenu.hh:50
OSEdConstants::CMD_SIMULATE
@ CMD_SIMULATE
Simulate command id.
Definition: OSEdConstants.hh:100
GUICommand.hh
GUICommand
Definition: GUICommand.hh:43
OSEdConstants::CMD_REMOVE_MODULE
@ CMD_REMOVE_MODULE
Remove module command id.
Definition: OSEdConstants.hh:95
EVT_MENU_RANGE
EVT_MENU_RANGE(ProximConstants::COMMAND_FIRST, ProximConstants::COMMAND_LAST, ProximMainFrame::onCommandEvent) EVT_MENU_RANGE(ProximConstants
Definition: ProximMainFrame.cc:91
OSEdTextGenerator::TXT_MENU_MODIFY_PROPERTIES
@ TXT_MENU_MODIFY_PROPERTIES
Modify properties menu label.
Definition: OSEdTextGenerator.hh:170
DropDownMenu::updateMenu
void updateMenu()
Definition: DropDownMenu.cc:131
CommandRegistry
Definition: CommandRegistry.hh:47
OSEdTextGenerator::TXT_MENU_ADD_OPERATION
@ TXT_MENU_ADD_OPERATION
Add operation menu label.
Definition: OSEdTextGenerator.hh:167
OSEdTextGenerator::TXT_MENU_ADD_MODULE
@ TXT_MENU_ADD_MODULE
Add module menu label.
Definition: OSEdTextGenerator.hh:169
CommandRegistry::nextCommand
GUICommand * nextCommand()
Definition: CommandRegistry.cc:120
OSEdConstants::CMD_ADD_MODULE
@ CMD_ADD_MODULE
Add module command id.
Definition: OSEdConstants.hh:92
DropDownMenu
Definition: DropDownMenu.hh:44
OSEdTextGenerator::TXT_MENU_REMOVE_MODULE
@ TXT_MENU_REMOVE_MODULE
Remove module menu label.
Definition: OSEdTextGenerator.hh:178
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
OSEdTextGenerator::TXT_MENU_MODIFY_BEHAVIOR
@ TXT_MENU_MODIFY_BEHAVIOR
Modify behavior menu label.
Definition: OSEdTextGenerator.hh:179
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
DropDownMenu::~DropDownMenu
virtual ~DropDownMenu()
Definition: DropDownMenu.cc:114
OSEdTextGenerator::TXT_MENU_REMOVE_OPERATION
@ TXT_MENU_REMOVE_OPERATION
Remove operation menu label.
Definition: OSEdTextGenerator.hh:168
WxConversion.hh
GUICommand::id
virtual int id() const =0
CommandRegistry::firstCommand
GUICommand * firstCommand()
Definition: CommandRegistry.cc:104
OSEdTextGenerator.hh
OSEdTextGenerator::TXT_MENU_SIMULATE
@ TXT_MENU_SIMULATE
Simulate menu label.
Definition: OSEdTextGenerator.hh:173
OSEdTextGenerator::TXT_MENU_BUILD
@ TXT_MENU_BUILD
Build menu label.
Definition: OSEdTextGenerator.hh:171
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
OSEdConstants::CMD_MODIFY_BEHAVIOR
@ CMD_MODIFY_BEHAVIOR
Modify operation behavior command id.
Definition: OSEdConstants.hh:97
DropDownMenu.hh