MenuBar.h
1/* Copyright (C) 2015 Marc Boris Duerner
2 Copyright (C) 2015 Laurentiu-Gheorghe Crisan
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 As a special exception, you may use this file as part of a free
10 software library without restriction. Specifically, if other files
11 instantiate templates or use macros or inline functions from this
12 file, or you compile this file and link it with other files to
13 produce an executable, this file does not by itself cause the
14 resulting executable to be covered by the GNU General Public
15 License. This exception does not however invalidate any other
16 reasons why the executable file might be covered by the GNU Library
17 General Public License.
18
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
23
24 You should have received a copy of the GNU Lesser General Public
25 License along with this library; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 MA 02110-1301 USA
28*/
29#ifndef PT_FORMS_MENUBAR_H
30#define PT_FORMS_MENUBAR_H
31
32#include <Pt/Forms/Api.h>
33#include <Pt/Forms/MenuBase.h>
34#include <Pt/Forms/MenuBarItem.h>
35#include <Pt/Forms/Button.h>
36#include <Pt/Forms/Control.h>
37#include <Pt/Forms/FlowLayout.h>
38#include <Pt/SmartPtr.h>
39#include <vector>
40
41namespace Pt {
42
43namespace Forms {
44
45class Menu;
46class MenuBar;
47
76class PT_FORMS_API MenuBar : public Control
77 , protected MenuBase
78{
79 typedef Control Base;
80
81 public:
85
88 virtual ~MenuBar();
89
95 void addItem(MenuBarItem& item);
96
100
107
111
117 const Pt::Gfx::Pen& contour() const;
118
121 void setContour(const Pt::Gfx::Pen& p);
122
123 protected:
124
125 virtual Pt::Forms::Widget* onFindMenu(const Pt::Gfx::PointF& screenPos);
126
127 virtual void onAddMenu(MenuSubItem& item);
128
129 virtual void onRemoveMenu(MenuSubItem& item);
130
131 virtual void onOpenMenu(MenuSubItem& item);
132
133 virtual void onCloseMenu(MenuSubItem& item);
134
135 virtual void onCancel();
136
137 virtual void onInvalidate();
138
139 virtual Pt::Gfx::SizeF onMeasure(const Pt::Forms::SizePolicy& policy);
140
141 virtual void onLayout(const Pt::Gfx::RectF& rect);
142
143 virtual void onPaint(PaintContext& context, const Pt::Gfx::RectF& rect);
144
145 virtual bool onMouseEvent(const Pt::Forms::MouseEvent& ev);
146
147 virtual bool onTouchEvent(const Pt::Forms::TouchEvent& ev);
148
149 void onItemClicked(MenuItemBase& item);
150
152
153 private:
154 Pt::Forms::FlowLayout _layout;
155 MenuSubItem* _currentItem;
156 Pt::AutoPtr<Pt::Gfx::Brush> _background;
158 Pt::Gfx::Brush _brush;
159 Pt::Gfx::Pen _pen;
160};
161
162}}
163
164#endif
Policy based Auto pointer.
Definition SmartPtr.h:291
Control()
Creates an unparented control.
Arranges children in a single row or column.
Definition FlowLayout.h:72
Represents a top-level entry in a menu bar.
Definition MenuBarItem.h:54
Represents a horizontal bar of top-level menus.
Definition MenuBar.h:78
virtual void onPaint(PaintContext &context, const Pt::Gfx::RectF &rect)
Paints custom content in local coordinates.
virtual void onLayout(const Pt::Gfx::RectF &rect)
Assigns geometry to direct children within rect.
MenuBar()
Creates an empty menu bar.
void onProcessMouseEvent(const Pt::Forms::MouseEvent &ev)
Routes mouse input to the frontmost eligible child or this control.
virtual bool onTouchEvent(const Pt::Forms::TouchEvent &ev)
Handles touch input in local coordinates.
void addItem(MenuBarItem &item)
Adds top-level entry item to this menu bar.
void setContour(const Pt::Gfx::Pen &p)
Sets a local contour pen.
void setBackground(const Pt::Gfx::Brush &b)
Sets a local background brush.
const Pt::Gfx::Brush & background() const
Returns the background brush.
const Pt::Gfx::Pen & contour() const
Returns the contour pen.
virtual Pt::Gfx::SizeF onMeasure(const Pt::Forms::SizePolicy &policy)
Measures intrinsic content for effective policy policy.
virtual ~MenuBar()
Destroys the menu bar.
virtual bool onMouseEvent(const Pt::Forms::MouseEvent &ev)
Handles mouse input in local coordinates.
virtual void onInvalidate()
Updates derived state after invalidation.
void removeItem(MenuBarItem &item)
Removes top-level entry item from this menu bar.
MenuBase()
Creates an unassociated menu coordination interface.
Represents the common content and activation behavior of a menu item.
Definition MenuItemBase.h:55
Represents a menu item that opens a nested menu.
Definition MenuSubItem.h:57
Represents a popup menu containing commands and nested menus.
Definition Menu.h:71
Pointer movement or button change.
Definition MouseEvent.h:134
Active painting session on a Forms paint surface.
Definition PaintContext.h:51
Constraint used when measuring a control.
Definition SizePolicy.h:48
Touch press, move, or release.
Definition TouchEvent.h:51
Common type of every visual Forms object.
Definition Widget.h:105
Fill color, gradient or texture.
Definition Brush.h:151
Outline color, width and style.
Definition Pen.h:59
Graphical user interfaces.
Definition ActivateEvent.h:40
Core module.
Definition Allocator.h:33