ui/gtk/container.c

changeset 483
069fca2a47c2
parent 471
063a9f29098c
child 485
c584149b22f0
equal deleted inserted replaced
482:5bc95a6228b0 483:069fca2a47c2
1042 1042
1043 UiObject *newobj = uic_object_new(obj, pane0); 1043 UiObject *newobj = uic_object_new(obj, pane0);
1044 newobj->container = ui_splitpane_container(obj, pane0, orientation, max); 1044 newobj->container = ui_splitpane_container(obj, pane0, orientation, max);
1045 uic_obj_add(obj, newobj); 1045 uic_obj_add(obj, newobj);
1046 1046
1047 g_object_set_data(G_OBJECT(pane0), "ui_splitpane", newobj->container);
1048
1047 return pane0; 1049 return pane0;
1048 } 1050 }
1049 1051
1050 UIWIDGET ui_hsplitpane_create(UiObject *obj, UiSplitPaneArgs args) { 1052 UIWIDGET ui_hsplitpane_create(UiObject *obj, UiSplitPaneArgs args) {
1051 return splitpane_create(obj, UI_HORIZONTAL, args); 1053 return splitpane_create(obj, UI_HORIZONTAL, args);
1060 ct->container.widget = pane; 1062 ct->container.widget = pane;
1061 ct->container.add = ui_splitpane_container_add; 1063 ct->container.add = ui_splitpane_container_add;
1062 ct->current_pane = pane; 1064 ct->current_pane = pane;
1063 ct->orientation = orientation; 1065 ct->orientation = orientation;
1064 ct->max = max; 1066 ct->max = max;
1067 ct->children = cxArrayListCreateSimple(CX_STORE_POINTERS, 4);
1065 return (UiContainer*)ct; 1068 return (UiContainer*)ct;
1066 } 1069 }
1067 1070
1068 void ui_splitpane_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { 1071 void ui_splitpane_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
1069 UiSplitPaneContainer *s = (UiSplitPaneContainer*)ct; 1072 UiSplitPaneContainer *s = (UiSplitPaneContainer*)ct;
1070 1073
1071 if(s->nchildren >= s->max) { 1074 if(s->nchildren >= s->max) {
1072 fprintf(stderr, "splitpane: maximum number of children reached\n"); 1075 fprintf(stderr, "splitpane: maximum number of children reached\n");
1073 return; 1076 return;
1074 } 1077 }
1078
1079 cxListAdd(s->children, widget);
1075 1080
1076 if(s->pos == 0) { 1081 if(s->pos == 0) {
1077 gtk_paned_set_start_child(GTK_PANED(s->current_pane), widget); 1082 gtk_paned_set_start_child(GTK_PANED(s->current_pane), widget);
1078 s->pos++; 1083 s->pos++;
1079 s->nchildren++; 1084 s->nchildren++;
1087 s->current_pane = pane; 1092 s->current_pane = pane;
1088 } 1093 }
1089 1094
1090 s->pos = 0; 1095 s->pos = 0;
1091 s->nchildren++; 1096 s->nchildren++;
1097 }
1098 }
1099
1100 UIEXPORT void ui_splitpane_set_visible(UIWIDGET splitpane, int child_index, UiBool visible) {
1101 UiSplitPaneContainer *ct = g_object_get_data(G_OBJECT(splitpane), "ui_splitpane");
1102 if(!ct) {
1103 fprintf(stderr, "UI Error: not a splitpane\n");
1104 return;
1105 }
1106
1107 GtkWidget *w = cxListAt(ct->children, child_index);
1108 if(w) {
1109 gtk_widget_set_visible(w, visible);
1092 } 1110 }
1093 } 1111 }
1094 1112
1095 /* -------------------- ItemList Container -------------------- */ 1113 /* -------------------- ItemList Container -------------------- */
1096 1114

mercurial