1 /*
2  *  ppui/Menu.h
3  *
4  *  Copyright 2009 Peter Barth
5  *
6  *  This file is part of Milkytracker.
7  *
8  *  Milkytracker is free software: you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation, either version 3 of the License, or
11  *  (at your option) any later version.
12  *
13  *  Milkytracker is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with Milkytracker.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 /*
24  *  Menu.h
25  *  MilkyTracker
26  *
27  *  Created by Peter Barth on Fri Mar 04 2005.
28  *
29  */
30 
31 #ifndef MENU__H
32 #define MENU__H
33 
34 #include "BasicTypes.h"
35 #include "SimpleVector.h"
36 
37 class PPFont;
38 class PPGraphicsAbstract;
39 class PPContextMenu;
40 
41 enum MenuCommandIDs
42 {
43 	MenuCommandIDNew			= 0,
44 	MenuCommandIDCut			= 1,
45 	MenuCommandIDCopy			= 2,
46 	MenuCommandIDPaste			= 3,
47 	MenuCommandIDSelectAll		= 4,
48 	MenuCommandIDSelectNothing	= 5,
49 	MenuCommandIDUndo			= 7,
50 	MenuCommandIDRedo			= 8,
51 	MenuCommandIDHide			= 0x10000
52 };
53 
54 struct PPMenu
55 {
56 	struct Entry
57 	{
58 		PPString name;
59 		pp_int32 identifier;
60 		pp_uint32 state;
61 		PPContextMenu* subMenu;
62 
63 		Entry(const PPString& s, pp_int32 theId, pp_uint32 stat = 0, PPContextMenu* aSubMenu = NULL) :
namePPMenu::Entry64 			name(s),
65 			identifier(theId),
66 			state(stat),
67 			subMenu(aSubMenu)
68 		{
69 		}
70 
71 	};
72 
73 	PPSimpleVector<Entry> items;
74 	PPFont* font;
75 
76 	const PPColor* backColor;
77 	const PPColor* borderColor;
78 	const PPColor* selectionColor;
79 
80 	const PPColor* textBrightColor;
81 	const PPColor* textDarkColor;
82 
83 	bool subMenu;
84 	PPContextMenu* parentMenu;
85 
86 	PPMenu(PPFont* aFont, const PPColor& selectionColor, const PPColor& bgColor, bool bSubMenu = false);
87 
88 	pp_uint32 getMaxWidth() const;
89 	pp_uint32 getEntryHeight() const;
90 	PPRect getBoundingRect() const;
91 
92 	bool setState(pp_int32 theId, pp_uint32 newState);
93 
setSubMenuPPMenu94 	void setSubMenu(bool bSubMenu) { subMenu = bSubMenu; }
isSubMenuPPMenu95 	bool isSubMenu() const { return subMenu; }
96 
setParentMenuPPMenu97 	void setParentMenu(PPContextMenu* parent) { parentMenu = parent; }
getParentMenuPPMenu98 	PPContextMenu* getParentMenu() const { return parentMenu; }
99 
100 	void paint(PPGraphicsAbstract* g, pp_int32 px, pp_int32 py, pp_int32 menuSelection);
101 
setFontPPMenu102 	void setFont(PPFont* font) { this->font = font; }
103 
setTextBrightColorPPMenu104 	void setTextBrightColor(const PPColor& color) { textBrightColor = &color; }
setTextDarkColorPPMenu105 	void setTextDarkColor(const PPColor& color) { textDarkColor = &color; }
106 };
107 
108 #endif
109