1 /** @file
2 * @brief Dialog for renaming layers
3 */
4 /* Author:
5 * Bryce W. Harrington <bryce@bryceharrington.com>
6 *
7 * Copyright (C) 2004 Bryce Harrington
8 *
9 * Released under GNU GPL. Read the file 'COPYING' for more information
10 */
12 #ifndef INKSCAPE_DIALOG_LAYER_PROPERTIES_H
13 #define INKSCAPE_DIALOG_LAYER_PROPERTIES_H
15 #include <gtkmm/dialog.h>
16 #include <gtkmm/notebook.h>
17 #include <gtkmm/separator.h>
18 #include <gtkmm/frame.h>
19 #include <gtkmm/entry.h>
20 #include <gtkmm/label.h>
21 #include <gtkmm/table.h>
22 #include <gtkmm/combobox.h>
23 #include <gtkmm/liststore.h>
25 #include "selection.h"
26 #include "layer-fns.h"
28 namespace Inkscape {
29 namespace UI {
30 namespace Dialogs {
32 class LayerPropertiesDialog : public Gtk::Dialog {
33 public:
34 LayerPropertiesDialog();
35 virtual ~LayerPropertiesDialog();
37 Glib::ustring getName() const { return "LayerPropertiesDialog"; }
39 static void showRename(SPDesktop *desktop, SPObject *layer) {
40 _showDialog(Rename::instance(), desktop, layer);
41 }
42 static void showCreate(SPDesktop *desktop, SPObject *layer) {
43 _showDialog(Create::instance(), desktop, layer);
44 }
46 protected:
47 struct Strategy {
48 virtual ~Strategy() {}
49 virtual void setup(LayerPropertiesDialog &)=0;
50 virtual void perform(LayerPropertiesDialog &)=0;
51 };
52 struct Rename : public Strategy {
53 static Rename &instance() { static Rename instance; return instance; }
54 void setup(LayerPropertiesDialog &dialog);
55 void perform(LayerPropertiesDialog &dialog);
56 };
57 struct Create : public Strategy {
58 static Create &instance() { static Create instance; return instance; }
59 void setup(LayerPropertiesDialog &dialog);
60 void perform(LayerPropertiesDialog &dialog);
61 };
63 friend class Rename;
64 friend class Create;
66 Strategy *_strategy;
67 SPDesktop *_desktop;
68 SPObject *_layer;
70 class PositionDropdownColumns : public Gtk::TreeModel::ColumnRecord {
71 public:
72 Gtk::TreeModelColumn<LayerRelativePosition> position;
73 Gtk::TreeModelColumn<Glib::ustring> name;
75 PositionDropdownColumns() {
76 add(position); add(name);
77 }
78 };
80 Gtk::Label _layer_name_label;
81 Gtk::Entry _layer_name_entry;
82 Gtk::Label _layer_position_label;
83 Gtk::ComboBox _layer_position_combo;
84 Gtk::Table _layout_table;
85 bool _position_visible;
87 PositionDropdownColumns _dropdown_columns;
88 Gtk::CellRendererText _label_renderer;
89 Glib::RefPtr<Gtk::ListStore> _dropdown_list;
91 Gtk::Button _close_button;
92 Gtk::Button _apply_button;
94 sigc::connection _destroy_connection;
96 static LayerPropertiesDialog &_instance() {
97 static LayerPropertiesDialog instance;
98 return instance;
99 }
101 void _setDesktop(SPDesktop *desktop);
102 void _setLayer(SPObject *layer);
104 static void _showDialog(Strategy &strategy, SPDesktop *desktop, SPObject *layer);
105 void _apply();
106 void _close();
108 void _setup_position_controls();
109 void _prepareLabelRenderer(Gtk::TreeModel::const_iterator const &row);
111 private:
112 LayerPropertiesDialog(LayerPropertiesDialog const &); // no copy
113 LayerPropertiesDialog &operator=(LayerPropertiesDialog const &); // no assign
114 };
116 } // namespace
117 } // namespace
118 } // namespace
121 #endif //INKSCAPE_DIALOG_LAYER_PROPERTIES_H
123 /*
124 Local Variables:
125 mode:c++
126 c-file-style:"stroustrup"
127 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
128 indent-tabs-mode:nil
129 fill-column:99
130 End:
131 */
132 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :