CEBL  2.1
Tab.cpp
Go to the documentation of this file.
1 #include "Tab.hpp"
2 
3 #include <sstream>
4 using namespace std;
5 
6 
7 Tab::Tab(string title, GtkWidget *notebook, CEBLViewGTK * view)
8 {
9  this->view = view;
10  this->title = title;
11  container = gtk_vbox_new(FALSE,0);
12  if(notebook!=NULL)
13  {
14  string text = "<small>" + title + "</small>";
15  GtkWidget * label = gtk_label_new("");
16  gtk_label_set_markup(GTK_LABEL(label),text.c_str());
17  gtk_notebook_append_page(GTK_NOTEBOOK(notebook),container,label);
18  }
19  //gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(notebook),container,true);
20  //gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(notebook),container,true);
21  gtk_widget_show_all(container);
22 
23  this->notebook_id = gtk_notebook_page_num(GTK_NOTEBOOK(notebook),container);
24 }
25 
27 {
28 
29 }
30 
31 string Tab::GetTitle()
32 {
33  return title;
34 }
35 
36 GtkWidget *Tab::GetContainer()
37 {
38  return container;
39 }
40 
41 void Tab::TabRemove(GtkWidget *widget)
42 {
43  gtk_container_remove(GTK_CONTAINER(container),widget);
44 }
45 
47 void Tab::TabAdd(GtkWidget * widget, bool expand, bool fill, int padding)
48 {
49  gtk_box_pack_start(GTK_BOX(container), widget, expand, fill, padding);
50  gtk_widget_show_all(widget);
51 }
52 
54 void Tab::TabAdd(GtkWidget * widget)
55 {
56  TabAdd(widget, false, false, 2);
57 }
58 
60 void Tab::TabFrameAdd(GtkWidget * widget, const char * title, bool expand, bool fill)
61 {
62  TabAdd(TabFrameCreate(widget, title), expand, fill, 5);
63 }
64 
66 GtkWidget *Tab::TabFrameCreate(GtkWidget * widget, const char * title)
67 {
68  GtkWidget *outer_align = gtk_alignment_new(0,0,1,1);
69  GtkWidget *frame = gtk_frame_new(title);
70  GtkWidget *inner_align = gtk_alignment_new(0,0,0,1);
71 
72  gtk_container_add(GTK_CONTAINER(inner_align),widget);
73  gtk_alignment_set_padding(GTK_ALIGNMENT(inner_align),5,5,5,5);
74 
75  gtk_container_add(GTK_CONTAINER(frame),inner_align);
76 
77  gtk_container_add(GTK_CONTAINER(outer_align),frame);
78  gtk_alignment_set_padding(GTK_ALIGNMENT(outer_align),5,5,5,5);
79 
80  return outer_align;
81 }
82 
83