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) Lumiera.org
5  2009, Joel Holdsworth <joel@airwebreathe.org.uk>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
33 #include "stage/panel/panel.hpp"
34 #include "stage/draw/rectangle.hpp"
35 #include "include/logging.h"
36 
37 #include <boost/foreach.hpp>
38 #include <algorithm>
39 
40 using namespace Gtk;
41 using namespace Glib;
42 using namespace sigc;
43 using namespace std;
44 using namespace stage::workspace;
45 
46 namespace stage {
47 namespace widget {
48 
49 
50  PanelBar::PanelBar (panel::Panel& owner_panel, const gchar *stock_id)
51  : Box()
52  , panel_(owner_panel)
53  , panelButton_(StockID(stock_id))
54  , lockItem_(NULL)
55  {
56  set_border_width(1);
57 
58  panelButton_.set_relief(RELIEF_NONE);
59  panelButton_.set_can_focus(false);
60  panelButton_.show();
61  pack_start(panelButton_, PACK_SHRINK);
62 
64  }
65 
66 
67  void
69  {
70  REQUIRE(lockItem_ == NULL);
71 
72  // Add items for each type of panel
73  for (int i = 0; i < PanelManager::getPanelDescriptionCount(); i++)
74  {
75  uString title = uString(PanelManager::getPanelTitle(i));
76  uString slug (title);
77 
78  /* Slug should be a char only string, no spaces, numbers, or
79  * symbols. Currently all panel titles are single words.
80  * So the above works OK for now.
81  */
82 
83  slot<void> func = bind(mem_fun(*this,
85 
86  panelButton_.append (slug, title, func);
87 
93  }
94 
95 #if false
96  list.push_back( Menu_Helpers::SeparatorElem() );
97 #endif
98 
99  // Add extra commands
100  slot<void> hide = mem_fun(*this, &PanelBar::on_hide);
101  panelButton_.append("Hide","_Hide", hide);
102 
103  slot<void> lock = mem_fun(*this, &PanelBar::on_lock);
104  panelButton_.append ("Lock", "_Lock", lock);
105 
106 #if false
107  lockItem_ = dynamic_cast<CheckMenuItem*>(&list.back());
108  ENSURE (lockItem_);
109  lockItem_->set_active (panel_.is_locked());
110 #endif
111 
112 
113  slot<void> hfunc = bind(mem_fun(*this, &PanelBar::on_split_panel),
114  ORIENTATION_HORIZONTAL);
115 
116  panelButton_.append("SplitHorizontal", "Split _Horizontal",hfunc);
117 
118  slot<void> vfunc = bind(mem_fun(*this, &PanelBar::on_split_panel),
119  ORIENTATION_VERTICAL);
120  panelButton_.append("SplitVertical", "Split _Vertical", vfunc);
121 
122  }
123 
124 
125  void
126  PanelBar::on_panel_type (int type_index)
127  {
128  panel_.getPanelManager().switchPanel (panel_, type_index);
129  }
130 
131 
132  void
134  {
135  panel_.show(false);
136  }
137 
138 
139  void
141  {
142  REQUIRE(lockItem_);
143  static bool is_locking = false;
144 
145  if (!is_locking)
146  {
147  is_locking = true;
148 
149  const bool lock = !panel_.is_locked();
150  panel_.lock(lock);
151  lockItem_->set_active(lock);
152 
153  is_locking = false;
154  }
155  }
156 
157 
158  void
159  PanelBar::on_split_panel (Gtk::Orientation split_direction)
160  {
161  panel_.getPanelManager().splitPanel (panel_, split_direction);
162  }
163 
164 
165 }}// 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:67
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:133
This header is for including and configuring NoBug.
void show(bool show=true)
Shows or hides the panel.
Definition: panel.cpp:101
panel::Panel & panel_
reference to the owner panel
Definition: panel-bar.hpp:58
void lock(bool show=true)
Locks or unlocks the panel against modifications.
Definition: panel.cpp:134
The base class for all dockable panels.
Definition: panel.hpp:49
Base class and interface for all dockable panels.
void setupPanelButton()
Sets up panelButton, populating it with menu items.
Definition: panel-bar.cpp:68
void on_split_panel(Gtk::Orientation split_direction)
Event handler for when the split panel menu item is clicked.
Definition: panel-bar.cpp:159
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
void append(uString &slug, uString &title, sigc::slot< void > &callback, bool toggle=false)
Append a Menu Item to the Menu.
void on_panel_type(int type_index)
An event handler for when a panel type is chosen.
Definition: panel-bar.cpp:126
workspace::PanelManager & getPanelManager()
Definition: panel.cpp:148
MenuButton panelButton_
The panel menu drop-down button widget, that will be displayed in the corner of the bar...
Definition: panel-bar.hpp:62
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:140
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.