2019-02-11 16:43:43 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibGUI/GMenuItem.h>
|
2019-02-12 12:08:35 +03:00
|
|
|
#include <AK/Function.h>
|
2019-04-18 13:25:00 +03:00
|
|
|
#include <AK/Retainable.h>
|
|
|
|
#include <AK/Retained.h>
|
2019-02-11 16:43:43 +03:00
|
|
|
#include <AK/Vector.h>
|
|
|
|
|
2019-02-12 16:09:48 +03:00
|
|
|
class GAction;
|
2019-04-12 18:10:30 +03:00
|
|
|
class Point;
|
2019-02-12 16:09:48 +03:00
|
|
|
|
2019-02-11 16:43:43 +03:00
|
|
|
class GMenu {
|
|
|
|
public:
|
2019-02-11 17:37:12 +03:00
|
|
|
explicit GMenu(const String& name);
|
2019-02-11 16:43:43 +03:00
|
|
|
~GMenu();
|
|
|
|
|
2019-02-12 12:08:35 +03:00
|
|
|
static GMenu* from_menu_id(int);
|
|
|
|
|
2019-02-26 00:06:55 +03:00
|
|
|
GAction* action_at(int);
|
2019-02-12 16:09:48 +03:00
|
|
|
|
2019-04-18 13:25:00 +03:00
|
|
|
void add_action(Retained<GAction>);
|
2019-02-11 17:37:12 +03:00
|
|
|
void add_separator();
|
|
|
|
|
2019-05-16 02:06:21 +03:00
|
|
|
void popup(const Point& screen_position);
|
2019-04-14 02:53:19 +03:00
|
|
|
void dismiss();
|
2019-04-12 18:10:30 +03:00
|
|
|
|
2019-02-12 12:08:35 +03:00
|
|
|
Function<void(unsigned)> on_item_activation;
|
|
|
|
|
2019-02-11 16:43:43 +03:00
|
|
|
private:
|
2019-02-12 02:52:19 +03:00
|
|
|
friend class GMenuBar;
|
2019-04-18 13:25:00 +03:00
|
|
|
|
2019-02-12 02:52:19 +03:00
|
|
|
int menu_id() const { return m_menu_id; }
|
|
|
|
int realize_menu();
|
2019-02-13 20:48:22 +03:00
|
|
|
void unrealize_menu();
|
2019-02-12 02:52:19 +03:00
|
|
|
|
2019-05-24 05:31:00 +03:00
|
|
|
int m_menu_id { -1 };
|
2019-02-11 17:37:12 +03:00
|
|
|
String m_name;
|
2019-02-12 16:09:48 +03:00
|
|
|
Vector<OwnPtr<GMenuItem>> m_items;
|
2019-02-11 16:43:43 +03:00
|
|
|
};
|