Lumiera  0.pre.03
»edit your freedom«
panel-bar.cpp
Go to the documentation of this file.
1 /*
2  PanelBar - container to place widgets into the GDL dock attachment area
3 
4  Copyright (C)
5  2009, Joel Holdsworth <joel@airwebreathe.org.uk>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
14 
24 #include "stage/panel/panel.hpp"
25 #include "stage/draw/rectangle.hpp"
26 #include "include/logging.h"
27 
28 #include <boost/foreach.hpp>
29 #include <algorithm>
30 
31 using namespace Gtk;
32 using namespace Glib;
33 using namespace sigc;
34 using namespace std;
35 using namespace stage::workspace;
36 
37 namespace stage {
38 namespace widget {
39 
40 
41  PanelBar::PanelBar (panel::Panel& owner_panel, const gchar *stock_id)
42  : Box()
43  , panel_(owner_panel)
44  , panelButton_(StockID(stock_id))
45  , lockItem_(NULL)
46  {
47  set_border_width(1);
48 
49  panelButton_.set_relief(RELIEF_NONE);
50  panelButton_.set_can_focus(false);
51  panelButton_.show();
52  pack_start(panelButton_, PACK_SHRINK);
53 
55  }
56 
57 
58  void
60  {
61  REQUIRE(lockItem_ == NULL);
62 
63  // Add items for each type of panel
64  for (int i = 0; i < PanelManager::getPanelDescriptionCount(); i++)
65  {
66  uString title = uString(PanelManager::getPanelTitle(i));
67  uString slug (title);
68 
69  /* Slug should be a char only string, no spaces, numbers, or
70  * symbols. Currently all panel titles are single words.
71  * So the above works OK for now.
72  */
73 
74  slot<void> func = bind(mem_fun(*this,
76 
77  panelButton_.append (slug, title, func);
78 
84  }
85 
86 #if false
87  list.push_back( Menu_Helpers::SeparatorElem() );
88 #endif
89 
90  // Add extra commands
91  slot<void> hide = mem_fun(*this, &PanelBar::on_hide);
92  panelButton_.append("Hide","_Hide", hide);
93 
94  slot<void> lock = mem_fun(*this, &PanelBar::on_lock);
95  panelButton_.append ("Lock", "_Lock", lock);
96 
97 #if false
98  lockItem_ = dynamic_cast<CheckMenuItem*>(&list.back());
99  ENSURE (lockItem_);
100  lockItem_->set_active (panel_.is_locked());
101 #endif
102 
103 
104  slot<void> hfunc = bind(mem_fun(*this, &PanelBar::on_split_panel),
105  ORIENTATION_HORIZONTAL);
106 
107  panelButton_.append("SplitHorizontal", "Split _Horizontal",hfunc);
108 
109  slot<void> vfunc = bind(mem_fun(*this, &PanelBar::on_split_panel),
110  ORIENTATION_VERTICAL);
111  panelButton_.append("SplitVertical", "Split _Vertical", vfunc);
112 
113  }
114 
115 
116  void
117  PanelBar::on_panel_type (int type_index)
118  {
119  panel_.getPanelManager().switchPanel (panel_, type_index);
120  }
121 
122 
123  void
125  {
126  panel_.show(false);
127  }
128 
129 
130  void
132  {
133  REQUIRE(lockItem_);
134  static bool is_locking = false;
135 
136  if (!is_locking)
137  {
138  is_locking = true;
139 
140  const bool lock = !panel_.is_locked();
141  panel_.lock(lock);
142  lockItem_->set_active(lock);
143 
144  is_locking = false;
145  }
146  }
147 
148 
149  void
150  PanelBar::on_split_panel (Gtk::Orientation split_direction)
151  {
152  panel_.getPanelManager().splitPanel (panel_, split_direction);
153  }
154 
155 
156 }}// stage::widget
The global workspace with top-level windows.
Helper functions to work with rectangular screen ranges.
Gtk::CheckMenuItem * lockItem_
pointer to the lock menu item.
Definition: panel-bar.hpp:58
Management of dockable panels.
void splitPanel(panel::Panel &panel, Gtk::Orientation split_direction)
Splits a panel into two panels of the same type.
STL namespace.
void on_hide()
An event handler for when the "Hide" menu item is clicked.
Definition: panel-bar.cpp:124
This header is for including and configuring NoBug.
void show(bool show=true)
Shows or hides the panel.
Definition: panel.cpp:92
panel::Panel & panel_
reference to the owner panel
Definition: panel-bar.hpp:49
void lock(bool show=true)
Locks or unlocks the panel against modifications.
Definition: panel.cpp:125
The base class for all dockable panels.
Definition: panel.hpp:40
Base class and interface for all dockable panels.
void setupPanelButton()
Sets up panelButton, populating it with menu items.
Definition: panel-bar.cpp:59
void on_split_panel(Gtk::Orientation split_direction)
Event handler for when the split panel menu item is clicked.
Definition: panel-bar.cpp:150
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
void append(uString &slug, uString &title, sigc::slot< void > &callback, bool toggle=false)
Append a Menu Item to the Menu.
Definition: menu-button.cpp:99
void on_panel_type(int type_index)
An event handler for when a panel type is chosen.
Definition: panel-bar.cpp:117
workspace::PanelManager & getPanelManager()
Definition: panel.cpp:139
MenuButton panelButton_
The panel menu drop-down button widget, that will be displayed in the corner of the bar...
Definition: panel-bar.hpp:53
This file contains the definition of the main workspace window parent, which is the toplevel parent o...
void on_lock()
Event handler for when the "Lock" menu item is clicked.
Definition: panel-bar.cpp:131
Custom container widget to allow placing toolbar buttons into the active docking header area of GDL d...
void switchPanel(panel::Panel &old_panel, const int description_index)
Switches a panel from one type to another, without touching the underlying GdlDockItem.