diff options
author | fluxgen <fluxgen> | 2002-11-26 16:46:05 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-11-26 16:46:05 (GMT) |
commit | 558aa0f9f970b95bdd14582da7690a8208fe7bb9 (patch) | |
tree | 09d948b979f4c803f8ca154d5d1bd6d3a731db81 /src | |
parent | 75eb138d4e07d6f1024963f4ac9561dfd7a34b54 (diff) | |
download | fluxbox_paul-558aa0f9f970b95bdd14582da7690a8208fe7bb9.zip fluxbox_paul-558aa0f9f970b95bdd14582da7690a8208fe7bb9.tar.bz2 |
using drawutil's doAlignment function
Diffstat (limited to 'src')
-rw-r--r-- | src/Toolbar.cc | 139 | ||||
-rw-r--r-- | src/Window.cc | 56 |
2 files changed, 61 insertions, 134 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 745646d..5f21a2b 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.40 2002/11/16 22:17:06 fluxgen Exp $ | 25 | // $Id: Toolbar.cc,v 1.41 2002/11/26 16:46:05 fluxgen Exp $ |
26 | 26 | ||
27 | #include "Toolbar.hh" | 27 | #include "Toolbar.hh" |
28 | 28 | ||
@@ -598,39 +598,18 @@ void Toolbar::checkClock(bool redraw, bool date) { | |||
598 | } | 598 | } |
599 | #endif // HAVE_STRFTIME | 599 | #endif // HAVE_STRFTIME |
600 | 600 | ||
601 | int dx = (frame.bevel_w * 2), dlen = strlen(t); | 601 | size_t newlen = strlen(t); |
602 | unsigned int l; | 602 | int dx = DrawUtil::doAlignment(frame.clock_w, |
603 | l = screen->getToolbarStyle()->font.textWidth(t, dlen); | 603 | frame.bevel_w*2, |
604 | 604 | screen->getToolbarStyle()->justify, | |
605 | l += (frame.bevel_w * 4); | 605 | screen->getToolbarStyle()->font, |
606 | 606 | t, strlen(t), newlen); | |
607 | if (l > frame.clock_w) { | 607 | |
608 | for (; dlen >= 0; dlen--) { | ||
609 | l = screen->getToolbarStyle()->font.textWidth(t, dlen); | ||
610 | l += (frame.bevel_w * 4); | ||
611 | |||
612 | if (l < frame.clock_w) | ||
613 | break; | ||
614 | } | ||
615 | |||
616 | } | ||
617 | |||
618 | switch (screen->getToolbarStyle()->justify) { | ||
619 | case DrawUtil::Font::RIGHT: | ||
620 | dx += frame.clock_w - l; | ||
621 | break; | ||
622 | case DrawUtil::Font::CENTER: | ||
623 | dx += (frame.clock_w - l) / 2; | ||
624 | break; | ||
625 | default: //LEFT, no justification | ||
626 | break; | ||
627 | } | ||
628 | |||
629 | screen->getToolbarStyle()->font.drawText( | 608 | screen->getToolbarStyle()->font.drawText( |
630 | frame.clock, | 609 | frame.clock, |
631 | screen->getScreenNumber(), | 610 | screen->getScreenNumber(), |
632 | screen->getToolbarStyle()->c_text_gc, | 611 | screen->getToolbarStyle()->c_text_gc, |
633 | t, dlen, | 612 | t, newlen, |
634 | dx, 1 + screen->getToolbarStyle()->font.ascent()); | 613 | dx, 1 + screen->getToolbarStyle()->font.ascent()); |
635 | } | 614 | } |
636 | } | 615 | } |
@@ -645,39 +624,17 @@ void Toolbar::redrawWindowLabel(bool redraw) { | |||
645 | if (foc->getScreen() != screen || foc->getTitle().size() == 0) | 624 | if (foc->getScreen() != screen || foc->getTitle().size() == 0) |
646 | return; | 625 | return; |
647 | 626 | ||
648 | int dx = (frame.bevel_w * 2), dlen = foc->getTitle().size(); | 627 | size_t newlen = foc->getTitle().size(); |
649 | unsigned int l; | 628 | int dx = DrawUtil::doAlignment(frame.window_label_w, frame.bevel_w*2, |
650 | 629 | screen->getToolbarStyle()->justify, | |
651 | l = screen->getToolbarStyle()->font.textWidth(foc->getTitle().c_str(), dlen); | 630 | screen->getToolbarStyle()->font, |
652 | 631 | foc->getTitle().c_str(), foc->getTitle().size(), newlen); | |
653 | l += (frame.bevel_w * 4); | 632 | |
654 | |||
655 | if (l > frame.window_label_w) { | ||
656 | for (; dlen >= 0; dlen--) { | ||
657 | l = screen->getToolbarStyle()->font.textWidth(foc->getTitle().c_str(), dlen); | ||
658 | |||
659 | l += (frame.bevel_w * 4); | ||
660 | |||
661 | if (l < frame.window_label_w) | ||
662 | break; | ||
663 | } | ||
664 | } | ||
665 | switch (screen->getToolbarStyle()->justify) { | ||
666 | case DrawUtil::Font::RIGHT: | ||
667 | dx += frame.window_label_w - l; | ||
668 | break; | ||
669 | |||
670 | case DrawUtil::Font::CENTER: | ||
671 | dx += (frame.window_label_w - l) / 2; | ||
672 | break; | ||
673 | default: | ||
674 | break; | ||
675 | } | ||
676 | screen->getToolbarStyle()->font.drawText( | 633 | screen->getToolbarStyle()->font.drawText( |
677 | frame.window_label, | 634 | frame.window_label, |
678 | screen->getScreenNumber(), | 635 | screen->getScreenNumber(), |
679 | screen->getToolbarStyle()->w_text_gc, | 636 | screen->getToolbarStyle()->w_text_gc, |
680 | foc->getTitle().c_str(), dlen, | 637 | foc->getTitle().c_str(), newlen, |
681 | dx, 1 + screen->getToolbarStyle()->font.ascent()); | 638 | dx, 1 + screen->getToolbarStyle()->font.ascent()); |
682 | } else | 639 | } else |
683 | XClearWindow(display, frame.window_label); | 640 | XClearWindow(display, frame.window_label); |
@@ -685,50 +642,26 @@ void Toolbar::redrawWindowLabel(bool redraw) { | |||
685 | 642 | ||
686 | 643 | ||
687 | void Toolbar::redrawWorkspaceLabel(bool redraw) { | 644 | void Toolbar::redrawWorkspaceLabel(bool redraw) { |
688 | if (screen->getCurrentWorkspace()->name().size()>0) { | 645 | if (screen->getCurrentWorkspace()->name().size()==0) |
689 | 646 | return; | |
690 | if (redraw) | ||
691 | XClearWindow(display, frame.workspace_label); | ||
692 | |||
693 | int dx = (frame.bevel_w * 2), dlen = | ||
694 | screen->getCurrentWorkspace()->name().size(); | ||
695 | unsigned int l; | ||
696 | |||
697 | l = screen->getToolbarStyle()->font.textWidth(screen->getCurrentWorkspace()->name().c_str(), dlen); | ||
698 | |||
699 | l += (frame.bevel_w * 4); | ||
700 | |||
701 | if (l > frame.workspace_label_w) { | ||
702 | for (; dlen >= 0; dlen--) { | ||
703 | l = screen->getToolbarStyle()->font.textWidth( | ||
704 | screen->getCurrentWorkspace()->name().c_str(), dlen); | ||
705 | |||
706 | l += (frame.bevel_w * 4); | ||
707 | |||
708 | if (l < frame.workspace_label_w) | ||
709 | break; | ||
710 | } | ||
711 | } | ||
712 | 647 | ||
713 | switch (screen->getToolbarStyle()->justify) { | 648 | if (redraw) |
714 | case DrawUtil::Font::RIGHT: | 649 | XClearWindow(display, frame.workspace_label); |
715 | dx += frame.workspace_label_w - l; | ||
716 | break; | ||
717 | |||
718 | case DrawUtil::Font::CENTER: | ||
719 | dx += (frame.workspace_label_w - l) / 2; | ||
720 | break; | ||
721 | default: | ||
722 | break; | ||
723 | } | ||
724 | 650 | ||
725 | screen->getToolbarStyle()->font.drawText( | 651 | const char *text = screen->getCurrentWorkspace()->name().c_str(); |
726 | frame.workspace_label, | 652 | size_t textlen = screen->getCurrentWorkspace()->name().size(); |
727 | screen->getScreenNumber(), | 653 | size_t newlen = textlen; |
728 | screen->getToolbarStyle()->l_text_gc, | 654 | int dx = DrawUtil::doAlignment(frame.workspace_label_w, frame.bevel_w, |
729 | screen->getCurrentWorkspace()->name().c_str(), dlen, | 655 | screen->getToolbarStyle()->justify, |
730 | dx, 1 + screen->getToolbarStyle()->font.ascent()); | 656 | screen->getToolbarStyle()->font, |
731 | } | 657 | text, textlen, newlen); |
658 | |||
659 | screen->getToolbarStyle()->font.drawText( | ||
660 | frame.workspace_label, | ||
661 | screen->getScreenNumber(), | ||
662 | screen->getToolbarStyle()->l_text_gc, | ||
663 | text, newlen, | ||
664 | dx, 1 + screen->getToolbarStyle()->font.ascent()); | ||
732 | } | 665 | } |
733 | 666 | ||
734 | 667 | ||
@@ -1097,7 +1030,9 @@ void Toolbar::keyPressEvent(XKeyEvent *ke) { | |||
1097 | tw = screen->getToolbarStyle()->font.textWidth(new_workspace_name.c_str(), l); | 1030 | tw = screen->getToolbarStyle()->font.textWidth(new_workspace_name.c_str(), l); |
1098 | x = (frame.workspace_label_w - tw) / 2; | 1031 | x = (frame.workspace_label_w - tw) / 2; |
1099 | 1032 | ||
1100 | if (x < (signed) frame.bevel_w) x = frame.bevel_w; | 1033 | if (x < (signed) frame.bevel_w) |
1034 | x = frame.bevel_w; | ||
1035 | |||
1101 | screen->getToolbarStyle()->font.drawText( | 1036 | screen->getToolbarStyle()->font.drawText( |
1102 | frame.workspace_label, | 1037 | frame.workspace_label, |
1103 | screen->getScreenNumber(), | 1038 | screen->getScreenNumber(), |
diff --git a/src/Window.cc b/src/Window.cc index 24e4e45..3ec9543 100644 --- a/src/Window.cc +++ b/src/Window.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: Window.cc,v 1.101 2002/11/23 16:07:19 rathnor Exp $ | 25 | // $Id: Window.cc,v 1.102 2002/11/26 16:44:48 fluxgen Exp $ |
26 | 26 | ||
27 | #include "Window.hh" | 27 | #include "Window.hh" |
28 | 28 | ||
@@ -2426,44 +2426,36 @@ void FluxboxWindow::redrawLabel() { | |||
2426 | XClearWindow(display, frame.label); | 2426 | XClearWindow(display, frame.label); |
2427 | 2427 | ||
2428 | //no need to draw the title if we don't have any | 2428 | //no need to draw the title if we don't have any |
2429 | if (getTitle().size() != 0) { | 2429 | if (getTitle().size() == 0) |
2430 | GC gc = ((focused) ? screen->getWindowStyle()->l_text_focus_gc : | 2430 | return; |
2431 | screen->getWindowStyle()->l_text_unfocus_gc); | ||
2432 | unsigned int l = client.title_text_w; | ||
2433 | int dlen = getTitle().size(); | ||
2434 | int dx = frame.bevel_w; | ||
2435 | FbTk::Font &font = screen->getWindowStyle()->font; | ||
2436 | if (l > frame.label_w) { | ||
2437 | for (; dlen >= 0; dlen--) { | ||
2438 | l = font.textWidth(getTitle().c_str(), dlen) + frame.bevel_w*4; | ||
2439 | if (l < frame.label_w) | ||
2440 | break; | ||
2441 | } | ||
2442 | } | ||
2443 | switch (screen->getWindowStyle()->justify) { | ||
2444 | case DrawUtil::Font::RIGHT: | ||
2445 | dx += frame.label_w - l; | ||
2446 | break; | ||
2447 | case DrawUtil::Font::CENTER: | ||
2448 | dx += (frame.label_w - l)/2; | ||
2449 | break; | ||
2450 | } | ||
2451 | 2431 | ||
2452 | font.drawText( | 2432 | GC gc = ((focused) ? screen->getWindowStyle()->l_text_focus_gc : |
2453 | frame.label, | 2433 | screen->getWindowStyle()->l_text_unfocus_gc); |
2454 | screen->getScreenNumber(), | 2434 | |
2455 | gc, | 2435 | size_t newlen = getTitle().size(); |
2456 | getTitle().c_str(), getTitle().size(), | 2436 | const char *labeltext = getTitle().c_str(); |
2457 | dx, screen->getWindowStyle()->font.ascent() + 1); | 2437 | FbTk::Font &font = screen->getWindowStyle()->font; |
2458 | } | 2438 | |
2439 | int align_x = DrawUtil::doAlignment( | ||
2440 | frame.label_w, frame.bevel_w*2, | ||
2441 | screen->getWindowStyle()->justify, | ||
2442 | font, | ||
2443 | labeltext, newlen, newlen); | ||
2444 | |||
2445 | font.drawText( | ||
2446 | frame.label, | ||
2447 | screen->getScreenNumber(), | ||
2448 | gc, | ||
2449 | labeltext, newlen, | ||
2450 | align_x, font.ascent() + 1); | ||
2459 | } | 2451 | } |
2460 | 2452 | ||
2461 | 2453 | ||
2462 | void FluxboxWindow::redrawAllButtons() { | 2454 | void FluxboxWindow::redrawAllButtons() { |
2463 | for (unsigned int i=0; i<buttonlist.size(); i++) | 2455 | for (unsigned int i=0; i<buttonlist.size(); i++) { |
2464 | if (buttonlist[i].draw) | 2456 | if (buttonlist[i].draw) |
2465 | buttonlist[i].draw(this, buttonlist[i].win, false); | 2457 | buttonlist[i].draw(this, buttonlist[i].win, false); |
2466 | 2458 | } | |
2467 | } | 2459 | } |
2468 | 2460 | ||
2469 | void FluxboxWindow::mapRequestEvent(XMapRequestEvent *re) { | 2461 | void FluxboxWindow::mapRequestEvent(XMapRequestEvent *re) { |