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, 400, 100, 400, 100, 0)
34 this->client = client;
45 void ScaleWin::create_objects()
50 BC_Title *title = new BC_Title(x0, y1, _("Scale:"));
52 int x1 = x0 + title->get_w() + 10;
53 add_tool(use_scale = new ScaleUseScale(this, client, x1, y1));
54 int x2 = x1 + use_scale->get_w() + 10;
55 x_factor = new ScaleXFactor(this, client, x2, y1);
56 x_factor->create_objects();
57 int x3 = x2 + x_factor->get_w() + 20;
58 y_factor = new ScaleYFactor(this, client, x3, y1);
59 y_factor->create_objects();
60 add_tool(constrain = new ScaleConstrain(client, x1, y2));
63 add_tool(new BC_Title(x0, y0, _("Size:")));
64 add_tool(use_size = new ScaleUseSize(this, client, x1, y0));
65 width = new ScaleWidth(this, client, x2, y0);
66 width->create_objects();
67 int x = x2 + width->get_w() + 3;
68 add_tool(new BC_Title(x, y0, _("x")));
69 height= new ScaleHeight(this, client, x3, y0);
70 height->create_objects();
71 int x4 = x3 + height->get_w() + 15;
72 add_tool(pulldown = new FrameSizePulldown(client->server->mwindow->theme,
73 width->get_textbox(), height->get_textbox(), x4, y0));
79 ScaleXFactor::ScaleXFactor(ScaleWin *win,
80 ScaleMain *client, int x, int y)
81 : BC_TumbleTextBox(win, (float)client->config.x_factor, 0., 100., x, y, 100)
83 //printf("ScaleXFactor::ScaleXFactor %f\n", client->config.x_factor);
84 this->client = client;
90 ScaleXFactor::~ScaleXFactor()
94 int ScaleXFactor::handle_event()
96 client->config.x_factor = atof(get_text());
97 CLAMP(client->config.x_factor, 0, 100);
99 if(client->config.constrain)
101 client->config.y_factor = client->config.x_factor;
102 win->y_factor->update(client->config.y_factor);
105 //printf("ScaleXFactor::handle_event 1 %f\n", client->config.x_factor);
106 if(client->config.type == FIXED_SCALE && enabled) {
107 client->send_configure_change();
115 ScaleYFactor::ScaleYFactor(ScaleWin *win, ScaleMain *client, int x, int y)
116 : BC_TumbleTextBox(win, (float)client->config.y_factor, 0., 100., x, y, 100)
118 this->client = client;
123 ScaleYFactor::~ScaleYFactor()
126 int ScaleYFactor::handle_event()
128 client->config.y_factor = atof(get_text());
129 CLAMP(client->config.y_factor, 0, 100);
131 if(client->config.constrain)
133 client->config.x_factor = client->config.y_factor;
134 win->x_factor->update(client->config.x_factor);
137 if(client->config.type == FIXED_SCALE && enabled)
139 client->send_configure_change();
146 ScaleWidth::ScaleWidth(ScaleWin *win,
147 ScaleMain *client, int x, int y)
148 : BC_TumbleTextBox(win, client->config.width, 0, 100000, x, y, 90)
150 //printf("ScaleWidth::ScaleWidth %f\n", client->config.x_factor);
151 this->client = client;
157 ScaleWidth::~ScaleWidth()
161 int ScaleWidth::handle_event()
163 client->config.width = atoi(get_text());
164 if(client->config.type == FIXED_SIZE && enabled)
166 client->send_configure_change();
168 //printf("ScaleWidth::handle_event 1 %f\n", client->config.x_factor);
175 ScaleHeight::ScaleHeight(ScaleWin *win, ScaleMain *client, int x, int y)
176 : BC_TumbleTextBox(win, client->config.height, 0, 100000, x, y, 90)
178 this->client = client;
183 ScaleHeight::~ScaleHeight()
187 int ScaleHeight::handle_event()
189 client->config.height = atoi(get_text());
190 if(client->config.type == FIXED_SIZE && enabled)
192 client->send_configure_change();
197 ScaleUseScale::ScaleUseScale(ScaleWin *win, ScaleMain *client, int x, int y)
198 : BC_Radial(x, y, client->config.type == FIXED_SCALE, "")
201 this->client = client;
202 set_tooltip(_("Use fixed scale"));
204 ScaleUseScale::~ScaleUseScale()
207 int ScaleUseScale::handle_event()
209 client->set_type(FIXED_SCALE);
213 ScaleUseSize::ScaleUseSize(ScaleWin *win, ScaleMain *client, int x, int y)
214 : BC_Radial(x, y, client->config.type == FIXED_SIZE, "")
217 this->client = client;
218 set_tooltip(_("Use fixed size"));
220 ScaleUseSize::~ScaleUseSize()
223 int ScaleUseSize::handle_event()
225 client->set_type(FIXED_SIZE);
231 ScaleConstrain::ScaleConstrain(ScaleMain *client, int x, int y)
232 : BC_CheckBox(x, y, client->config.constrain, _("Constrain ratio"))
234 this->client = client;
236 ScaleConstrain::~ScaleConstrain()
239 int ScaleConstrain::handle_event()
241 client->config.constrain = get_value();
242 client->send_configure_change();