Show
Ignore:
Timestamp:
21/05/10 19:44:17 (2 years ago)
Author:
westram
Message:
  • AW_root
    • ctor initializes AWAR subsystem
    • made more clear that AW_root is a singleton
    • call dtor atexit; unlink AWARs from prop-DB and free memory (AW_window instances and releated mem still remain)
    • close properties DB
    • renamed some functions
  • AW_awar
    • added dtor
  • added AWT_create_root (necessary to add properties DB to DB-browser)
  • removed AWT_open_properties (done inside AW_root-ctor now)
  • EDIT properties
    • detect existing properties before constructing AW_root
  • removed AW_config_struct
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/WINDOW/aw_root.hxx

    r6508 r6666  
    1616#endif 
    1717 
    18  
    19 #define AW_ROOT_DEFAULT (aw_main_root_default) 
     18#define AW_ROOT_DEFAULT AW_root::SINGLETON->check_properties(NULL) 
     19 
    2020class        AW_root; 
    2121class        AW_window; 
    22 typedef long AW_CL;             // generic client data type (void *) 
     22typedef long AW_CL;                                 // generic client data type (void *) 
    2323 
    2424typedef void (*AW_RCB)(AW_root*, AW_CL, AW_CL); 
     
    3636typedef int         AW_font; 
    3737 
    38 extern AW_default aw_main_root_default; 
    39  
    4038typedef struct _WidgetRec *Widget; 
    4139 
    42 // #define AWUSE(variable) variable = variable 
    4340#if defined(DEBUG) && defined(DEVEL_RALF) && 0 
    4441#define AWUSE(variable) (void)variable; int DONT_USE_AWUSE_FOR_##variable 
     
    180177 
    181178class AW_root { 
     179    AW_default application_database; 
     180     
     181    void init_variables(AW_default database); 
     182    void exit_variables(); 
     183 
     184    void init_root(const char *programname, bool no_exit); 
     185    AW_default load_properties(const char *default_name); 
     186 
    182187public: 
    183     static  AW_root *THIS; 
    184     AW_root_Motif   *prvt;                          // Do not use !!! 
    185     bool             value_changed; 
    186     long             changer_of_variable; 
    187     int              y_correction_for_input_labels; 
    188     AW_active        global_mask; 
    189     GB_HASH         *hash_table_for_variables; 
    190     bool             variable_set_by_toggle_field; 
    191     int              number_of_toggle_fields; 
    192     int              number_of_option_menus; 
    193     char            *program_name; 
     188    static AW_root *SINGLETON; 
     189 
     190    AW_root_Motif *prvt;                            // Do not use !!! 
     191    bool           value_changed; 
     192    long           changer_of_variable; 
     193    int            y_correction_for_input_labels; 
     194    AW_active      global_mask; 
     195    GB_HASH       *hash_table_for_variables; 
     196    bool           variable_set_by_toggle_field; 
     197    int            number_of_toggle_fields; 
     198    int            number_of_option_menus; 
     199    char          *program_name; 
    194200 
    195201    void            *get_aw_var_struct(char *awar); 
     
    204210 
    205211    // the read only public section: 
    206     AW_default  application_database; 
    207212    short       font_width; 
    208213    short       font_height; 
     
    211216 
    212217    // the real public section: 
    213     AW_root(); 
     218    AW_root(const char *properties, const char *program, bool no_exit); 
    214219    ~AW_root(); 
     220 
    215221    enum { AW_MONO_COLOR, AW_RGB_COLOR }    color_mode; 
    216222 
    217     void init_variables(AW_default database); 
    218     void init_root(const char *programname, bool no_exit); 
    219223    void main_loop(); 
    220     void process_events();     // might block 
    221     void process_pending_events();     // non-blocking 
     224     
     225    void                process_events();           // might block 
     226    void                process_pending_events();   // non-blocking 
    222227    AW_ProcessEventType peek_key_event(AW_window *); 
    223228 
     
    245250    void unlink_awars_from_DB(GBDATA *gb_main);     // use before calling GB_close for 'gb_main', if you have AWARs in DB 
    246251 
    247     AW_default  open_default(const char *default_name, bool create_if_missing = true); 
    248     AW_error   *save_default(const char *awar_name); 
    249     AW_error   *save_default(const char *awar_name, const char *file_name); 
    250     AW_error   *save_default(AW_default aw_default, const char *file_name); 
    251     AW_default  get_default(const char *varname); 
    252     AW_default  get_gbdata(const char *varname); 
     252    static const char *property_DB_fullname(const char *default_name); 
     253    static bool        property_DB_exists(const char *default_name); 
     254 
     255    AW_default check_properties(AW_default aw_props) { 
     256        return aw_props ? aw_props : application_database; 
     257    } 
     258 
     259    GB_ERROR save_properties(const char *filename = NULL) __ATTR__USERESULT; 
     260 
     261    AW_default get_gbdata(const char *varname) __ATTR__DEPRECATED; // replace by awar + gb_var 
     262 
    253263 
    254264    // Control sensitivity of buttons etc.: 
     
    330340 
    331341    AW_awar(AW_VARIABLE_TYPE var_type, const char *var_name, const char *var_value, double var_double_value, AW_default default_file, AW_root *root); 
     342    ~AW_awar(); 
    332343 
    333344    AW_awar *add_callback(Awar_CB2 f, AW_CL cd1, AW_CL cd2);