ui/motif/container.c

changeset 92
d56175dd931e
parent 91
c13e344fa55f
child 93
5223de7979e2
equal deleted inserted replaced
91:c13e344fa55f 92:d56175dd931e
479 479
480 int width = 0; 480 int width = 0;
481 int height = 0; 481 int height = 0;
482 XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL); 482 XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL);
483 int button_width = width / 4; 483 int button_width = width / 4;
484 int button_height = 0;
484 int x = 0; 485 int x = 0;
485 UCX_FOREACH(elm, v->tabs) { 486 UCX_FOREACH(elm, v->tabs) {
486 UiTab *tab = elm->data; 487 UiTab *tab = elm->data;
487 XtVaSetValues( 488 XtVaSetValues(
488 tab->tab_button, 489 tab->tab_button,
489 XmNx, x, 490 XmNx, x,
490 XmNy, 0, 491 XmNy, 0,
491 XmNwidth, 492 XmNwidth,
492 button_width, 493 button_width,
494 XmNheight,
495 v->height,
493 NULL); 496 NULL);
494 x += button_width; 497 x += button_width;
498 }
499
500 if(height <= v->height) {
501 XtVaSetValues(widget, XmNheight, v->height + (v->height/7), NULL);
495 } 502 }
496 } 503 }
497 504
498 static void ui_tabbar_expose(Widget widget, XtPointer udata, XtPointer cdata) { 505 static void ui_tabbar_expose(Widget widget, XtPointer udata, XtPointer cdata) {
499 MotifTabbedPane *v = (MotifTabbedPane*)udata; 506 MotifTabbedPane *v = (MotifTabbedPane*)udata;
500 XmDrawingAreaCallbackStruct *cbs = (XmDrawingAreaCallbackStruct *)cdata; 507 XmDrawingAreaCallbackStruct *cbs = (XmDrawingAreaCallbackStruct *)cdata;
501 XEvent *event = cbs->event; 508 XEvent *event = cbs->event;
509 Display *dpy = XtDisplay(widget);
510
511 XGCValues gcvals;
512 GC gc;
513 Pixel fgpix;
514
515 int tab_x;
516 int tab_width;
517 XtVaGetValues(v->current->tab_button, XmNx, &tab_x, XmNwidth, &tab_width, XmNhighlightColor, &fgpix, NULL);
518
519 gcvals.foreground = v->bg1;
520 gc = XCreateGC( dpy, XtWindow(widget), (GCForeground), &gcvals);
521
522 int width = 0;
523 int height = 0;
524 XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL);
525 XFillRectangle(dpy, XtWindow(widget), gc, 0, 0, width, height);
526
527 gcvals.foreground = fgpix;
528 gc = XCreateGC( dpy, XtWindow(widget), (GCForeground), &gcvals);
529
530 XFillRectangle(dpy, XtWindow(widget), gc, tab_x, 0, tab_width, height);
531
502 } 532 }
503 533
504 UiTabbedPane* ui_tabbed_document_view(UiObject *obj) { 534 UiTabbedPane* ui_tabbed_document_view(UiObject *obj) {
505 int n = 0; 535 int n = 0;
506 Arg args[16]; 536 Arg args[16];
536 tabbedpane->view.widget = tabct; 566 tabbedpane->view.widget = tabct;
537 tabbedpane->view.document = NULL; 567 tabbedpane->view.document = NULL;
538 tabbedpane->tabbar = tabbar; 568 tabbedpane->tabbar = tabbar;
539 tabbedpane->tabs = NULL; 569 tabbedpane->tabs = NULL;
540 tabbedpane->current = NULL; 570 tabbedpane->current = NULL;
541 571 tabbedpane->height = 0;
542 XGCValues gcv;
543 572
544 XtAddCallback(tabbar, XmNresizeCallback , ui_tabbar_resize, tabbedpane); 573 XtAddCallback(tabbar, XmNresizeCallback , ui_tabbar_resize, tabbedpane);
545 XtAddCallback(tabbar, XmNexposeCallback, ui_tabbar_expose, tabbedpane); 574 XtAddCallback(tabbar, XmNexposeCallback, ui_tabbar_expose, tabbedpane);
546 575
547 return &tabbedpane->view; 576 return &tabbedpane->view;
597 button, 626 button,
598 XmNactivateCallback, 627 XmNactivateCallback,
599 (XtCallbackProc)ui_tab_button_callback, 628 (XtCallbackProc)ui_tab_button_callback,
600 tab); 629 tab);
601 630
631 if(v->height == 0) {
632 XtVaGetValues(
633 button,
634 XmNarmColor,
635 &v->bg1,
636 XmNbackground,
637 &v->bg2,
638 XmNheight,
639 &v->height,
640 NULL);
641 }
642
602 ui_change_tab(v, tab); 643 ui_change_tab(v, tab);
603 ui_tabbar_resize(v->tabbar, v, NULL); 644 ui_tabbar_resize(v->tabbar, v, NULL);
604 645
605 return content; 646 return content;
606 } 647 }
619 660
620 void ui_change_tab(MotifTabbedPane *pane, UiTab *tab) { 661 void ui_change_tab(MotifTabbedPane *pane, UiTab *tab) {
621 UiContext *ctx = tab->content->ctx; 662 UiContext *ctx = tab->content->ctx;
622 ctx->parent->set_document(ctx->parent, ctx->document); 663 ctx->parent->set_document(ctx->parent, ctx->document);
623 664
665 if(pane->current) {
666 XtVaSetValues(pane->current->tab_button, XmNshadowThickness, 0, XmNbackground, pane->bg1, NULL);
667 }
668 XtVaSetValues(tab->tab_button, XmNshadowThickness, 1, XmNbackground, pane->bg2, NULL);
669
624 pane->current = tab; 670 pane->current = tab;
625 pane->index = ucx_list_find(pane->tabs, tab, NULL, NULL); 671 pane->index = ucx_list_find(pane->tabs, tab, NULL, NULL);
626 printf("index: %d\n", pane->index); 672 printf("index: %d\n", pane->index);
673
674 // redraw tabbar
675 Display *dpy = XtDisplay(pane->tabbar);
676 Window window = XtWindow(pane->tabbar);
677 if(dpy && window) {
678 XClearArea(dpy, XtWindow(pane->tabbar), 0, 0, 0, 0, TRUE);
679 XFlush(dpy);
680 }
627 } 681 }
628 682
629 void ui_tab_set_document(UiContext *ctx, void *document) { 683 void ui_tab_set_document(UiContext *ctx, void *document) {
630 if(ctx->parent->document) { 684 if(ctx->parent->document) {
631 //ctx->parent->detach_document(ctx->parent, ctx->parent->document); 685 //ctx->parent->detach_document(ctx->parent, ctx->parent->document);

mercurial