summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/ruler.h
blob: 2e22896bdc2f7467ccf2d54fd5654378ac2c4b8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#ifndef SEEN_UI_WIDGET_RULER_H
#define SEEN_UI_WIDGET_RULER_H

/*
 * Authors:
 *   Ralf Stephan <ralf@ark.in-berlin.de>
 *
 * Copyright (C) 2005 The Authors
 *
 * Released under GNU GPL, read the file 'COPYING' for more information
 */

#include <gtkmm/eventbox.h>
#include <2geom/point.h>

struct SPCanvasItem;
class  SPDesktop;
namespace Glib {
    class ustring;
}

typedef struct _SPRuler SPRuler;

// This is an import of the now-deprecated Gtk::Ruler API.
namespace Gtk {
namespace Deprecated {

/** Base class for horizontal or vertical rulers.
 *
 * This is an abstract base for Gtk::HRuler and
 * Gtk::VRuler.  Users should only instantiate those types.
 */
class Ruler : public Widget
{
public:
  virtual ~Ruler();

protected:
  explicit Ruler(const Glib::ConstructParams& construct_params);
  explicit Ruler(SPRuler* castitem);

public:
  ///Provides access to the underlying C GtkObject.
  SPRuler*       gobj()       { return reinterpret_cast<SPRuler*>(gobject_); }

  ///Provides access to the underlying C GtkObject.
  const SPRuler* gobj() const { return reinterpret_cast<SPRuler*>(gobject_); }

protected:
  Ruler();

public:
  /** sets the range of the ruler.
   * <i>upper</i> and <i>lower</i> arguments denote the extents of the Ruler.
   * <i>max_size</i> is the largest number displayed by the ruler.
   * <i>position</i> gives the initial value of the ruler.
   * Rulers do not have sane defaults so this function should always be called.
   */
  void set_range(double lower, double upper, double position, double max_size);
  
  /** Retrieves values indicating the range and current position of a Gtk::Ruler.
   * See set_range().
   * 
   * @param lower Location to store lower limit of the ruler, or <tt>0</tt>.
   * @param upper Location to store upper limit of the ruler, or <tt>0</tt>.
   * @param position Location to store the current position of the mark on the ruler, or <tt>0</tt>.
   * @param max_size Location to store the maximum size of the ruler used when calculating
   * the space to leave for the text, or <tt>0</tt>.
   */
  void get_range(double& lower, double& upper, double& position, double& max_size);
};


/** Vertical Ruler */
class VRuler : public Ruler
{
  public:
  virtual ~VRuler();

public:
  ///Provides access to the underlying C GtkObject.
  SPRuler*       gobj()       { return reinterpret_cast<SPRuler*>(gobject_); }

  ///Provides access to the underlying C GtkObject.
  const SPRuler* gobj() const { return reinterpret_cast<SPRuler*>(gobject_); }

public:
  VRuler();
}; //class VRuler

/** Horizontal Ruler */
class HRuler : public Ruler
{
  public:
  virtual ~HRuler();

public:
  ///Provides access to the underlying C GtkObject.
  SPRuler*       gobj()       { return reinterpret_cast<SPRuler*>(gobject_); }

  ///Provides access to the underlying C GtkObject.
  const SPRuler* gobj() const { return reinterpret_cast<SPRuler*>(gobject_); }
  
public:
  HRuler();
}; // class HRuler
} // namespace Deprecated
} // namespace Gtk



namespace Inkscape {
namespace UI {
namespace Widget {

/**
 * Gtkmm facade/wrapper around sp_rulers.
 */
class Ruler : public Gtk::EventBox
{
public:
    void          init (SPDesktop*, Gtk::Widget&);
    void          get_range (double&, double&, double&, double&);
    void          set_range (double, double, double, double);
    void          update_metric();
    Glib::ustring get_tip();

protected:
    SPDesktop    *_dt;
    SPCanvasItem *_guide;
    Gtk::Widget  *_canvas_widget;
    Gtk::Deprecated::Ruler   *_r;
    bool         _horiz_f, _dragging;

    virtual bool on_button_press_event (GdkEventButton *);
    virtual bool on_motion_notify_event (GdkEventMotion *);
    virtual bool on_button_release_event (GdkEventButton *);

private:
    void canvas_get_pointer (int&, int&);
    Geom::Point get_event_dt();
};

/**
 * Horizontal ruler gtkmm wrapper.
 */
class HRuler : public Ruler
{
public:
    HRuler();
    ~HRuler();
};

/**
 * Vertical ruler gtkmm wrapper.
 */
class VRuler : public Ruler
{
public:
    VRuler();
    ~VRuler();
};

} // namespace Widget
} // namespace UI
} // namespace Inkscape


#endif // SEEN_UI_WIDGET_RULER_H


/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :