Code

remove g++ 4.1.1 compiler errors
[inkscape.git] / src / rubberband.cpp
1 #define __RUBBERBAND_C__
3 /**
4  * \file src/rubberband.cpp
5  * \brief Rubberbanding selector
6  *
7  * Author:
8  *   Lauris Kaplinski <lauris@kaplinski.com>
9  *
10  * Copyright (C) 1999-2002 Lauris Kaplinski
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #include "display/sodipodi-ctrlrect.h"
16 #include "desktop.h"
17 #include "inkscape.h"
18 #include "desktop-handles.h"
19 #include "rubberband.h"
21 Inkscape::Rubberband *Inkscape::Rubberband::_instance = NULL;
23 Inkscape::Rubberband::Rubberband()
24     : _desktop(SP_ACTIVE_DESKTOP), _canvas(NULL), _started(false)
25 {
27 }
29 void Inkscape::Rubberband::start(SPDesktop *d, NR::Point const &p)
30 {
31     stop();
32     _desktop = d;
33     _start = p;
34     _started = true;
36     sp_canvas_force_full_redraw_after_interruptions(_desktop->canvas, 5);
37 }
39 void Inkscape::Rubberband::stop()
40 {
41     if (_canvas) {
42         gtk_object_destroy((GtkObject *) _canvas);
43         _canvas = NULL;
44         sp_canvas_end_forced_full_redraws(_desktop->canvas);
45     }
46     
47     _started = false;
48 }
50 void Inkscape::Rubberband::move(NR::Point const &p)
51 {
52     if (_canvas == NULL) {
53         _canvas = static_cast<CtrlRect *>(sp_canvas_item_new(sp_desktop_controls(_desktop), SP_TYPE_CTRLRECT, NULL));
54     }
56     _desktop->scroll_to_point(&p);
57     _end = p;
59     _canvas->setRectangle(NR::Rect(_start, _end));
60 }
62 NR::Maybe<NR::Rect> Inkscape::Rubberband::getRectangle() const
63 {
64     if (_canvas == NULL) {
65         return NR::Nothing();
66     }
68     return NR::Rect(_start, _end);
69 }
71 Inkscape::Rubberband *Inkscape::Rubberband::get()
72 {
73     if (_instance == NULL) {
74         _instance = new Inkscape::Rubberband;
75     }
77     return _instance;
78 }
80 bool Inkscape::Rubberband::is_started()
81 {
82     return _started;
83 }
85 /*
86   Local Variables:
87   mode:c++
88   c-file-style:"stroustrup"
89   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
90   indent-tabs-mode:nil
91   fill-column:99
92   End:
93 */
94 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :