|
Last change
on this file since 45ff42 was d20ed5, checked in by Frederik Heber <heber@…>, 16 years ago |
|
Added basic menu and action framework
- Added action base class
- Added class to make actions from methods
- Added Menu base class
- Added TextMenu class to produce text menus
- Added MenuItem base class for menu items
- Added ActionMenuItem for menu items using an action
- Added SubMenuItem class for menu items presenting a submenu
- Added SeperatorItem class for menu seperators without functioninality
Signed-off-by: Tillmann Crueger <crueger@…>
|
-
Property mode
set to
100644
|
|
File size:
693 bytes
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * MenuItem.cpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Dec 10, 2009
|
|---|
| 5 | * Author: crueger
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | #include "Menu/MenuItem.hpp"
|
|---|
| 11 | #include "Menu/Menu.hpp"
|
|---|
| 12 | #include <sstream>
|
|---|
| 13 |
|
|---|
| 14 | MenuItem::MenuItem(char _trigger, const char* _description,Menu* menu) :
|
|---|
| 15 | trigger(_trigger)
|
|---|
| 16 | {
|
|---|
| 17 | description = new string(_description);
|
|---|
| 18 | menu->addItem(this);
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | MenuItem::~MenuItem()
|
|---|
| 22 | {
|
|---|
| 23 | delete description;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | void MenuItem::checkTrigger(char key) {
|
|---|
| 27 | if(key == trigger)
|
|---|
| 28 | doTrigger();
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | char MenuItem::getTrigger() {
|
|---|
| 32 | return trigger;
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | const string MenuItem::getDescription() {
|
|---|
| 36 | return *description;
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | const string MenuItem::formatEntry(){
|
|---|
| 40 | stringstream s;
|
|---|
| 41 | s << getTrigger() << " - " << getDescription();
|
|---|
| 42 |
|
|---|
| 43 | return s.str();
|
|---|
| 44 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.