aboutsummaryrefslogtreecommitdiff
path: root/src/Tab.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Tab.cc')
-rw-r--r--src/Tab.cc142
1 files changed, 71 insertions, 71 deletions
diff --git a/src/Tab.cc b/src/Tab.cc
index 43340a6..410d499 100644
--- a/src/Tab.cc
+++ b/src/Tab.cc
@@ -32,19 +32,19 @@ using namespace std;
32 32
33bool Tab::m_stoptabs = false; 33bool Tab::m_stoptabs = false;
34Tab::t_tabplacementlist Tab::m_tabplacementlist[] = { 34Tab::t_tabplacementlist Tab::m_tabplacementlist[] = {
35 {PTop, "Top"}, 35 {PTOP, "Top"},
36 {PBottom, "Bottom"}, 36 {PBOTTOM, "Bottom"},
37 {PLeft, "Left"}, 37 {PLEFT, "Left"},
38 {PRight, "Right"}, 38 {PRIGHT, "Right"},
39 {pnone, "none"} 39 {PNONE, "none"}
40 }; 40 };
41 41
42Tab::t_tabplacementlist Tab::m_tabalignmentlist[] = { 42Tab::t_tabplacementlist Tab::m_tabalignmentlist[] = {
43 {ALeft, "Left"}, 43 {ALEFT, "Left"},
44 {ACenter, "Center"}, 44 {ACENTER, "Center"},
45 {ARight, "Right"}, 45 {ARIGHT, "Right"},
46 {ARelative, "Relative"}, 46 {ARELATIVE, "Relative"},
47 {anone, "none"} 47 {ANONE, "none"}
48 }; 48 };
49 49
50Tab::Tab(FluxboxWindow *win, Tab *prev, Tab *next) { 50Tab::Tab(FluxboxWindow *win, Tab *prev, Tab *next) {
@@ -57,8 +57,8 @@ Tab::Tab(FluxboxWindow *win, Tab *prev, Tab *next) {
57 m_win = win; 57 m_win = win;
58 m_display = Fluxbox::instance()->getXDisplay(); 58 m_display = Fluxbox::instance()->getXDisplay();
59 59
60 if ((m_win->getScreen()->getTabPlacement() == PLeft || 60 if ((m_win->getScreen()->getTabPlacement() == PLEFT ||
61 m_win->getScreen()->getTabPlacement() == PRight) && 61 m_win->getScreen()->getTabPlacement() == PRIGHT) &&
62 m_win->getScreen()->isTabRotateVertical()) { 62 m_win->getScreen()->isTabRotateVertical()) {
63 m_size_w = m_win->getScreen()->getTabHeight(); 63 m_size_w = m_win->getScreen()->getTabHeight();
64 m_size_h = m_win->getScreen()->getTabWidth(); 64 m_size_h = m_win->getScreen()->getTabWidth();
@@ -290,7 +290,7 @@ void Tab::resize() {
290 } 290 }
291 291
292 // need to resize tabs if in relative mode 292 // need to resize tabs if in relative mode
293 if (m_win->getScreen()->getTabAlignment() == ARelative) { 293 if (m_win->getScreen()->getTabAlignment() == ARELATIVE) {
294 calcIncrease(); 294 calcIncrease();
295 setPosition(); 295 setPosition();
296 } 296 }
@@ -306,13 +306,13 @@ void Tab::shade() {
306 first->m_win->shade(); 306 first->m_win->shade();
307 } 307 }
308 308
309 if (m_win->getScreen()->getTabPlacement() == PLeft || 309 if (m_win->getScreen()->getTabPlacement() == PLEFT ||
310 m_win->getScreen()->getTabPlacement() == PRight) { 310 m_win->getScreen()->getTabPlacement() == PRIGHT) {
311 resizeGroup(); 311 resizeGroup();
312 calcIncrease(); 312 calcIncrease();
313 } 313 }
314 314
315 if (!(m_win->getScreen()->getTabPlacement() == PTop)) 315 if (!(m_win->getScreen()->getTabPlacement() == PTOP))
316 setPosition(); 316 setPosition();
317} 317}
318 318
@@ -329,8 +329,8 @@ void Tab::draw(bool pressed) {
329 m_win->getScreen()->getWindowStyle()->tab.l_text_unfocus_gc); 329 m_win->getScreen()->getWindowStyle()->tab.l_text_unfocus_gc);
330 330
331 // Different routines for drawing rotated text 331 // Different routines for drawing rotated text
332 if ((m_win->getScreen()->getTabPlacement() == PLeft || 332 if ((m_win->getScreen()->getTabPlacement() == PLEFT ||
333 m_win->getScreen()->getTabPlacement() == PRight) && 333 m_win->getScreen()->getTabPlacement() == PRIGHT) &&
334 (!m_win->isShaded() && m_win->getScreen()->isTabRotateVertical())) { 334 (!m_win->isShaded() && m_win->getScreen()->isTabRotateVertical())) {
335 335
336 tabtext_w = Misc::XRotTextWidth(m_win->getScreen()->getWindowStyle()->tab.rot_font, 336 tabtext_w = Misc::XRotTextWidth(m_win->getScreen()->getWindowStyle()->tab.rot_font,
@@ -384,10 +384,10 @@ void Tab::setPosition() {
384 //posible movement to a static member function 384 //posible movement to a static member function
385 385
386 //Tab placement 386 //Tab placement
387 if (m_win->getScreen()->getTabPlacement() == PTop) { 387 if (m_win->getScreen()->getTabPlacement() == PTOP) {
388 pos_y = m_win->frame.y - m_size_h; 388 pos_y = m_win->frame.y - m_size_h;
389 389
390 } else if (m_win->getScreen()->getTabPlacement() == PBottom || 390 } else if (m_win->getScreen()->getTabPlacement() == PBOTTOM ||
391 m_win->isShaded()) { 391 m_win->isShaded()) {
392 if (m_win->isShaded()) 392 if (m_win->isShaded())
393 pos_y = m_win->frame.y + m_win->getTitleHeight() + 393 pos_y = m_win->frame.y + m_win->getTitleHeight() +
@@ -397,42 +397,42 @@ void Tab::setPosition() {
397 pos_y = m_win->frame.y + m_win->getHeight() + 397 pos_y = m_win->frame.y + m_win->getHeight() +
398 m_win->getScreen()->getBorderWidth2x(); 398 m_win->getScreen()->getBorderWidth2x();
399 399
400 } else if (m_win->getScreen()->getTabPlacement() == PLeft) { 400 } else if (m_win->getScreen()->getTabPlacement() == PLEFT) {
401 pos_x = m_win->frame.x - m_size_w; 401 pos_x = m_win->frame.x - m_size_w;
402 402
403 } else if (m_win->getScreen()->getTabPlacement() == PRight) { 403 } else if (m_win->getScreen()->getTabPlacement() == PRIGHT) {
404 pos_x = m_win->frame.x + m_win->frame.width + 404 pos_x = m_win->frame.x + m_win->frame.width +
405 m_win->getScreen()->getBorderWidth2x(); 405 m_win->getScreen()->getBorderWidth2x();
406 } 406 }
407 407
408 //Tab alignment 408 //Tab alignment
409 if (m_win->getScreen()->getTabPlacement() == PTop || 409 if (m_win->getScreen()->getTabPlacement() == PTOP ||
410 m_win->getScreen()->getTabPlacement() == PBottom || 410 m_win->getScreen()->getTabPlacement() == PBOTTOM ||
411 m_win->isShaded()) { 411 m_win->isShaded()) {
412 switch(m_win->getScreen()->getTabAlignment()) { 412 switch(m_win->getScreen()->getTabAlignment()) {
413 case ARelative: 413 case ARELATIVE:
414 case ALeft: 414 case ALEFT:
415 pos_x = m_win->frame.x; 415 pos_x = m_win->frame.x;
416 break; 416 break;
417 case ACenter: 417 case ACENTER:
418 pos_x = calcCenterXPos(); 418 pos_x = calcCenterXPos();
419 break; 419 break;
420 case ARight: 420 case ARIGHT:
421 pos_x = m_win->frame.x + m_win->frame.width + 421 pos_x = m_win->frame.x + m_win->frame.width +
422 m_win->getScreen()->getBorderWidth2x() - m_size_w; 422 m_win->getScreen()->getBorderWidth2x() - m_size_w;
423 break; 423 break;
424 } 424 }
425 } else { //PLeft | PRight 425 } else { //PLeft | PRight
426 switch(m_win->getScreen()->getTabAlignment()) { 426 switch(m_win->getScreen()->getTabAlignment()) {
427 case ALeft: 427 case ALEFT:
428 pos_y = m_win->frame.y - m_size_h + m_win->frame.height + 428 pos_y = m_win->frame.y - m_size_h + m_win->frame.height +
429 m_win->getScreen()->getBorderWidth2x(); 429 m_win->getScreen()->getBorderWidth2x();
430 break; 430 break;
431 case ACenter: 431 case ACENTER:
432 pos_y = calcCenterYPos(); 432 pos_y = calcCenterYPos();
433 break; 433 break;
434 case ARelative: 434 case ARELATIVE:
435 case ARight: 435 case ARIGHT:
436 pos_y = m_win->frame.y; 436 pos_y = m_win->frame.y;
437 break; 437 break;
438 } 438 }
@@ -468,40 +468,40 @@ void Tab::calcIncrease(void) {
468 int inc_x = 0, inc_y = 0; 468 int inc_x = 0, inc_y = 0;
469 unsigned int tabs = 0, i = 0; 469 unsigned int tabs = 0, i = 0;
470 470
471 if (m_win->getScreen()->getTabPlacement() == PTop || 471 if (m_win->getScreen()->getTabPlacement() == PTOP ||
472 m_win->getScreen()->getTabPlacement() == PBottom || 472 m_win->getScreen()->getTabPlacement() == PBOTTOM ||
473 m_win->isShaded()) { 473 m_win->isShaded()) {
474 inc_y = 0; 474 inc_y = 0;
475 475
476 switch(m_win->getScreen()->getTabAlignment()) { 476 switch(m_win->getScreen()->getTabAlignment()) {
477 case ALeft: 477 case ALEFT:
478 inc_x = m_size_w; 478 inc_x = m_size_w;
479 break; 479 break;
480 case ACenter: 480 case ACENTER:
481 inc_x = m_size_w; 481 inc_x = m_size_w;
482 break; 482 break;
483 case ARight: 483 case ARIGHT:
484 inc_x = -m_size_w; 484 inc_x = -m_size_w;
485 break; 485 break;
486 case ARelative: 486 case ARELATIVE:
487 inc_x = calcRelativeWidth(); 487 inc_x = calcRelativeWidth();
488 break; 488 break;
489 } 489 }
490 } else if (m_win->getScreen()->getTabPlacement() == PLeft || 490 } else if (m_win->getScreen()->getTabPlacement() == PLEFT ||
491 m_win->getScreen()->getTabPlacement() == PRight) { 491 m_win->getScreen()->getTabPlacement() == PRIGHT) {
492 inc_x = 0; 492 inc_x = 0;
493 493
494 switch(m_win->getScreen()->getTabAlignment()) { 494 switch(m_win->getScreen()->getTabAlignment()) {
495 case ALeft: 495 case ALEFT:
496 inc_y = -m_size_h; 496 inc_y = -m_size_h;
497 break; 497 break;
498 case ACenter: 498 case ACENTER:
499 inc_y = m_size_h; 499 inc_y = m_size_h;
500 break; 500 break;
501 case ARight: 501 case ARIGHT:
502 inc_y = m_size_h; 502 inc_y = m_size_h;
503 break; 503 break;
504 case ARelative: 504 case ARELATIVE:
505 inc_y = calcRelativeHeight(); 505 inc_y = calcRelativeHeight();
506 break; 506 break;
507 } 507 }
@@ -512,10 +512,10 @@ void Tab::calcIncrease(void) {
512 for (first = getFirst(this); first!=0; first = first->m_next, i++){ 512 for (first = getFirst(this); first!=0; first = first->m_next, i++){
513 513
514 //TODO: move this out from here? 514 //TODO: move this out from here?
515 if ((m_win->getScreen()->getTabPlacement() == PTop || 515 if ((m_win->getScreen()->getTabPlacement() == PTOP ||
516 m_win->getScreen()->getTabPlacement() == PBottom || 516 m_win->getScreen()->getTabPlacement() == PBOTTOM ||
517 m_win->isShaded()) && 517 m_win->isShaded()) &&
518 m_win->getScreen()->getTabAlignment() == ARelative) { 518 m_win->getScreen()->getTabAlignment() == ARELATIVE) {
519 if (!((m_win->frame.width + 519 if (!((m_win->frame.width +
520 m_win->getScreen()->getBorderWidth2x()) % tabs) || 520 m_win->getScreen()->getBorderWidth2x()) % tabs) ||
521 i >= ((m_win->frame.width + 521 i >= ((m_win->frame.width +
@@ -527,7 +527,7 @@ void Tab::calcIncrease(void) {
527 first->m_inc_x = inc_x + 1; 527 first->m_inc_x = inc_x + 1;
528 } 528 }
529 first->m_inc_y = inc_y; 529 first->m_inc_y = inc_y;
530 } else if (m_win->getScreen()->getTabAlignment() == ARelative) { 530 } else if (m_win->getScreen()->getTabAlignment() == ARELATIVE) {
531 if (!((m_win->frame.height + 531 if (!((m_win->frame.height +
532 m_win->getScreen()->getBorderWidth2x()) % tabs) || 532 m_win->getScreen()->getBorderWidth2x()) % tabs) ||
533 i >= ((m_win->frame.height + 533 i >= ((m_win->frame.height +
@@ -620,32 +620,32 @@ void Tab::buttonReleaseEvent(XButtonEvent *be) {
620 dest_x = be->x_root; 620 dest_x = be->x_root;
621 dest_y = be->y_root; 621 dest_y = be->y_root;
622 622
623 if (placement == PTop || placement == PBottom || m_win->isShaded()) { 623 if (placement == PTOP || placement == PBOTTOM || m_win->isShaded()) {
624 if (placement == PBottom && !m_win->isShaded()) 624 if (placement == PBOTTOM && !m_win->isShaded())
625 dest_y -= m_win->frame.height; 625 dest_y -= m_win->frame.height;
626 else if (placement != PTop && m_win->isShaded()) 626 else if (placement != PTOP && m_win->isShaded())
627 dest_y -= m_win->getTitleHeight(); 627 dest_y -= m_win->getTitleHeight();
628 else // PTop 628 else // PTOP
629 dest_y += m_win->getTitleHeight(); 629 dest_y += m_win->getTitleHeight();
630 630
631 switch(m_win->getScreen()->getTabAlignment()) { 631 switch(m_win->getScreen()->getTabAlignment()) {
632 case ACenter: 632 case ACENTER:
633 dest_x -= (m_win->frame.width / 2) - (m_size_w / 2); 633 dest_x -= (m_win->frame.width / 2) - (m_size_w / 2);
634 break; 634 break;
635 case ARight: 635 case ARIGHT:
636 dest_x -= m_win->frame.width - m_size_w; 636 dest_x -= m_win->frame.width - m_size_w;
637 break; 637 break;
638 } 638 }
639 639
640 } else { // PLeft & PRight 640 } else { // PLEFT & PRIGHT
641 if (placement == PRight) 641 if (placement == PRIGHT)
642 dest_x = be->x_root - m_win->frame.width; 642 dest_x = be->x_root - m_win->frame.width;
643 643
644 switch(m_win->getScreen()->getTabAlignment()) { 644 switch(m_win->getScreen()->getTabAlignment()) {
645 case ACenter: 645 case ACENTER:
646 dest_y -= (m_win->frame.height / 2) - (m_size_h / 2); 646 dest_y -= (m_win->frame.height / 2) - (m_size_h / 2);
647 break; 647 break;
648 case ALeft: 648 case ALEFT:
649 dest_y -= m_win->frame.height - m_size_h; 649 dest_y -= m_win->frame.height - m_size_h;
650 break; 650 break;
651 } 651 }
@@ -840,8 +840,8 @@ void Tab::insert(Tab *tab) {
840 if (m_win->isShaded() != tab->m_win->isShaded()) { 840 if (m_win->isShaded() != tab->m_win->isShaded()) {
841 tab->m_stoptabs = true; // we don't want any actions performed on the 841 tab->m_stoptabs = true; // we don't want any actions performed on the
842 // tabs, just the tab windows! 842 // tabs, just the tab windows!
843 if (m_win->getScreen()->getTabPlacement() == PLeft || 843 if (m_win->getScreen()->getTabPlacement() == PLEFT ||
844 m_win->getScreen()->getTabPlacement() == PRight) 844 m_win->getScreen()->getTabPlacement() == PRIGHT)
845 resize_tabs = true; 845 resize_tabs = true;
846 846
847 // if the window we are grouping to, we need to shade the tab window 847 // if the window we are grouping to, we need to shade the tab window
@@ -874,7 +874,7 @@ void Tab::insert(Tab *tab) {
874 } 874 }
875 875
876 // resize if in relative mode or resize_tabs is true 876 // resize if in relative mode or resize_tabs is true
877 if(m_win->getScreen()->getTabAlignment() == ARelative || 877 if(m_win->getScreen()->getTabAlignment() == ARELATIVE ||
878 resize_tabs) { 878 resize_tabs) {
879 resizeGroup(); 879 resizeGroup();
880 calcIncrease(); 880 calcIncrease();
@@ -903,12 +903,12 @@ void Tab::disconnect() {
903 903
904 //reposition the tabs 904 //reposition the tabs
905 if (tmp) { 905 if (tmp) {
906 if (m_win->getScreen()->getTabAlignment() == ARelative) 906 if (m_win->getScreen()->getTabAlignment() == ARELATIVE)
907 tmp->calcIncrease(); 907 tmp->calcIncrease();
908 tmp->setPosition(); 908 tmp->setPosition();
909 } 909 }
910 910
911 if (m_win->getScreen()->getTabAlignment() == ARelative) 911 if (m_win->getScreen()->getTabAlignment() == ARELATIVE)
912 calcIncrease(); 912 calcIncrease();
913 913
914 setPosition(); 914 setPosition();
@@ -957,8 +957,8 @@ void Tab::resizeGroup(void) {
957 #endif //DEBUG 957 #endif //DEBUG
958 Tab *first; 958 Tab *first;
959 for (first = getFirst(this); first != 0; first = first->m_next) { 959 for (first = getFirst(this); first != 0; first = first->m_next) {
960 if ((m_win->getScreen()->getTabPlacement() == PLeft || 960 if ((m_win->getScreen()->getTabPlacement() == PLEFT ||
961 m_win->getScreen()->getTabPlacement() == PRight) && 961 m_win->getScreen()->getTabPlacement() == PRIGHT) &&
962 m_win->getScreen()->isTabRotateVertical() && 962 m_win->getScreen()->isTabRotateVertical() &&
963 !m_win->isShaded()) { 963 !m_win->isShaded()) {
964 first->setTabWidth(m_win->getScreen()->getTabHeight()); 964 first->setTabWidth(m_win->getScreen()->getTabHeight());
@@ -1026,7 +1026,7 @@ unsigned int Tab::calcCenterYPos() {
1026// tabplacement number on success else 0. 1026// tabplacement number on success else 0.
1027//---------------------------------------- 1027//----------------------------------------
1028const char *Tab::getTabPlacementString(int placement) { 1028const char *Tab::getTabPlacementString(int placement) {
1029 for (int i=0; i<(pnone / 5); i++) { 1029 for (int i=0; i<(PNONE / 5); i++) {
1030 if (m_tabplacementlist[i] == placement) 1030 if (m_tabplacementlist[i] == placement)
1031 return m_tabplacementlist[i].string; 1031 return m_tabplacementlist[i].string;
1032 } 1032 }
@@ -1039,12 +1039,12 @@ const char *Tab::getTabPlacementString(int placement) {
1039// the type none on failure. 1039// the type none on failure.
1040//---------------------------------------- 1040//----------------------------------------
1041int Tab::getTabPlacementNum(const char *string) { 1041int Tab::getTabPlacementNum(const char *string) {
1042 for (int i=0; i<(pnone / 5); i ++) { 1042 for (int i=0; i<(PNONE / 5); i ++) {
1043 if (m_tabplacementlist[i] == string) { 1043 if (m_tabplacementlist[i] == string) {
1044 return m_tabplacementlist[i].tp; 1044 return m_tabplacementlist[i].tp;
1045 } 1045 }
1046 } 1046 }
1047 return pnone; 1047 return PNONE;
1048} 1048}
1049 1049
1050//------- getTabAlignmentString ---------- 1050//------- getTabAlignmentString ----------
@@ -1052,7 +1052,7 @@ int Tab::getTabPlacementNum(const char *string) {
1052// tabplacement number on success else 0. 1052// tabplacement number on success else 0.
1053//---------------------------------------- 1053//----------------------------------------
1054const char *Tab::getTabAlignmentString(int placement) { 1054const char *Tab::getTabAlignmentString(int placement) {
1055 for (int i=0; i<anone; i++) { 1055 for (int i=0; i<ANONE; i++) {
1056 if (m_tabalignmentlist[i] == placement) 1056 if (m_tabalignmentlist[i] == placement)
1057 return m_tabalignmentlist[i].string; 1057 return m_tabalignmentlist[i].string;
1058 } 1058 }
@@ -1065,10 +1065,10 @@ const char *Tab::getTabAlignmentString(int placement) {
1065// the type none on failure. 1065// the type none on failure.
1066//---------------------------------------- 1066//----------------------------------------
1067int Tab::getTabAlignmentNum(const char *string) { 1067int Tab::getTabAlignmentNum(const char *string) {
1068 for (int i=0; i<anone; i++) { 1068 for (int i=0; i<ANONE; i++) {
1069 if (m_tabalignmentlist[i] == string) { 1069 if (m_tabalignmentlist[i] == string) {
1070 return m_tabalignmentlist[i].tp; 1070 return m_tabalignmentlist[i].tp;
1071 } 1071 }
1072 } 1072 }
1073 return anone; 1073 return ANONE;
1074} 1074}