summaryrefslogtreecommitdiffstats
path: root/SidebarToolbox.h
blob: 1be8b6ab57a12f77bc4de6f342aee69f54f5322f (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef SIDEBARTOOLBOX_H_
#define SIDEBARTOOLBOX_H_

#include <gtk/gtk.h>
#include <map>
#include <list>
#include "EditManager.h"
#include "Sidebar.h"
#include "Tool.h"
#include "ToolSelector.h"


class Window;


class SidebarToolbox : Sidebar {
  private:
    GtkWidget *widget;
    
    Window *window;
    
    std::list<Tool*> tools;
    std::map<Tool*, GtkWidget*> buttons;
    std::map<GtkWidget*, Tool*> buttonsRev;
    
    Tool *activeTool;
    
    ToolSelector toolSelector;
    
    int cols, rows;
    
    void updateRows(bool changed);
    void activateTool(Tool *tool);
    
    // prevent shallow copy
    SidebarToolbox(const SidebarToolbox &w);
    const SidebarToolbox& operator=(const SidebarToolbox &w);
    
    static void buttonToggled(GtkWidget *button, SidebarToolbox *toolbox);
    static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation, SidebarToolbox *toolbox);
    
  public:
    SidebarToolbox(Window *window);
    virtual ~SidebarToolbox();
    
    GtkWidget* getWidget() {
      return widget;
    }
    
    void resetTool() {
      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(buttons[&toolSelector]), TRUE);
    }
    
    Tool& getActiveTool() {
      return *activeTool;
    }
    
    void addTool(Tool *tool);
    void removeTool(Tool *tool);
    
    void update();
};

#endif /*SIDEBARTOOLBOX_H_*/