ui/common/types.c

changeset 1057
b0bc313dea43
parent 1056
541cec5e913c
child 1058
92592a640fe3
equal deleted inserted replaced
1056:541cec5e913c 1057:b0bc313dea43
808 } 808 }
809 return selection; 809 return selection;
810 } 810 }
811 811
812 UIEXPORT void ui_list_setselection(UiList *list, int index) { 812 UIEXPORT void ui_list_setselection(UiList *list, int index) {
813 ui_list_setselection2(list, index, TRUE);
814 }
815
816 UIEXPORT void ui_list_setselection2(UiList *list, int index, UiBool selection_event) {
813 if (list->setselection) { 817 if (list->setselection) {
814 UiListSelection sel = { 0, NULL }; 818 UiListSelection sel = { 0, NULL };
815 if(index >= 0) { 819 if(index >= 0) {
816 sel.count = 1; 820 sel.count = 1;
817 sel.rows = &index; 821 sel.rows = &index;
818 } 822 }
823 UiBool events = ui_selection_events_is_enabled();
824 if(!selection_event) {
825 ui_selection_events_enable(FALSE);
826 }
819 list->setselection(list, sel); 827 list->setselection(list, sel);
828 ui_selection_events_enable(events);
820 } 829 }
821 } 830 }
822 831
823 UIEXPORT void ui_listselection_free(UiListSelection selection) { 832 UIEXPORT void ui_listselection_free(UiListSelection selection) {
824 free(selection.rows); 833 free(selection.rows);
881 cxMempoolSetDestructor(destr, (cx_destructor_func)observer_destructor); 890 cxMempoolSetDestructor(destr, (cx_destructor_func)observer_destructor);
882 } 891 }
883 892
884 static int ui_set_op = 0; 893 static int ui_set_op = 0;
885 static int ui_onchange_events_enabled = TRUE; 894 static int ui_onchange_events_enabled = TRUE;
895 static int ui_selection_events_enabled = TRUE;
886 896
887 void ui_setop_enable(int set) { 897 void ui_setop_enable(int set) {
888 ui_set_op = set; 898 ui_set_op = set;
889 } 899 }
890 900
896 ui_onchange_events_enabled = enable; 906 ui_onchange_events_enabled = enable;
897 } 907 }
898 908
899 UiBool ui_onchange_events_is_enabled(void) { 909 UiBool ui_onchange_events_is_enabled(void) {
900 return ui_onchange_events_enabled; 910 return ui_onchange_events_enabled;
911 }
912
913 void ui_selection_events_enable(UiBool enable) {
914 ui_selection_events_enabled = enable;
915 }
916
917 UiBool ui_selection_events_is_enabled(void) {
918 return ui_selection_events_enabled;
901 } 919 }
902 920
903 /* ---------------- List initializers and wrapper functions ---------------- */ 921 /* ---------------- List initializers and wrapper functions ---------------- */
904 922
905 void ui_global_list_initializer(ui_list_init_func func, void *userdata) { 923 void ui_global_list_initializer(ui_list_init_func func, void *userdata) {

mercurial