Mercurial > pidgin
comparison console/libgnt/gntbox.c @ 14343:0387a167f342
[gaim-migrate @ 17044]
A WM can now act on keystrokes. As an example, the sample WM will toggle
the buddylist on pressing Alt+b.
Mouse clicking and scrolling is now supported in most/all widgets.
To use a WM, you need to add "wm=/path/to/wm.so" under [general] in ~/.gntrc.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 26 Aug 2006 12:54:39 +0000 |
parents | 1a500db56415 |
children | f4af666fafe3 |
comparison
equal
deleted
inserted
replaced
14342:12156328fb4f | 14343:0387a167f342 |
---|---|
452 } | 452 } |
453 | 453 |
454 reposition_children(widget); | 454 reposition_children(widget); |
455 } | 455 } |
456 | 456 |
457 static gboolean | |
458 gnt_box_clicked(GntWidget *widget, GntMouseEvent event, int cx, int cy) | |
459 { | |
460 GList *iter; | |
461 for (iter = GNT_BOX(widget)->list; iter; iter = iter->next) { | |
462 int x, y, w, h; | |
463 GntWidget *wid = iter->data; | |
464 | |
465 gnt_widget_get_position(wid, &x, &y); | |
466 gnt_widget_get_size(wid, &w, &h); | |
467 | |
468 if (cx >= x && cx < x + w && cy >= y && cy < y + h) { | |
469 if (event <= GNT_MIDDLE_MOUSE_DOWN && | |
470 GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_CAN_TAKE_FOCUS)) { | |
471 while (widget->parent) | |
472 widget = widget->parent; | |
473 gnt_box_give_focus_to_child(GNT_BOX(widget), wid); | |
474 } | |
475 return gnt_widget_clicked(wid, event, cx, cy); | |
476 } | |
477 } | |
478 return FALSE; | |
479 } | |
480 | |
457 static void | 481 static void |
458 gnt_box_class_init(GntBoxClass *klass) | 482 gnt_box_class_init(GntBoxClass *klass) |
459 { | 483 { |
460 parent_class = GNT_WIDGET_CLASS(klass); | 484 parent_class = GNT_WIDGET_CLASS(klass); |
461 parent_class->destroy = gnt_box_destroy; | 485 parent_class->destroy = gnt_box_destroy; |
463 parent_class->expose = gnt_box_expose; | 487 parent_class->expose = gnt_box_expose; |
464 parent_class->map = gnt_box_map; | 488 parent_class->map = gnt_box_map; |
465 parent_class->size_request = gnt_box_size_request; | 489 parent_class->size_request = gnt_box_size_request; |
466 parent_class->set_position = gnt_box_set_position; | 490 parent_class->set_position = gnt_box_set_position; |
467 parent_class->key_pressed = gnt_box_key_pressed; | 491 parent_class->key_pressed = gnt_box_key_pressed; |
492 parent_class->clicked = gnt_box_clicked; | |
468 parent_class->lost_focus = gnt_box_lost_focus; | 493 parent_class->lost_focus = gnt_box_lost_focus; |
469 parent_class->gained_focus = gnt_box_gained_focus; | 494 parent_class->gained_focus = gnt_box_gained_focus; |
470 parent_class->confirm_size = gnt_box_confirm_size; | 495 parent_class->confirm_size = gnt_box_confirm_size; |
471 parent_class->size_changed = gnt_box_size_changed; | 496 parent_class->size_changed = gnt_box_size_changed; |
472 | 497 |
601 x = w->priv.x - widget->priv.x; | 626 x = w->priv.x - widget->priv.x; |
602 y = w->priv.y - widget->priv.y; | 627 y = w->priv.y - widget->priv.y; |
603 | 628 |
604 if (box->vertical) | 629 if (box->vertical) |
605 { | 630 { |
631 x = pos; | |
606 if (box->alignment == GNT_ALIGN_RIGHT) | 632 if (box->alignment == GNT_ALIGN_RIGHT) |
607 x += widget->priv.width - width; | 633 x += widget->priv.width - width; |
608 else if (box->alignment == GNT_ALIGN_MID) | 634 else if (box->alignment == GNT_ALIGN_MID) |
609 x += (widget->priv.width - width)/2; | 635 x += (widget->priv.width - width)/2; |
610 if (x + width > widget->priv.width - pos) | 636 if (x + width > widget->priv.width - pos) |
611 x -= x + width - (widget->priv.width - pos); | 637 x -= x + width - (widget->priv.width - pos); |
612 } | 638 } |
613 else | 639 else |
614 { | 640 { |
641 y = pos; | |
615 if (box->alignment == GNT_ALIGN_BOTTOM) | 642 if (box->alignment == GNT_ALIGN_BOTTOM) |
616 y += widget->priv.height - height; | 643 y += widget->priv.height - height; |
617 else if (box->alignment == GNT_ALIGN_MID) | 644 else if (box->alignment == GNT_ALIGN_MID) |
618 y += (widget->priv.height - height)/2; | 645 y += (widget->priv.height - height)/2; |
619 if (y + height >= widget->priv.height - pos) | 646 if (y + height >= widget->priv.height - pos) |
620 y = widget->priv.height - height - pos; | 647 y = widget->priv.height - height - pos; |
621 } | 648 } |
622 | 649 |
623 copywin(w->window, widget->window, 0, 0, | 650 copywin(w->window, widget->window, 0, 0, |
624 y, x, y + height - 1, x + width - 1, FALSE); | 651 y, x, y + height - 1, x + width - 1, FALSE); |
652 gnt_widget_set_position(w, x + widget->priv.x, y + widget->priv.y); | |
625 } | 653 } |
626 } | 654 } |
627 | 655 |
628 void gnt_box_set_alignment(GntBox *box, GntAlignment alignment) | 656 void gnt_box_set_alignment(GntBox *box, GntAlignment alignment) |
629 { | 657 { |