2
* Gtkmm facade/wrapper around zoom_status code that formerly lived
3
* in desktop-widget.cpp
6
* Ralf Stephan <ralf@ark.in-berlin.de>
7
* Lauris Kaplinski <lauris@kaplinski.com>
8
* MenTaLguY <mental@rydia.net>
9
* bulia byak <buliabyak@users.sf.net>
11
* Copyright (C) 2005 Ralf Stephan
12
* Copyright (C) 2004 MenTaLguY
13
* Copyright (C) 1999-2002 Lauris Kaplinski
14
* Copyright (C) 2000-2001 Ximian, Inc.
16
* Released under GNU GPL, read the file 'COPYING' for more information
19
#include "ui/widget/zoom-status.h"
21
#include "desktop-handles.h"
22
#include "widgets/spw-utilities.h"
28
ZoomStatus::ZoomStatus()
29
: _adj(0.0, -1.0, 1.0, 0.1, 0.1)
34
property_numeric() = false;
35
property_update_policy() = Gtk::UPDATE_ALWAYS;
36
sp_set_font_size_smaller(static_cast<GtkWidget*>((void*)gobj()));
39
ZoomStatus::~ZoomStatus()
45
ZoomStatus::init(SPDesktop *dt)
48
property_digits() = 4;
50
_adj.set_lower(log(SP_DESKTOP_ZOOM_MIN)/log(2.0));
51
_adj.set_upper(log(SP_DESKTOP_ZOOM_MAX)/log(2.0));
52
_adj.set_step_increment(0.1);
53
_adj.set_page_increment(0.1);
62
set_value(log(_dt->current_zoom())/log(2.0));
67
value_to_display(double value)
69
return floor(pow(2, value) * 100.0 + 0.5);
73
display_to_value(double value)
75
return log(value / 100.0) / log(2.0);
79
ZoomStatus::on_input(double *new_val)
81
double new_scrolled = get_value();
82
double new_typed = atof(get_text().c_str());
84
if (value_to_display(new_scrolled) == new_typed)
85
{ // the new value is set by scrolling
86
*new_val = new_scrolled;
87
} else { // the new value is typed in
88
*new_val = display_to_value(new_typed);
95
ZoomStatus::on_output()
98
g_snprintf(b, 64, "%4.0f%%", value_to_display(get_value()));
104
ZoomStatus::on_value_changed()
109
double zoom_factor = pow(2, get_value());
110
NR::Rect const d =_dt->get_display_area();
111
_dt->zoom_absolute(d.midpoint()[NR::X], d.midpoint()[NR::Y], zoom_factor);
112
gtk_widget_grab_focus(static_cast<GtkWidget*>((void*)_dt->canvas)); /// \todo this no love song
121
c-file-style:"stroustrup"
122
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
127
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :