neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
popup_menu.hpp
Go to the documentation of this file.
1// popup_menu.hpp
2/*
3neogfx C++ App/Game Engine
4Copyright (c) 2015, 2020 Leigh Johnston. All Rights Reserved.
5
6This program is free software: you can redistribute it and / or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
23#include "window.hpp"
26
27namespace neogfx
28{
29 class popup_menu : public window
30 {
32 public:
33 static const window_style DEFAULT_STYLE =
44 public:
45 struct no_menu : std::logic_error { no_menu() : std::logic_error("neogfx::popup_menu::no_menu") {} };
46 public:
47 popup_menu(const point& aPosition, i_menu& aMenu, window_style aStyle = DEFAULT_STYLE);
48 popup_menu(i_widget& aParent, const point& aPosition, i_menu& aMenu, window_style aStyle = DEFAULT_STYLE);
49 popup_menu(const point& aPosition, window_style aStyle = DEFAULT_STYLE);
50 popup_menu(i_widget& aParent, const point& aPosition, window_style aStyle = DEFAULT_STYLE);
52 public:
53 bool has_menu() const;
54 i_menu& menu() const;
55 void set_menu(i_menu& aMenu, const point& aPosition = point{});
56 void clear_menu();
57 public:
58 void resized() override;
59 public:
60 void dismiss() override;
61 public:
62 double rendering_priority() const override;
63 public:
64 neogfx::size_policy size_policy() const override;
65 size minimum_size(optional_size const& aAvailableSpace = optional_size{}) const override;
66 size maximum_size(optional_size const& aAvailableSpace = optional_size{}) const override;
67 public:
68 color frame_color() const override;
69 public:
70 bool key_pressed(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override;
71 bool key_released(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override;
72 bool text_input(i_string const& aText) override;
73 private:
74 void init();
75 void close_sub_menu();
76 void update_position();
77 private:
78 sink iSink;
79 sink iSink2;
80 i_widget* iParentWidget;
81 i_menu* iMenu;
82 std::unique_ptr<popup_menu> iOpenSubMenu;
83 bool iOpeningSubMenu;
84 };
85}
i_menu & menu() const
bool has_menu() const
bool key_released(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override
bool key_pressed(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override
popup_menu(const point &aPosition, i_menu &aMenu, window_style aStyle=DEFAULT_STYLE)
popup_menu(i_widget &aParent, const point &aPosition, i_menu &aMenu, window_style aStyle=DEFAULT_STYLE)
size maximum_size(optional_size const &aAvailableSpace=optional_size{}) const override
void resized() override
popup_menu(i_widget &aParent, const point &aPosition, window_style aStyle=DEFAULT_STYLE)
popup_menu(const point &aPosition, window_style aStyle=DEFAULT_STYLE)
size minimum_size(optional_size const &aAvailableSpace=optional_size{}) const override
bool text_input(i_string const &aText) override
color frame_color() const override
void set_menu(i_menu &aMenu, const point &aPosition=point{})
neogfx::size_policy size_policy() const override
void dismiss() override
double rendering_priority() const override
#define meta_object(...)
Definition i_object.hpp:28