4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "bcdisplayinfo.h"
26 #include "pluginserver.h"
31 ScaleWin::ScaleWin(ScaleMain *client)
32 : PluginClientWindow(client, xS(400), yS(100), xS(400), yS(100), 0)
34 this->client = client;
45 void ScaleWin::create_objects()
47 int xs10 = xS(10), xs15 = xS(15), xs20 = xS(20);
48 int ys10 = yS(10), ys25 = yS(25);
49 int x0 = xs10, y0 = ys10;
52 BC_Title *title = new BC_Title(x0, y1, _("Scale:"));
54 int x1 = x0 + title->get_w() + xs10;
55 add_tool(use_scale = new ScaleUseScale(this, client, x1, y1));
56 int x2 = x1 + use_scale->get_w() + xs10;
57 x_factor = new ScaleXFactor(this, client, x2, y1);
58 x_factor->create_objects();
59 int x3 = x2 + x_factor->get_w() + xs20;
60 y_factor = new ScaleYFactor(this, client, x3, y1);
61 y_factor->create_objects();
62 add_tool(constrain = new ScaleConstrain(client, x1, y2));
65 add_tool(new BC_Title(x0, y0, _("Size:")));
66 add_tool(use_size = new ScaleUseSize(this, client, x1, y0));
67 width = new ScaleWidth(this, client, x2, y0);
68 width->create_objects();
69 int x = x2 + width->get_w() + xS(3);
70 add_tool(new BC_Title(x, y0, _("x")));
71 height= new ScaleHeight(this, client, x3, y0);
72 height->create_objects();
73 int x4 = x3 + height->get_w() + xs15;
74 add_tool(pulldown = new FrameSizePulldown(client->server->mwindow->theme,
75 width->get_textbox(), height->get_textbox(), x4, y0));
81 ScaleXFactor::ScaleXFactor(ScaleWin *win,
82 ScaleMain *client, int x, int y)
83 : BC_TumbleTextBox(win, (float)client->config.x_factor, 0., 100., x, y, xS(100))
85 //printf("ScaleXFactor::ScaleXFactor %f\n", client->config.x_factor);
86 this->client = client;
92 ScaleXFactor::~ScaleXFactor()
96 int ScaleXFactor::handle_event()
98 client->config.x_factor = atof(get_text());
99 CLAMP(client->config.x_factor, 0, 100);
101 if(client->config.constrain)
103 client->config.y_factor = client->config.x_factor;
104 win->y_factor->update(client->config.y_factor);
107 //printf("ScaleXFactor::handle_event 1 %f\n", client->config.x_factor);
108 if(client->config.type == FIXED_SCALE && enabled) {
109 client->send_configure_change();
117 ScaleYFactor::ScaleYFactor(ScaleWin *win, ScaleMain *client, int x, int y)
118 : BC_TumbleTextBox(win, (float)client->config.y_factor, 0., 100., x, y, xS(100))
120 this->client = client;
125 ScaleYFactor::~ScaleYFactor()
128 int ScaleYFactor::handle_event()
130 client->config.y_factor = atof(get_text());
131 CLAMP(client->config.y_factor, 0, 100);
133 if(client->config.constrain)
135 client->config.x_factor = client->config.y_factor;
136 win->x_factor->update(client->config.x_factor);
139 if(client->config.type == FIXED_SCALE && enabled)
141 client->send_configure_change();
148 ScaleWidth::ScaleWidth(ScaleWin *win,
149 ScaleMain *client, int x, int y)
150 : BC_TumbleTextBox(win, client->config.width, 0, 100000, x, y, xS(90))
152 //printf("ScaleWidth::ScaleWidth %f\n", client->config.x_factor);
153 this->client = client;
159 ScaleWidth::~ScaleWidth()
163 int ScaleWidth::handle_event()
165 client->config.width = atoi(get_text());
166 if(client->config.type == FIXED_SIZE && enabled)
168 client->send_configure_change();
170 //printf("ScaleWidth::handle_event 1 %f\n", client->config.x_factor);
177 ScaleHeight::ScaleHeight(ScaleWin *win, ScaleMain *client, int x, int y)
178 : BC_TumbleTextBox(win, client->config.height, 0, 100000, x, y, xS(90))
180 this->client = client;
185 ScaleHeight::~ScaleHeight()
189 int ScaleHeight::handle_event()
191 client->config.height = atoi(get_text());
192 if(client->config.type == FIXED_SIZE && enabled)
194 client->send_configure_change();
199 ScaleUseScale::ScaleUseScale(ScaleWin *win, ScaleMain *client, int x, int y)
200 : BC_Radial(x, y, client->config.type == FIXED_SCALE, "")
203 this->client = client;
204 set_tooltip(_("Use fixed scale"));
206 ScaleUseScale::~ScaleUseScale()
209 int ScaleUseScale::handle_event()
211 client->set_type(FIXED_SCALE);
215 ScaleUseSize::ScaleUseSize(ScaleWin *win, ScaleMain *client, int x, int y)
216 : BC_Radial(x, y, client->config.type == FIXED_SIZE, "")
219 this->client = client;
220 set_tooltip(_("Use fixed size"));
222 ScaleUseSize::~ScaleUseSize()
225 int ScaleUseSize::handle_event()
227 client->set_type(FIXED_SIZE);
233 ScaleConstrain::ScaleConstrain(ScaleMain *client, int x, int y)
234 : BC_CheckBox(x, y, client->config.constrain, _("Constrain ratio"))
236 this->client = client;
238 ScaleConstrain::~ScaleConstrain()
241 int ScaleConstrain::handle_event()
243 client->config.constrain = get_value();
244 client->send_configure_change();