aboutsummaryrefslogtreecommitdiff
path: root/src/Toolbar.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-11-26 16:46:05 (GMT)
committerfluxgen <fluxgen>2002-11-26 16:46:05 (GMT)
commit558aa0f9f970b95bdd14582da7690a8208fe7bb9 (patch)
tree09d948b979f4c803f8ca154d5d1bd6d3a731db81 /src/Toolbar.cc
parent75eb138d4e07d6f1024963f4ac9561dfd7a34b54 (diff)
downloadfluxbox_pavel-558aa0f9f970b95bdd14582da7690a8208fe7bb9.zip
fluxbox_pavel-558aa0f9f970b95bdd14582da7690a8208fe7bb9.tar.bz2
using drawutil's doAlignment function
Diffstat (limited to 'src/Toolbar.cc')
-rw-r--r--src/Toolbar.cc139
1 files changed, 37 insertions, 102 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
687void Toolbar::redrawWorkspaceLabel(bool redraw) { 644void 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(),