Show
Ignore:
Timestamp:
02/06/10 09:01:31 (2 years ago)
Author:
westram
Message:
  • AW_awar / widget interaction
    • replaced AW_INSERT_BUTTON_IN_AWAR_LIST by AW_awar/tie_widget
    • link AW_widget_refresh_cb in AW_awar (leak)
    • use Widget type instead of void*
    • untie_all_widgets() in dtor
  • removed deprecated header aw_awar.hxx
  • AW_root
    • delete focus_callback_list (leak)
    • method remove_button_from_sens_list replaces AW_remove_button_from_sens_list
    • moved member 'button_list' from AW_root_Motif, renamed it into 'button_sens_list' and destroy it in dtor
    • use Widget type instead of void*
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/WINDOW/AW_button.cxx

    r6584 r6675  
    1515#include "aw_size.hxx" 
    1616#include "aw_select.hxx" 
    17 #include "aw_awar.hxx" 
     17#include "aw_nawar.hxx" 
    1818#include "aw_window_Xm.hxx" 
    1919 
     
    3939#endif // DEBUG 
    4040 
    41 static void aw_cp_awar_2_widget_cb(AW_root *root, AW_widget_list_for_variable *widgetlist) { 
    42     if (widgetlist->widget == (int *)root->changer_of_variable) { 
     41struct AW_widget_refresh_cb { 
     42    AW_widget_refresh_cb(AW_widget_refresh_cb *previous, AW_awar *vs, AW_CL cd1, Widget w, AW_widget_type type, AW_window *awi); 
     43    ~AW_widget_refresh_cb(); 
     44 
     45    AW_CL           cd; 
     46    AW_awar        *awar; 
     47    Widget          widget; 
     48    AW_widget_type  widget_type; 
     49    AW_window      *aw; 
     50 
     51    AW_widget_refresh_cb *next; 
     52}; 
     53 
     54static void aw_cp_awar_2_widget_cb(AW_root *root, AW_CL cl_widget_refresh_cb) { 
     55    AW_widget_refresh_cb *widgetlist = (AW_widget_refresh_cb*)cl_widget_refresh_cb; 
     56    if (widgetlist->widget == root->changer_of_variable) { 
    4357        root->changer_of_variable = 0; 
    4458        root->value_changed = false; 
     
    8195} 
    8296 
    83  
    84 AW_widget_list_for_variable::AW_widget_list_for_variable(AW_awar *vs, AW_CL cd1, int *widgeti, AW_widget_type type, AW_window *awi) { 
     97AW_widget_refresh_cb::AW_widget_refresh_cb(AW_widget_refresh_cb *previous, AW_awar *vs, AW_CL cd1, Widget w, AW_widget_type type, AW_window *awi) { 
    8598    cd          = cd1; 
    86     widget      = widgeti; 
     99    widget      = w; 
    87100    widget_type = type; 
    88101    awar        = vs; 
    89102    aw          = awi; 
    90     next        = 0; 
    91     awar->add_callback((AW_RCB1)aw_cp_awar_2_widget_cb, (AW_CL)this); 
    92 } 
     103    next        = previous; 
     104 
     105    awar->add_callback(aw_cp_awar_2_widget_cb, (AW_CL)this); 
     106} 
     107 
     108AW_widget_refresh_cb::~AW_widget_refresh_cb() { 
     109    if (next) delete next; 
     110    awar->remove_callback(aw_cp_awar_2_widget_cb, (AW_CL)this); 
     111} 
     112 
     113void AW_awar::tie_widget(AW_CL cd1, Widget widget, AW_widget_type type, AW_window *aww) { 
     114    refresh_list = new AW_widget_refresh_cb(refresh_list, this, cd1, widget, type, aww); 
     115} 
     116void AW_awar::untie_all_widgets() { 
     117    delete refresh_list; refresh_list = NULL; 
     118} 
     119 
    93120 
    94121struct AW_variable_update_struct { // used to refresh single items on change 
     
    139166 
    140167    if (root->value_changed) { 
    141         root->changer_of_variable = (long)vus->widget; 
     168        root->changer_of_variable = vus->widget; 
    142169    } 
    143170 
     
    847874} 
    848875 
    849 void AW_window::update_label(int *widget, const char *var_value) { 
    850     Widget w = (Widget) widget; 
    851  
    852     if (get_root()->changer_of_variable != (long)widget) { 
    853         XtVaSetValues(w, RES_CONVERT(XmNlabelString, var_value), NULL); 
     876void AW_window::update_label(Widget widget, const char *var_value) { 
     877    if (get_root()->changer_of_variable != widget) { 
     878        XtVaSetValues(widget, RES_CONVERT(XmNlabelString, var_value), NULL); 
    854879    } 
    855880    else { 
     
    867892}; 
    868893 
    869 void AW_window::update_toggle(int *wgt, const char *var, AW_CL cd_toggle_data) 
    870 { 
     894void AW_window::update_toggle(Widget widget, const char *var, AW_CL cd_toggle_data) { 
    871895    aw_toggle_data *tdata = (aw_toggle_data*)cd_toggle_data; 
    872896    const char     *text  = tdata->bitmapOrText[(var[0] == '0' || var[0] == 'n') ? 0 : 1]; 
    873897 
    874898    if (tdata->isTextToggle) { 
    875         XtVaSetValues((Widget)wgt, RES_CONVERT(XmNlabelString, text), NULL); 
     899        XtVaSetValues(widget, RES_CONVERT(XmNlabelString, text), NULL); 
    876900    } 
    877901    else { 
    878902        char *path = pixmapPath(text+1); 
    879         XtVaSetValues((Widget)wgt, RES_CONVERT(XmNlabelPixmap, path), NULL); 
     903        XtVaSetValues(widget, RES_CONVERT(XmNlabelPixmap, path), NULL); 
    880904        free(path); 
    881905    } 
     
    913937        char *var_value = vs->read_as_string(); 
    914938 
    915         this->update_toggle((int*)p_w->toggle_field, var_value, (AW_CL)tdata); 
     939        this->update_toggle(p_w->toggle_field, var_value, (AW_CL)tdata); 
    916940        free(var_value); 
    917941    } 
     
    924948                  (XtPointer) vus); 
    925949 
    926     AW_INSERT_BUTTON_IN_AWAR_LIST(vs, (AW_CL)tdata, p_w->toggle_field, AW_WIDGET_TOGGLE, this); 
     950    vs->tie_widget((AW_CL)tdata, p_w->toggle_field, AW_WIDGET_TOGGLE, this); 
    927951} 
    928952 
     
    10601084                  (XtPointer) root); 
    10611085 
    1062     AW_INSERT_BUTTON_IN_AWAR_LIST(vs, 0, textField, AW_WIDGET_INPUT_FIELD, this); 
     1086    vs->tie_widget(0, textField, AW_WIDGET_INPUT_FIELD, this); 
    10631087    root->make_sensitive(textField, _at->widget_mask); 
    10641088 
     
    10881112} 
    10891113 
    1090  
    1091 void AW_window::update_input_field(int *widget, const char *var_value) { 
    1092     Widget w = (Widget) widget; 
    1093  
    1094     XtVaSetValues(w, XmNvalue, var_value, NULL); 
    1095 } 
    1096  
    1097  
    1098  
     1114void AW_window::update_input_field(Widget widget, const char *var_value) { 
     1115    XtVaSetValues(widget, XmNvalue, var_value, NULL); 
     1116} 
    10991117 
    11001118void AW_window::create_text_field(const char *var_name, int columns, int rows) { 
     
    12241242    XtAddCallback(scrolledText, XmNvalueChangedCallback, (XtCallbackProc) AW_value_changed_callback, (XtPointer) root); 
    12251243 
    1226     AW_INSERT_BUTTON_IN_AWAR_LIST(vs, 0, scrolledText, AW_WIDGET_TEXT_FIELD, this); 
     1244    vs->tie_widget(0, scrolledText, AW_WIDGET_TEXT_FIELD, this); 
    12271245    root->make_sensitive(scrolledText, _at->widget_mask); 
    12281246 
     
    12321250 
    12331251 
    1234 void AW_window::update_text_field(int *widget, const char *var_value) { 
    1235     Widget w = (Widget) widget; 
    1236  
    1237     XtVaSetValues(w, XmNvalue, var_value, NULL); 
     1252void AW_window::update_text_field(Widget widget, const char *var_value) { 
     1253    XtVaSetValues(widget, XmNvalue, var_value, NULL); 
    12381254} 
    12391255 
     
    13991415                          (XtPointer) _d_callback); 
    14001416        } 
    1401         AW_INSERT_BUTTON_IN_AWAR_LIST(vs, (AW_CL)p_global->last_selection_list, scrolledList, AW_WIDGET_SELECTION_LIST, this); 
     1417        vs->tie_widget((AW_CL)p_global->last_selection_list, scrolledList, AW_WIDGET_SELECTION_LIST, this); 
    14021418        root->make_sensitive(scrolledList, _at->widget_mask); 
    14031419    } 
     
    22092225    p_global->current_option_menu = p_global->last_option_menu; 
    22102226 
    2211     AW_INSERT_BUTTON_IN_AWAR_LIST(vs, (AW_CL)p_global->current_option_menu, optionMenu, AW_WIDGET_CHOICE_MENU, this); 
     2227    vs->tie_widget((AW_CL)p_global->current_option_menu, optionMenu, AW_WIDGET_CHOICE_MENU, this); 
    22122228    root->make_sensitive(optionMenu1, _at->widget_mask); 
    22132229 
     
    22162232 
    22172233static void remove_option_from_option_menu(AW_root *aw_root, AW_option_struct *os) { 
    2218     AW_remove_button_from_sens_list(aw_root, os->choice_widget); 
     2234    aw_root->remove_button_from_sens_list(os->choice_widget); 
    22192235    XtDestroyWidget(os->choice_widget); 
    22202236} 
     
    23522368 
    23532369void AW_window::update_option_menu(AW_option_menu_struct *oms) { 
    2354     if (get_root()->changer_of_variable != (long)oms->label_widget) { 
     2370    if (get_root()->changer_of_variable != oms->label_widget) { 
    23552371        AW_option_struct *active_choice = oms->first_choice; 
    23562372        { 
     
    25182534    } 
    25192535 
    2520     AW_INSERT_BUTTON_IN_AWAR_LIST(vs, get_root()->number_of_toggle_fields, toggle_field, AW_WIDGET_TOGGLE_FIELD, this); 
     2536    vs->tie_widget(get_root()->number_of_toggle_fields, toggle_field, AW_WIDGET_TOGGLE_FIELD, this); 
    25212537    root->make_sensitive(toggle_field, _at->widget_mask); 
    25222538}