~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/ui/widget/page-sizer.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-2006 Authors
 
8
 *
 
9
 * Released under GNU GPL.  Read the file 'COPYING' for more information.
 
10
 */
 
11
 
 
12
#ifndef INKSCAPE_UI_WIDGET_PAGE_SIZER__H
 
13
#define INKSCAPE_UI_WIDGET_PAGE_SIZER__H
 
14
 
 
15
#include <gtkmm.h>
 
16
#include <sigc++/sigc++.h>
 
17
#include "ui/widget/registry.h"
 
18
#include "ui/widget/registered-widget.h"
 
19
#include "helper/units.h"
 
20
 
 
21
 
 
22
namespace Inkscape {    
 
23
namespace UI {
 
24
namespace Widget {
 
25
 
 
26
/**
 
27
 * Data class used to store common paper dimensions.  Used to make
 
28
 * PageSizer's _paperSizeTable. 
 
29
 */ 
 
30
class PaperSize
 
31
{
 
32
public:
 
33
 
 
34
    /**
 
35
     * Default constructor
 
36
     */
 
37
    PaperSize()
 
38
        { init(); }
 
39
 
 
40
    /**
 
41
     * Main constructor.  Use this one.
 
42
     */
 
43
    PaperSize(const Glib::ustring &nameArg,
 
44
                  double smallerArg,
 
45
                  double largerArg,
 
46
                          SPUnitId unitArg)
 
47
            {
 
48
            name    = nameArg;
 
49
            smaller = smallerArg;
 
50
            larger  = largerArg;
 
51
            unit    = unitArg;
 
52
            }
 
53
 
 
54
    /**
 
55
     * Copy constructor
 
56
     */
 
57
    PaperSize(const PaperSize &other)
 
58
        { assign(other); }
 
59
        
 
60
    /**
 
61
     * Assignment operator
 
62
     */      
 
63
    PaperSize &operator=(const PaperSize &other)
 
64
        { assign(other); return *this; }
 
65
 
 
66
    /**
 
67
     * Destructor
 
68
     */      
 
69
        virtual ~PaperSize()
 
70
            {}
 
71
            
 
72
    /**
 
73
     * Name of this paper specification
 
74
     */      
 
75
    Glib::ustring name;
 
76
    
 
77
    /**
 
78
     * The lesser of the two dimensions
 
79
     */      
 
80
    double smaller;
 
81
    
 
82
    /**
 
83
     * The greater of the two dimensions
 
84
     */      
 
85
    double larger;
 
86
    
 
87
    /**
 
88
     * The units (px, pt, mm, etc) of this specification
 
89
     */      
 
90
    SPUnitId unit;
 
91
 
 
92
private:
 
93
 
 
94
        void init()
 
95
            {
 
96
            name    = "";
 
97
            smaller = 0.0;
 
98
            larger  = 0.0;
 
99
            unit    = SP_UNIT_PX;
 
100
            }
 
101
 
 
102
        void assign(const PaperSize &other)
 
103
            {
 
104
            name    = other.name;
 
105
            smaller = other.smaller;
 
106
            larger  = other.larger;
 
107
            unit    = other.unit;
 
108
        }
 
109
 
 
110
};
 
111
 
 
112
 
 
113
 
 
114
 
 
115
 
 
116
/**
 
117
 * A compound widget that allows the user to select the desired
 
118
 * page size.  This widget is used in DocumentPreferences 
 
119
 */ 
 
120
class PageSizer : public Gtk::VBox
 
121
{
 
122
public:
 
123
 
 
124
    /**
 
125
     * Constructor
 
126
     */
 
127
    PageSizer(Registry & _wr);
 
128
 
 
129
    /**
 
130
     * Destructor
 
131
     */
 
132
    virtual ~PageSizer();
 
133
 
 
134
    /**
 
135
     * Set up or reset this widget
 
136
     */      
 
137
    void init ();
 
138
    
 
139
    /**
 
140
     * Set the page size to the given dimensions.  If 'changeList' is
 
141
     * true, then reset the paper size list to the closest match
 
142
     */
 
143
    void setDim (double w, double h, bool changeList=true);
 
144
 
 
145
protected:
 
146
 
 
147
    /**
 
148
     * Our handy table of all 'standard' paper sizes.
 
149
     */      
 
150
    std::map<Glib::ustring, PaperSize> _paperSizeTable;
 
151
 
 
152
    /**
 
153
     *  Find the closest standard paper size in the table, to the
 
154
     */
 
155
    Gtk::ListStore::iterator find_paper_size (double w, double h) const;
 
156
 
 
157
    void fire_fit_canvas_to_selection_or_drawing();
 
158
    
 
159
    Gtk::Tooltips _tips;
 
160
    
 
161
    //### The Paper Size selection list
 
162
    Gtk::HBox _paperSizeListBox;
 
163
    Gtk::Label _paperSizeListLabel;
 
164
    class PaperSizeColumns : public Gtk::TreeModel::ColumnRecord
 
165
        {
 
166
        public:
 
167
            PaperSizeColumns()
 
168
               { add(nameColumn); add(descColumn);  }
 
169
            Gtk::TreeModelColumn<Glib::ustring> nameColumn;
 
170
            Gtk::TreeModelColumn<Glib::ustring> descColumn;
 
171
        };
 
172
 
 
173
    PaperSizeColumns _paperSizeListColumns;
 
174
    Glib::RefPtr<Gtk::ListStore> _paperSizeListStore;
 
175
    Gtk::TreeView _paperSizeList;
 
176
    Glib::RefPtr<Gtk::TreeSelection> _paperSizeListSelection;
 
177
    Gtk::ScrolledWindow  _paperSizeListScroller;
 
178
    //callback
 
179
    void on_paper_size_list_changed();
 
180
    sigc::connection    _paper_size_list_connection;
 
181
    
 
182
    //### Portrait or landscape orientation
 
183
    Gtk::HBox           _orientationBox;
 
184
    Gtk::Label          _orientationLabel;
 
185
    Gtk::RadioButton    _portraitButton;
 
186
        Gtk::RadioButton    _landscapeButton;
 
187
    //callbacks
 
188
    void on_portrait();
 
189
    void on_landscape();
 
190
    sigc::connection    _portrait_connection;
 
191
        sigc::connection    _landscape_connection;
 
192
 
 
193
    //### Custom size frame
 
194
    Gtk::Frame           _customFrame;
 
195
    Gtk::Table           _customTable;
 
196
    RegisteredUnitMenu   _dimensionUnits;
 
197
    RegisteredScalarUnit _dimensionWidth;
 
198
        RegisteredScalarUnit _dimensionHeight;
 
199
        Gtk::Button          _fitPageButton;
 
200
    //callback
 
201
    void on_value_changed();
 
202
    sigc::connection    _changedw_connection;
 
203
        sigc::connection    _changedh_connection;
 
204
 
 
205
    Registry            *_widgetRegistry;
 
206
 
 
207
    //### state - whether we are currently landscape or portrait
 
208
    bool                 _landscape;
 
209
 
 
210
};
 
211
 
 
212
} // namespace Widget
 
213
} // namespace UI
 
214
} // namespace Inkscape
 
215
 
 
216
 
 
217
#endif /* INKSCAPE_UI_WIDGET_PAGE_SIZER__H */
 
218
 
 
219
/*
 
220
  Local Variables:
 
221
  mode:c++
 
222
  c-file-style:"stroustrup"
 
223
  c-file-offsets:((innamespace . 0)(inline-open . 0))
 
224
  indent-tabs-mode:nil
 
225
  fill-column:99
 
226
  End:
 
227
*/
 
228
// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :