1 /**
2 *
3 * \brief Dialog for renaming layers
4 *
5 * Author:
6 * Bryce W. Harrington <bryce@bryceharrington.com>
7 *
8 * Copyright (C) 2004 Bryce Harrington
9 *
10 * Released under GNU GPL. Read the file 'COPYING' for more information
11 */
13 #ifndef INKSCAPE_DIALOG_LAYER_PROPERTIES_H
14 #define INKSCAPE_DIALOG_LAYER_PROPERTIES_H
16 #include <gtkmm/dialog.h>
17 #include <gtkmm/notebook.h>
18 #include <gtkmm/separator.h>
19 #include <gtkmm/frame.h>
20 #include <gtkmm/entry.h>
21 #include <gtkmm/label.h>
22 #include <gtkmm/table.h>
23 #include <gtkmm/combobox.h>
24 #include <gtkmm/liststore.h>
26 #include "selection.h"
27 #include "layer-fns.h"
29 namespace Inkscape {
30 namespace UI {
31 namespace Dialogs {
33 class LayerPropertiesDialog : public Gtk::Dialog {
34 public:
35 LayerPropertiesDialog();
36 virtual ~LayerPropertiesDialog();
38 Glib::ustring getName() const { return "LayerPropertiesDialog"; }
40 static void showRename(SPDesktop *desktop, SPObject *layer) {
41 _showDialog(Rename::instance(), desktop, layer);
42 }
43 static void showCreate(SPDesktop *desktop, SPObject *layer) {
44 _showDialog(Create::instance(), desktop, layer);
45 }
47 protected:
48 struct Strategy {
49 virtual ~Strategy() {}
50 virtual void setup(LayerPropertiesDialog &)=0;
51 virtual void perform(LayerPropertiesDialog &)=0;
52 };
53 struct Rename : public Strategy {
54 static Rename &instance() { static Rename instance; return instance; }
55 void setup(LayerPropertiesDialog &dialog);
56 void perform(LayerPropertiesDialog &dialog);
57 };
58 struct Create : public Strategy {
59 static Create &instance() { static Create instance; return instance; }
60 void setup(LayerPropertiesDialog &dialog);
61 void perform(LayerPropertiesDialog &dialog);
62 };
64 friend class Rename;
65 friend class Create;
67 Strategy *_strategy;
68 SPDesktop *_desktop;
69 SPObject *_layer;
71 class PositionDropdownColumns : public Gtk::TreeModel::ColumnRecord {
72 public:
73 Gtk::TreeModelColumn<LayerRelativePosition> position;
74 Gtk::TreeModelColumn<Glib::ustring> name;
76 PositionDropdownColumns() {
77 add(position); add(name);
78 }
79 };
81 Gtk::Label _layer_name_label;
82 Gtk::Entry _layer_name_entry;
83 Gtk::Label _layer_position_label;
84 Gtk::ComboBox _layer_position_combo;
85 Gtk::Table _layout_table;
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 :