Lumiera  0.pre.03
»edit your freedom«
panel.cpp
Go to the documentation of this file.
1 /*
2  Panel - common base class for all docking panels
3 
4  Copyright (C) Lumiera.org
5  2008, 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 
29 #include "stage/gtk-base.hpp"
30 #include "stage/panel/panel.hpp"
33 
34 #include <gdl/gdl-dock-item-grip.h>
35 
36 using namespace Gtk;
37 
38 namespace stage {
39 namespace panel{
40 
41  Panel::Panel (workspace::PanelManager& panelManager
42  ,Gdl::DockItem& dockItem
43  ,const gchar* longName
44  ,const gchar* stockID)
45  : Gtk::Box{Gtk::ORIENTATION_VERTICAL}
46  , panelManager_(panelManager)
47  , dockItem_(dockItem)
48  , panelBar_(*this, stockID)
49  {
50  // Set dockItems long-name property
51  Glib::Value<std::string> val;
52  val.init(val.value_type());
53  val.set(longName);
54  g_object_set_property (G_OBJECT (dockItem.gobj()), "long-name", val.gobj());
55 
56  /* Set the grip handle */
58  GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP(
59  gdl_dock_item_get_grip(dockItem.gobj()));
60  gdl_dock_item_grip_show_handle(grip);
61  gdl_dock_item_grip_set_label(grip, ((Widget&)panelBar_).gobj());
62  //gdl_dock_item_grip_set_cursor_type(grip, GDK_LEFT_PTR);
63 
64  /* Set up the panel body */
65  // Add this panel's container to the DockItem
66  dockItem.add((Gtk::Widget&)*this);
67 
68  /* Connect the signals */
69  dockItem.signal_hide().connect(
70  sigc::mem_fun(*this, &Panel::on_item_hidden));
71 
72  dockItem.show();
73  }
74 
75 
76  Panel::~Panel()
77  {
80 
81  #if false
82  /* Detach the panel bar */
83  GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP(
85  gdl_dock_item_get_grip(dockItem_.gobj()));
86  gtk_container_remove (GTK_CONTAINER(grip),
87  ((Widget&)panelBar_).gobj());
88 
89  /* Remove this panel's container from the DockItem */
90  dockItem_.remove((Gtk::Widget&)*this);
91  #endif
92  }
93 
94  Gdl::DockItem&
96  {
97  return dockItem_;
98  }
99 
100  void
102  {
103  //REQUIRE(dockItem != NULL);
104  if(show) dockItem_.show_item();
105  else dockItem_.hide_item();
106  }
107 
108  bool
109  Panel::is_shown() const
110  {
111  //REQUIRE(dockItem != NULL);
112  return dockItem_.get_visible();
113  }
114 
115  void
116  Panel::iconify()
117  {
118  dockItem_.iconify_item();
119  }
120 
121  bool
123  {
128  GdlDockItem *item = dockItem_.gobj();
129  REQUIRE(item != NULL);
130  return GDL_DOCK_ITEM_ICONIFIED (item);
131  }
132 
133  void
135  {
136  if(lock) dockItem_.lock();
137  else dockItem_.unlock();
138  }
139 
140  bool
141  Panel::is_locked() const
142  {
143  REQUIRE(dockItem_.gobj() != NULL);
144  return not GDL_DOCK_ITEM_NOT_LOCKED(dockItem_.gobj());
145  }
146 
149  {
150  return panelManager_;
151  }
152 
154  Panel::getWorkspaceWindow()
155  {
157  }
158 
159  sigc::signal<void>&
161  {
162  return hidePanelSignal_;
163  }
164 
165  void
167  {
168  hidePanelSignal_.emit();
169  }
170 
171 
172 }}// namespace stage::panel
Management of dockable panels.
bool is_iconified() const
Definition: panel.cpp:122
void on_item_hidden()
event handler when dockItem is hidden.
Definition: panel.cpp:166
void show(bool show=true)
Shows or hides the panel.
Definition: panel.cpp:101
void lock(bool show=true)
Locks or unlocks the panel against modifications.
Definition: panel.cpp:134
A class to manage DockItem objects for WorkspaceWindow.
Base class and interface for all dockable panels.
workspace::PanelManager & panelManager_
The owner panel manager object.
Definition: panel.hpp:103
sigc::signal< void > hidePanelSignal_
signal that fires when the dock item is hidden.
Definition: panel.hpp:109
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
widget::PanelBar panelBar_
panel bar to attach to the panel grip.
Definition: panel.hpp:112
Gdl::DockItem & dockItem_
owner dock item widget that will host the widgets in this panel.
Definition: panel.hpp:106
WorkspaceWindow & getWorkspaceWindow()
Returns a reference to the owner workspace window.
The main Lumiera workspace window.
workspace::PanelManager & getPanelManager()
Definition: panel.cpp:148
This file contains the definition of the main workspace window parent, which is the toplevel parent o...
sigc::signal< void > & signal_hidePanel()
fires when the dock item gets hidden.
Definition: panel.cpp:160
Gdl::DockItem & getDockItem()
Definition: panel.cpp:95
A set of basic GTK includes for the UI.