1 /** \file
2 * \brief Widget for specifying page size; part of Document Preferences dialog.
3 *
4 * Author:
5 * Ralf Stephan <ralf@ark.in-berlin.de>
6 *
7 * Copyright (C) 2005 Authors
8 *
9 * Released under GNU GPL. Read the file 'COPYING' for more information.
10 */
12 #ifndef INKSCAPE_UI_WIDGET_PAGE_SIZER__H
13 #define INKSCAPE_UI_WIDGET_PAGE_SIZER__H
15 #include <sigc++/sigc++.h>
16 #include <gtkmm.h>
17 #include "ui/widget/registry.h"
18 #include "ui/widget/registered-widget.h"
19 #include "helper/units.h"
22 namespace Inkscape {
23 namespace UI {
24 namespace Widget {
26 /**
27 * Class used to store common paper dimensions
28 */
29 class PaperSize
30 {
31 public:
32 PaperSize()
33 { init(); }
34 PaperSize(const Glib::ustring &nameArg,
35 double smallerArg,
36 double largerArg,
37 SPUnitId unitArg)
38 {
39 name = nameArg;
40 smaller = smallerArg;
41 larger = largerArg;
42 unit = unitArg;
43 }
45 PaperSize(const PaperSize &other)
46 { assign(other); }
48 PaperSize &operator=(const PaperSize &other)
49 { assign(other); return *this; }
51 virtual ~PaperSize()
52 {}
54 void init()
55 {
56 name = "";
57 smaller = 0.0;
58 larger = 0.0;
59 unit = SP_UNIT_PX;
60 }
62 void assign(const PaperSize &other)
63 {
64 name = other.name;
65 smaller = other.smaller;
66 larger = other.larger;
67 unit = other.unit;
68 }
70 Glib::ustring name;
71 double smaller;
72 double larger;
73 SPUnitId unit;
74 };
80 /**
81 * Widget containing all widgets for specifying page size.
82 */
83 class PageSizer : public Gtk::VBox
84 {
85 public:
87 /**
88 * Constructor
89 */
90 PageSizer();
92 /**
93 * Destructor
94 */
95 virtual ~PageSizer();
97 void init (Registry& reg);
98 void setDim (double w, double h, bool changeList=true);
99 bool _landscape;
101 protected:
103 int find_paper_size (double w, double h) const;
104 void fire_fit_canvas_to_selection_or_drawing();
105 void on_portrait();
106 void on_landscape();
107 void on_value_changed();
108 void on_paper_size_list_changed();
110 RegisteredUnitMenu _rum;
111 RegisteredScalarUnit _rusw, _rush;
113 //# Various things for a ComboBox
114 Gtk::ComboBoxText _paperSizeList;
115 std::map<Glib::ustring, PaperSize> paperSizeTable;
117 Gtk::RadioButton _portraitButton;
118 Gtk::RadioButton _landscapeButton;
119 sigc::connection _paper_size_list_connection;
120 sigc::connection _portrait_connection;
121 sigc::connection _landscape_connection;
122 sigc::connection _changedw_connection;
123 sigc::connection _changedh_connection;
124 Registry *_wr;
125 };
127 } // namespace Widget
128 } // namespace UI
129 } // namespace Inkscape
132 #endif /* INKSCAPE_UI_WIDGET_PAGE_SIZER__H */
134 /*
135 Local Variables:
136 mode:c++
137 c-file-style:"stroustrup"
138 c-file-offsets:((innamespace . 0)(inline-open . 0))
139 indent-tabs-mode:nil
140 fill-column:99
141 End:
142 */
143 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :