aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-12-04 17:58:01 (GMT)
committerfluxgen <fluxgen>2002-12-04 17:58:01 (GMT)
commit27a73906fe3b185d466099ae19fd986c08d43457 (patch)
treeebc03b81e4743a8a3c2103f9d6e11beab0ecdf7b
parent9acaeba68093d1cb6b9daa3abd64d84af99413e5 (diff)
downloadfluxbox-27a73906fe3b185d466099ae19fd986c08d43457.zip
fluxbox-27a73906fe3b185d466099ae19fd986c08d43457.tar.bz2
fixed right and left placement
-rw-r--r--src/Toolbar.cc182
1 files changed, 132 insertions, 50 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index a7a1b36..9026852 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Toolbar.cc,v 1.47 2002/12/03 17:02:53 fluxgen Exp $ 25// $Id: Toolbar.cc,v 1.48 2002/12/04 17:58:01 fluxgen Exp $
26 26
27#include "Toolbar.hh" 27#include "Toolbar.hh"
28 28
@@ -69,6 +69,7 @@
69#include <iostream> 69#include <iostream>
70 70
71using namespace std; 71using namespace std;
72
72// toolbar frame 73// toolbar frame
73Toolbar::Frame::Frame(FbTk::EventHandler &evh, int screen_num): 74Toolbar::Frame::Frame(FbTk::EventHandler &evh, int screen_num):
74 window(screen_num, // screen (parent) 75 window(screen_num, // screen (parent)
@@ -276,7 +277,7 @@ void Toolbar::reconfigure() {
276 if (w > frame.workspace_label_w) 277 if (w > frame.workspace_label_w)
277 frame.workspace_label_w = w; 278 frame.workspace_label_w = w;
278 } 279 }
279 280
280 if (frame.workspace_label_w < frame.clock_w) 281 if (frame.workspace_label_w < frame.clock_w)
281 frame.workspace_label_w = frame.clock_w; 282 frame.workspace_label_w = frame.clock_w;
282 else if (frame.workspace_label_w > frame.clock_w) 283 else if (frame.workspace_label_w > frame.clock_w)
@@ -285,7 +286,7 @@ void Toolbar::reconfigure() {
285 frame.window_label_w = 286 frame.window_label_w =
286 (frame.width - (frame.clock_w + (frame.button_w * 4) + 287 (frame.width - (frame.clock_w + (frame.button_w * 4) +
287 frame.workspace_label_w + (frame.bevel_w * 8) + 6)); 288 frame.workspace_label_w + (frame.bevel_w * 8) + 6));
288 289
289 if (hidden) 290 if (hidden)
290 frame.window.moveResize(frame.x_hidden, frame.y_hidden, 291 frame.window.moveResize(frame.x_hidden, frame.y_hidden,
291 frame.width, frame.height); 292 frame.width, frame.height);
@@ -293,51 +294,75 @@ void Toolbar::reconfigure() {
293 frame.window.moveResize(frame.x, frame.y, 294 frame.window.moveResize(frame.x, frame.y,
294 frame.width, frame.height); 295 frame.width, frame.height);
295 } 296 }
296 297
297 cerr<<"workspace label width = "<<frame.workspace_label_w<<endl;
298 bool vertical = isVertical(); 298 bool vertical = isVertical();
299 unsigned int size_w = frame.workspace_label_w; 299 unsigned int next_x = frame.workspace_label_w;
300 unsigned int size_h = frame.label_h; 300 unsigned int next_y = frame.window.height();
301 unsigned int swap_var = 0; 301
302 if (vertical) { 302 if (vertical) {
303 swap_var = size_w; 303 next_x = frame.window.width();
304 size_w = size_h; 304 next_y = frame.workspace_label_w;
305 size_h = swap_var;
306 } 305 }
307 frame.workspace_label.moveResize(frame.bevel_w, frame.bevel_w, size_w, size_h);
308 306
309 size_w = frame.workspace_label_w + 1; 307 frame.workspace_label.moveResize(frame.bevel_w, frame.bevel_w, next_x, next_y);
310 size_h = frame.bevel_w + 1; 308 next_x = 0;
309 next_y = 0;
311 if (vertical) { 310 if (vertical) {
312 swap_var = size_w; 311 next_y += frame.workspace_label.height() + 1;
313 size_w = size_h; 312 } else {
314 size_h = swap_var; 313 next_x += frame.workspace_label.width() + 1;
315 } 314 }
315
316 frame.psbutton.moveResize(frame.bevel_w * 2 + 316 frame.psbutton.moveResize(frame.bevel_w * 2 +
317 size_w , size_h, 317 next_x , next_y,
318 frame.button_w, frame.button_w); 318 frame.button_w, frame.button_w);
319 if (vertical) 319 if (vertical)
320 size_h += frame.button_w + 1; 320 next_y += frame.psbutton.height() + 1;
321 else 321 else
322 size_w += frame.button_w + 1; 322 next_x += frame.psbutton.width() + 1;
323 323
324 frame.nsbutton.moveResize(frame.bevel_w * 3 + 324 frame.nsbutton.moveResize(frame.bevel_w * 3 +
325 size_w, size_h, 325 next_x, next_y,
326 frame.button_w, frame.button_w); 326 frame.button_w, frame.button_w);
327 frame.window_label.moveResize(frame.bevel_w * 4 + 327 size_t label_w = frame.window_label_w;
328 frame.button_w * 2 + frame.workspace_label_w + 3, 328 size_t label_h = frame.height;
329 frame.bevel_w, frame.window_label_w, frame.label_h); 329
330 frame.pwbutton.moveResize(frame.bevel_w * 5 + 330 if (vertical) {
331 frame.button_w * 2 + frame.workspace_label_w + 331 next_y += frame.nsbutton.height() + 1;
332 frame.window_label_w + 4, frame.bevel_w + 1, 332 label_w = frame.width;
333 label_h = frame.window_label_w - frame.width + frame.height;
334
335 } else
336 next_x += frame.nsbutton.width() + 1;
337
338
339 frame.window_label.moveResize(next_x, next_y,
340 label_w, label_h);
341 if (vertical)
342 next_y += frame.window_label.height() + 1;
343 else
344 next_x += frame.window_label.width() + 1;
345
346 frame.pwbutton.moveResize(next_x, next_y,
333 frame.button_w, frame.button_w); 347 frame.button_w, frame.button_w);
334 frame.nwbutton.moveResize(frame.bevel_w * 6 + 348 if (vertical)
335 frame.button_w * 3 + frame.workspace_label_w + 349 next_y += frame.pwbutton.height() + 1;
336 frame.window_label_w + 5, frame.bevel_w + 1, 350 else
351 next_x += frame.pwbutton.width() + 1;
352
353 frame.nwbutton.moveResize(next_x, next_y,
337 frame.button_w, frame.button_w); 354 frame.button_w, frame.button_w);
338 frame.clock.moveResize(frame.width - frame.clock_w - 355 size_t clock_w = frame.width - next_x - frame.nwbutton.width() - 1;
339 frame.bevel_w, frame.bevel_w, frame.clock_w, 356 size_t clock_h = frame.height;
340 frame.label_h); 357 if (vertical) {
358 next_y += frame.nwbutton.height() + 1;
359 clock_w = frame.width;
360 clock_h = frame.height - next_y;
361 } else
362 next_x += frame.nwbutton.width() + 1;
363
364 frame.clock.moveResize(next_x, next_y,
365 clock_w, clock_h);
341 366
342 Pixmap tmp = frame.base; 367 Pixmap tmp = frame.base;
343 const FbTk::Texture *texture = &(m_theme.toolbar()); 368 const FbTk::Texture *texture = &(m_theme.toolbar());
@@ -345,7 +370,7 @@ void Toolbar::reconfigure() {
345 frame.base = None; 370 frame.base = None;
346 frame.window.setBackgroundColor(texture->color()); 371 frame.window.setBackgroundColor(texture->color());
347 } else { 372 } else {
348 frame.base = image_ctrl.renderImage(frame.width, frame.height, *texture); 373 frame.base = image_ctrl.renderImage(frame.window.width(), frame.window.height(), *texture);
349 frame.window.setBackgroundPixmap(frame.base); 374 frame.window.setBackgroundPixmap(frame.base);
350 } 375 }
351 if (tmp) image_ctrl.removeImage(tmp); 376 if (tmp) image_ctrl.removeImage(tmp);
@@ -357,7 +382,7 @@ void Toolbar::reconfigure() {
357 frame.window_label.setBackgroundColor(texture->color()); 382 frame.window_label.setBackgroundColor(texture->color());
358 } else { 383 } else {
359 frame.label = 384 frame.label =
360 image_ctrl.renderImage(frame.window_label_w, frame.label_h, *texture); 385 image_ctrl.renderImage(frame.window_label.width(), frame.window_label.height(), *texture);
361 frame.window_label.setBackgroundPixmap(frame.label); 386 frame.window_label.setBackgroundPixmap(frame.label);
362 } 387 }
363 if (tmp) image_ctrl.removeImage(tmp); 388 if (tmp) image_ctrl.removeImage(tmp);
@@ -369,7 +394,8 @@ void Toolbar::reconfigure() {
369 frame.workspace_label.setBackgroundColor(texture->color()); 394 frame.workspace_label.setBackgroundColor(texture->color());
370 } else { 395 } else {
371 frame.wlabel = 396 frame.wlabel =
372 image_ctrl.renderImage(frame.workspace_label_w, frame.label_h, *texture); 397 image_ctrl.renderImage(frame.workspace_label.width(),
398 frame.workspace_label.height(), *texture);
373 frame.workspace_label.setBackgroundPixmap(frame.wlabel); 399 frame.workspace_label.setBackgroundPixmap(frame.wlabel);
374 } 400 }
375 if (tmp) image_ctrl.removeImage(tmp); 401 if (tmp) image_ctrl.removeImage(tmp);
@@ -381,7 +407,7 @@ void Toolbar::reconfigure() {
381 frame.clock.setBackgroundColor(texture->color()); 407 frame.clock.setBackgroundColor(texture->color());
382 } else { 408 } else {
383 frame.clk = 409 frame.clk =
384 image_ctrl.renderImage(frame.clock_w, frame.label_h, *texture); 410 image_ctrl.renderImage(frame.clock.width(), frame.clock.height(), *texture);
385 frame.clock.setBackgroundPixmap(frame.clk); 411 frame.clock.setBackgroundPixmap(frame.clk);
386 } 412 }
387 if (tmp) image_ctrl.removeImage(tmp); 413 if (tmp) image_ctrl.removeImage(tmp);
@@ -543,13 +569,18 @@ void Toolbar::checkClock(bool redraw, bool date) {
543 m_theme.justify(), 569 m_theme.justify(),
544 m_theme.font(), 570 m_theme.font(),
545 t, strlen(t), newlen); 571 t, strlen(t), newlen);
546 572 int dy = 1 + m_theme.font().ascent();
573 if (m_theme.font().isRotated()) {
574 int tmp = dy;
575 dy = frame.clock.height() - dx;
576 dx = tmp;
577 }
547 m_theme.font().drawText( 578 m_theme.font().drawText(
548 frame.clock.window(), 579 frame.clock.window(),
549 screen()->getScreenNumber(), 580 screen()->getScreenNumber(),
550 m_theme.clockTextGC(), 581 m_theme.clockTextGC(),
551 t, newlen, 582 t, newlen,
552 dx, 1 + m_theme.font().ascent()); 583 dx, dy);
553 } 584 }
554} 585}
555 586
@@ -568,13 +599,20 @@ void Toolbar::redrawWindowLabel(bool redraw) {
568 m_theme.justify(), 599 m_theme.justify(),
569 m_theme.font(), 600 m_theme.font(),
570 foc->getTitle().c_str(), foc->getTitle().size(), newlen); 601 foc->getTitle().c_str(), foc->getTitle().size(), newlen);
571 602 int dy = 1 + m_theme.font().ascent();
603
604 if (m_theme.font().isRotated()) {
605 int tmp = dy;
606 dy = frame.window_label.height() - dx;
607 dx = tmp;
608 }
609
572 m_theme.font().drawText( 610 m_theme.font().drawText(
573 frame.window_label.window(), 611 frame.window_label.window(),
574 screen()->getScreenNumber(), 612 screen()->getScreenNumber(),
575 m_theme.windowTextGC(), 613 m_theme.windowTextGC(),
576 foc->getTitle().c_str(), newlen, 614 foc->getTitle().c_str(), newlen,
577 dx, 1 + m_theme.font().ascent()); 615 dx, dy);
578 } else 616 } else
579 frame.window_label.clear(); 617 frame.window_label.clear();
580} 618}
@@ -594,13 +632,18 @@ void Toolbar::redrawWorkspaceLabel(bool redraw) {
594 m_theme.justify(), 632 m_theme.justify(),
595 m_theme.font(), 633 m_theme.font(),
596 text, textlen, newlen); 634 text, textlen, newlen);
597 635 int dy = 1 + m_theme.font().ascent();
636 if (m_theme.font().isRotated()) {
637 int tmp = dy;
638 dy = frame.workspace_label_w - dx;
639 dx = tmp;
640 }
598 m_theme.font().drawText( 641 m_theme.font().drawText(
599 frame.workspace_label.window(), 642 frame.workspace_label.window(),
600 screen()->getScreenNumber(), 643 screen()->getScreenNumber(),
601 m_theme.labelTextGC(), 644 m_theme.labelTextGC(),
602 text, newlen, 645 text, newlen,
603 dx, 1 + m_theme.font().ascent()); 646 dx, dy);
604} 647}
605 648
606 649
@@ -693,7 +736,7 @@ void Toolbar::edit() {
693 736
694 editing = true; //mark for editing 737 editing = true; //mark for editing
695 738
696 //workspace labe already got intput focus ? 739 //workspace label already has intput focus ?
697 if (XGetInputFocus(display, &window, &foo) && 740 if (XGetInputFocus(display, &window, &foo) &&
698 window == frame.workspace_label) 741 window == frame.workspace_label)
699 return; 742 return;
@@ -1069,9 +1112,39 @@ void Toolbar::setPlacement(Toolbar::Placement where) {
1069 screen()->getBorderWidth(); 1112 screen()->getBorderWidth();
1070 break; 1113 break;
1071 case LEFTCENTER: 1114 case LEFTCENTER:
1072 frame.x = 0; 1115 frame.x = head_x;
1073 frame.y = head_y + (head_h - frame.height)/2; 1116 frame.y = head_y + (head_h - frame.height)/2;
1074 frame.x_hidden = head_x + head_w - screen()->getBevelWidth() - screen()->getBorderWidth(); 1117 frame.x_hidden = frame.x - frame.width + screen()->getBevelWidth() + screen()->getBorderWidth();
1118 frame.y_hidden = frame.y;
1119 break;
1120 case LEFTTOP:
1121 frame.x = head_x;
1122 frame.y = head_y;
1123 frame.x_hidden = frame.x - frame.width + screen()->getBevelWidth() + screen()->getBorderWidth();
1124 frame.y_hidden = frame.y;
1125 break;
1126 case LEFTBOTTOM:
1127 frame.x = head_x;
1128 frame.y = head_y + head_h - frame.height;
1129 frame.x_hidden = frame.x - frame.width + screen()->getBevelWidth() + screen()->getBorderWidth();
1130 frame.y_hidden = frame.y;
1131 break;
1132 case RIGHTCENTER:
1133 frame.x = head_x + head_w - frame.width;
1134 frame.y = head_y + (head_h - frame.height)/2;
1135 frame.x_hidden = frame.x + frame.width - screen()->getBevelWidth() - screen()->getBorderWidth();
1136 frame.y_hidden = frame.y;
1137 break;
1138 case RIGHTTOP:
1139 frame.x = head_x + head_w - frame.width;
1140 frame.y = head_y;
1141 frame.x_hidden = frame.x + frame.width - screen()->getBevelWidth() - screen()->getBorderWidth();
1142 frame.y_hidden = frame.y;
1143 break;
1144 case RIGHTBOTTOM:
1145 frame.x = head_x + head_w - frame.width;
1146 frame.y = head_y + head_h - frame.height;
1147 frame.x_hidden = frame.x + frame.width - screen()->getBevelWidth() - screen()->getBorderWidth();
1075 frame.y_hidden = frame.y; 1148 frame.y_hidden = frame.y;
1076 break; 1149 break;
1077 } 1150 }
@@ -1207,7 +1280,7 @@ void Toolbarmenu::reconfigure() {
1207 Basemenu::reconfigure(); 1280 Basemenu::reconfigure();
1208} 1281}
1209 1282
1210 1283//TODO: fix placement
1211Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu &tm) 1284Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu &tm)
1212 : Basemenu(tm.m_toolbar.screen()), m_toolbarmenu(tm) { 1285 : Basemenu(tm.m_toolbar.screen()), m_toolbarmenu(tm) {
1213 1286
@@ -1217,12 +1290,18 @@ Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu &tm)
1217 ToolbarSet, ToolbarToolbarPlacement, 1290 ToolbarSet, ToolbarToolbarPlacement,
1218 "Toolbar Placement")); 1291 "Toolbar Placement"));
1219 setInternalMenu(); 1292 setInternalMenu();
1220 setMinimumSublevels(3); 1293 setMinimumSublevels(5);
1221 1294
1295 insert("Left Top", Toolbar::LEFTTOP);
1296 insert("Left Center", Toolbar::LEFTCENTER);
1297 insert("Left Bottom", Toolbar::LEFTBOTTOM);
1298
1222 insert(i18n->getMessage( 1299 insert(i18n->getMessage(
1223 CommonSet, CommonPlacementTopLeft, 1300 CommonSet, CommonPlacementTopLeft,
1224 "Top Left"), 1301 "Top Left"),
1225 Toolbar::TOPLEFT); 1302 Toolbar::TOPLEFT);
1303 insert("");
1304
1226 insert(i18n->getMessage( 1305 insert(i18n->getMessage(
1227 CommonSet, CommonPlacementBottomLeft, 1306 CommonSet, CommonPlacementBottomLeft,
1228 "Bottom Left"), 1307 "Bottom Left"),
@@ -1231,6 +1310,7 @@ Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu &tm)
1231 CommonSet, CommonPlacementTopCenter, 1310 CommonSet, CommonPlacementTopCenter,
1232 "Top Center"), 1311 "Top Center"),
1233 Toolbar::TOPCENTER); 1312 Toolbar::TOPCENTER);
1313 insert("");
1234 insert(i18n->getMessage( 1314 insert(i18n->getMessage(
1235 CommonSet, CommonPlacementBottomCenter, 1315 CommonSet, CommonPlacementBottomCenter,
1236 "Bottom Center"), 1316 "Bottom Center"),
@@ -1239,13 +1319,15 @@ Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu &tm)
1239 CommonSet, CommonPlacementTopRight, 1319 CommonSet, CommonPlacementTopRight,
1240 "Top Right"), 1320 "Top Right"),
1241 Toolbar::TOPRIGHT); 1321 Toolbar::TOPRIGHT);
1322 insert("");
1242 insert(i18n->getMessage( 1323 insert(i18n->getMessage(
1243 CommonSet, CommonPlacementBottomRight, 1324 CommonSet, CommonPlacementBottomRight,
1244 "Bottom Right"), 1325 "Bottom Right"),
1245 Toolbar::BOTTOMRIGHT); 1326 Toolbar::BOTTOMRIGHT);
1246 1327
1247 insert("Left Center", Toolbar::LEFTCENTER); 1328 insert("Right Top", Toolbar::RIGHTTOP);
1248 1329 insert("Right Center", Toolbar::RIGHTCENTER);
1330 insert("Right Bottom", Toolbar::RIGHTBOTTOM);
1249 update(); 1331 update();
1250} 1332}
1251 1333