summaryrefslogtreecommitdiff
path: root/src/gui_menu.hh
blob: e2af2740e2618dca4b4664e27ce6e2a7450daf4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// -*- mode: c++; c-basic-offset: 2; -*-

#ifndef GUI_MENU_HH
#define GUI_MENU_HH

#include <string>

class GuiMenu {
public:
  class Listener {
  public:
    virtual ~Listener() {}

    virtual void item_activated(std::string const& id) = 0;

  protected:
    Listener() {}
  };

  virtual ~GuiMenu() {}

  static GuiMenu* create();

  virtual void add_item(std::string const& id, std::string const& label) = 0;
  // The returned menu lives as long as the root-menu, do not free
  // the pointer yourself
  virtual GuiMenu* add_menu(std::string const& label) = 0;
  virtual void add_separator() = 0;

  // Call to enable/disable menu item, searches sub menues if no such
  // item is found in this menu. Returns true if an item was found.
  virtual bool enable_item(std::string const& id, bool enable = true) = 0;

  virtual void add_listener(Listener* listener) = 0;
  virtual void remove_listener(Listener* listener) = 0;

protected:
  GuiMenu() {}
  GuiMenu(GuiMenu const&) = delete;
};

#endif  // GUI_MENU_HH