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,
33 400, 100, 400, 100, 0)
35 this->client = client;
46 void ScaleWin::create_objects()
51 BC_Title *title = new BC_Title(x0, y1, _("Scale:"));
53 int x1 = x0 + title->get_w() + 10;
54 add_tool(use_scale = new ScaleUseScale(this, client, x1, y1));
55 int x2 = x1 + use_scale->get_w() + 10;
56 x_factor = new ScaleXFactor(this, client, x2, y1);
57 x_factor->create_objects();
58 int x3 = x2 + x_factor->get_w() + 20;
59 y_factor = new ScaleYFactor(this, client, x3, y1);
60 y_factor->create_objects();
61 add_tool(constrain = new ScaleConstrain(client, x1, y2));
64 add_tool(new BC_Title(x0, y0, _("Size:")));
65 add_tool(use_size = new ScaleUseSize(this, client, x1, y0));
66 width = new ScaleWidth(this, client, x2, y0);
67 width->create_objects();
68 int x = x2 + width->get_w() + 3;
69 add_tool(new BC_Title(x, y0, _("x")));
70 height= new ScaleHeight(this, client, x3, y0);
71 height->create_objects();
72 int x4 = x3 + height->get_w() + 15;
73 add_tool(pulldown = new FrameSizePulldown(client->server->mwindow->theme,
74 width->get_textbox(), height->get_textbox(), x4, y0));
80 ScaleXFactor::ScaleXFactor(ScaleWin *win,
81 ScaleMain *client, int x, int y)
82 : BC_TumbleTextBox(win, (float)client->config.x_factor, 0., 100., x, y, 100)
84 //printf("ScaleXFactor::ScaleXFactor %f\n", client->config.x_factor);
85 this->client = client;
91 ScaleXFactor::~ScaleXFactor()
95 int ScaleXFactor::handle_event()
97 client->config.x_factor = atof(get_text());
98 CLAMP(client->config.x_factor, 0, 100);
100 if(client->config.constrain)
102 client->config.y_factor = client->config.x_factor;
103 win->y_factor->update(client->config.y_factor);
106 //printf("ScaleXFactor::handle_event 1 %f\n", client->config.x_factor);
107 if(client->config.type == FIXED_SCALE && enabled) {
108 client->send_configure_change();
116 ScaleYFactor::ScaleYFactor(ScaleWin *win, ScaleMain *client, int x, int y)
117 : BC_TumbleTextBox(win, (float)client->config.y_factor, 0., 100., x, y, 100)
119 this->client = client;
124 ScaleYFactor::~ScaleYFactor()
127 int ScaleYFactor::handle_event()
129 client->config.y_factor = atof(get_text());
130 CLAMP(client->config.y_factor, 0, 100);
132 if(client->config.constrain)
134 client->config.x_factor = client->config.y_factor;
135 win->x_factor->update(client->config.x_factor);
138 if(client->config.type == FIXED_SCALE && enabled)
140 client->send_configure_change();
147 ScaleWidth::ScaleWidth(ScaleWin *win,
148 ScaleMain *client, int x, int y)
149 : BC_TumbleTextBox(win, client->config.width, 0, 100000, x, y, 90)
151 //printf("ScaleWidth::ScaleWidth %f\n", client->config.x_factor);
152 this->client = client;
158 ScaleWidth::~ScaleWidth()
162 int ScaleWidth::handle_event()
164 client->config.width = atoi(get_text());
165 if(client->config.type == FIXED_SIZE && enabled)
167 client->send_configure_change();
169 //printf("ScaleWidth::handle_event 1 %f\n", client->config.x_factor);
176 ScaleHeight::ScaleHeight(ScaleWin *win, ScaleMain *client, int x, int y)
177 : BC_TumbleTextBox(win, client->config.height, 0, 100000, x, y, 90)
179 this->client = client;
184 ScaleHeight::~ScaleHeight()
188 int ScaleHeight::handle_event()
190 client->config.height = atoi(get_text());
191 if(client->config.type == FIXED_SIZE && enabled)
193 client->send_configure_change();
198 ScaleUseScale::ScaleUseScale(ScaleWin *win, ScaleMain *client, int x, int y)
199 : BC_Radial(x, y, client->config.type == FIXED_SCALE, "")
202 this->client = client;
203 set_tooltip(_("Use fixed scale"));
205 ScaleUseScale::~ScaleUseScale()
208 int ScaleUseScale::handle_event()
210 client->set_type(FIXED_SCALE);
214 ScaleUseSize::ScaleUseSize(ScaleWin *win, ScaleMain *client, int x, int y)
215 : BC_Radial(x, y, client->config.type == FIXED_SIZE, "")
218 this->client = client;
219 set_tooltip(_("Use fixed size"));
221 ScaleUseSize::~ScaleUseSize()
224 int ScaleUseSize::handle_event()
226 client->set_type(FIXED_SIZE);
232 ScaleConstrain::ScaleConstrain(ScaleMain *client, int x, int y)
233 : BC_CheckBox(x, y, client->config.constrain, _("Constrain ratio"))
235 this->client = client;
237 ScaleConstrain::~ScaleConstrain()
240 int ScaleConstrain::handle_event()
242 client->config.constrain = get_value();
243 client->send_configure_change();