954 #endif |
954 #endif |
955 return NULL; |
955 return NULL; |
956 } |
956 } |
957 |
957 |
958 |
958 |
|
959 |
|
960 static UIWIDGET splitpane_create(UiObject *obj, UiOrientation orientation, UiSplitPaneArgs args) { |
|
961 UiObject* current = uic_current_obj(obj); |
|
962 |
|
963 GtkWidget *pane0 = create_paned(orientation); |
|
964 printf("pane0: %p\n", pane0); |
|
965 |
|
966 UI_APPLY_LAYOUT1(current, args); |
|
967 current->container->add(current->container, pane0, TRUE); |
|
968 |
|
969 int max = args.max_panes == 0 ? 2 : args.max_panes; |
|
970 |
|
971 UiObject *newobj = uic_object_new(obj, pane0); |
|
972 newobj->container = ui_splitpane_container(obj, pane0, orientation, max); |
|
973 uic_obj_add(obj, newobj); |
|
974 |
|
975 return pane0; |
|
976 } |
|
977 |
|
978 UIWIDGET ui_hsplitpane_create(UiObject *obj, UiSplitPaneArgs args) { |
|
979 return splitpane_create(obj, UI_HORIZONTAL, args); |
|
980 } |
|
981 |
|
982 UIWIDGET ui_vsplitpane_create(UiObject *obj, UiSplitPaneArgs args) { |
|
983 return splitpane_create(obj, UI_VERTICAL, args); |
|
984 } |
|
985 |
|
986 UiContainer* ui_splitpane_container(UiObject *obj, GtkWidget *pane, UiOrientation orientation, int max) { |
|
987 UiSplitPaneContainer *ct = ui_calloc(obj->ctx, 1, sizeof(UiSplitPaneContainer)); |
|
988 ct->container.widget = pane; |
|
989 ct->container.add = ui_splitpane_container_add; |
|
990 ct->current_pane = pane; |
|
991 ct->orientation = orientation; |
|
992 ct->max = max; |
|
993 return (UiContainer*)ct; |
|
994 } |
|
995 |
|
996 void ui_splitpane_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
|
997 UiSplitPaneContainer *s = (UiSplitPaneContainer*)ct; |
|
998 |
|
999 if(s->nchildren >= s->max) { |
|
1000 fprintf(stderr, "splitpane: maximum number of children reached\n"); |
|
1001 return; |
|
1002 } |
|
1003 |
|
1004 if(s->pos == 0) { |
|
1005 gtk_paned_set_start_child(GTK_PANED(s->current_pane), widget); |
|
1006 printf("pane add: %p\n", s->current_pane); |
|
1007 s->pos++; |
|
1008 s->nchildren++; |
|
1009 } else { |
|
1010 if(s->nchildren+1 == s->max) { |
|
1011 gtk_paned_set_end_child(GTK_PANED(s->current_pane), widget); |
|
1012 } else { |
|
1013 GtkWidget *pane = create_paned(s->orientation); |
|
1014 gtk_paned_set_start_child(GTK_PANED(pane), widget); |
|
1015 gtk_paned_set_end_child(GTK_PANED(s->current_pane), pane); |
|
1016 s->current_pane = pane; |
|
1017 } |
|
1018 |
|
1019 s->pos = 0; |
|
1020 s->nchildren++; |
|
1021 } |
|
1022 } |
959 |
1023 |
960 /* -------------------- ItemList Container -------------------- */ |
1024 /* -------------------- ItemList Container -------------------- */ |
961 |
1025 |
962 static void remove_item(void *data, void *item) { |
1026 static void remove_item(void *data, void *item) { |
963 UiGtkItemListContainer *ct = data; |
1027 UiGtkItemListContainer *ct = data; |