blob: 0de3cd763a7dd99b8a98b49014b2947b060b2c80 (
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
|
#define __RUBBERBAND_C__
/**
* \file src/rubberband.cpp
* \brief Rubberbanding selector
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Copyright (C) 1999-2002 Lauris Kaplinski
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "display/sodipodi-ctrlrect.h"
#include "desktop.h"
#include "inkscape.h"
#include "desktop-handles.h"
#include "rubberband.h"
Inkscape::Rubberband *Inkscape::Rubberband::_instance = NULL;
Inkscape::Rubberband::Rubberband()
: _desktop(SP_ACTIVE_DESKTOP), _canvas(NULL), _started(false)
{
}
void Inkscape::Rubberband::start(SPDesktop *d, NR::Point const &p)
{
stop();
_desktop = d;
_start = p;
_started = true;
sp_canvas_force_full_redraw_after_interruptions(_desktop->canvas, 5);
}
void Inkscape::Rubberband::stop()
{
_started = false;
if (_canvas) {
GtkObject *temp = _canvas;
_canvas = NULL;
gtk_object_destroy(temp);
sp_canvas_end_forced_full_redraws(_desktop->canvas);
}
}
void Inkscape::Rubberband::move(NR::Point const &p)
{
if (_canvas == NULL) {
_canvas = static_cast<CtrlRect *>(sp_canvas_item_new(sp_desktop_controls(_desktop), SP_TYPE_CTRLRECT, NULL));
}
_desktop->scroll_to_point(&p);
_end = p;
_canvas->setRectangle(NR::Rect(_start, _end));
}
NR::Maybe<NR::Rect> Inkscape::Rubberband::getRectangle() const
{
if (_canvas == NULL) {
return NR::Nothing();
}
return NR::Rect(_start, _end);
}
Inkscape::Rubberband *Inkscape::Rubberband::get()
{
if (_instance == NULL) {
_instance = new Inkscape::Rubberband;
}
return _instance;
}
bool Inkscape::Rubberband::is_started()
{
return _started;
}
/*
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:encoding=utf-8:textwidth=99 :
|