summaryrefslogtreecommitdiffstats
path: root/Window.cpp
blob: a1e391760c5536d4b7af366f8ca0c4feb118b1fc (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
#include "Window.h"
#include "WindowManager.h"


gboolean Window::deleteEvent(GtkWidget *widget, GdkEvent *event, Window *window) {
  gtk_widget_hide(widget);
  
  window->manager->windowClosed(window);
  
  return TRUE;
}

Window::Window(GdkGLConfig *glconfig, WindowManager *manager)
 : editor(this), drawer(this, glconfig), sidebar(&editor)
{
  this->manager = manager;
  
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
  g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(deleteEvent), this);
  
  GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER(window), vbox);
  
  gtk_box_pack_start(GTK_BOX(vbox), uiManager.getMenu(), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), uiManager.getToolbar(), FALSE, FALSE, 0);
  
  gtk_window_add_accel_group(GTK_WINDOW(window), uiManager.getAccels());
  
  GtkWidget *hPaned = gtk_hpaned_new();
  gtk_box_pack_end(GTK_BOX(vbox), hPaned, TRUE, TRUE, 0);
  
  gtk_paned_pack1(GTK_PANED(hPaned), drawer.getWidget(), TRUE, TRUE);
  
  gtk_paned_pack2(GTK_PANED(hPaned), sidebar.getWidget(), FALSE, TRUE);
  sidebar.update();
  
  gtk_widget_show_all(vbox);
}

Window::~Window() {
  gtk_widget_destroy(window);
}

void Window::show() {
  gtk_widget_show(window);
}

void Window::update() {
  drawer.update();
  sidebar.update();
}