Changeset 8350

Show
Ignore:
Timestamp:
01/02/12 17:55:08 (4 months ago)
Author:
westram
Message:
  • moved calculation of scrolled area (considering scrollbar indents) into method AW_window::get_scrollarea_size()
    • made involved member variables private
    • removed obsolete bottom indentation
  • DRYed more in calculate_scrollbars()
Location:
branches/e4fix/WINDOW
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/e4fix/WINDOW/AW_window.cxx

    r8349 r8350  
    403403 
    404404void AW_window::calculate_scrollbars() { 
    405     AW_screen_area screen; 
    406     this->_get_area_size(AW_MIDDLE_AREA, &screen); 
     405    AW_screen_area scrollArea; 
     406    get_scrollarea_size(&scrollArea); 
    407407 
    408408    // HORIZONTAL 
     
    414414        } 
    415415 
    416         bool      use_horizontal_bar     = true; 
    417         const int scrolled_area_width    = int(screen.r-left_indent_of_horizontal_scrollbar); 
    418         int       slider_size_horizontal = scrolled_area_width; 
     416        bool use_horizontal_bar     = true; 
     417        int  slider_size_horizontal = scrollArea.r; 
    419418 
    420419        if (slider_size_horizontal < 1) slider_size_horizontal = 1; // ist der slider zu klein (<1) ? 
     
    434433        } 
    435434        // Anpassung fuer resize, wenn unbeschriebener Bereich vergroessert wird 
    436         if (-slider_pos_horizontal + get_scrolled_picture_width() < scrolled_area_width) { 
    437             if (use_horizontal_bar) { 
    438                 slider_pos_horizontal = (int)(get_scrolled_picture_width() - scrolled_area_width); 
    439             } 
    440             else { 
    441                 slider_pos_horizontal = 0; // slider nach ganz oben, da alles sichtbar 
    442             } 
     435        int max_slider_pos = (int)(get_scrolled_picture_width() - scrollArea.r); 
     436        if (slider_pos_horizontal>max_slider_pos) { 
     437            slider_pos_horizontal = use_horizontal_bar ? max_slider_pos : 0; 
    443438        } 
    444439 
     
    458453        } 
    459454 
    460         bool      use_vertical_bar     = true; 
    461         const int scrolled_area_height = int(screen.b-top_indent_of_vertical_scrollbar-bottom_indent_of_vertical_scrollbar); 
    462         int       slider_size_vertical = scrolled_area_height; 
     455        bool use_vertical_bar     = true; 
     456        int  slider_size_vertical = scrollArea.b; 
    463457 
    464458        if (slider_size_vertical < 1) slider_size_vertical = 1; 
     
    478472        } 
    479473        // Anpassung fuer resize, wenn unbeschriebener Bereich vergroessert wird 
    480         if (-slider_pos_vertical + get_scrolled_picture_height() < scrolled_area_height) { 
    481             if (use_vertical_bar) { 
    482                 slider_pos_vertical = (int)(get_scrolled_picture_height() - scrolled_area_height); 
    483             } 
    484             else { 
    485                 slider_pos_vertical = 0; // slider nach ganz oben, da alles sichtbar 
    486             } 
    487         } 
     474        int max_slider_pos = (int)(get_scrolled_picture_height() - scrollArea.b); 
     475        if (slider_pos_vertical>max_slider_pos) { 
     476            slider_pos_vertical = use_vertical_bar ? max_slider_pos : 0; 
     477        } 
     478 
    488479        XtVaSetValues(p_w->scroll_bar_vertical, XmNsliderSize, 1, NULL); 
    489480        XtVaSetValues(p_w->scroll_bar_vertical, XmNmaximum, slider_max, NULL); 
     
    495486 
    496487void AW_window::set_vertical_scrollbar_position(int position) { 
     488#if defined(DEBUG) 
     489    fprintf(stderr, "set_vertical_scrollbar_position to %i\n", position); 
     490#endif 
     491    // @@@ test and constrain against limits 
    497492    slider_pos_vertical = position; 
    498493    XtVaSetValues(p_w->scroll_bar_vertical, XmNvalue, position, NULL); 
     
    500495 
    501496void AW_window::set_horizontal_scrollbar_position(int position) { 
     497#if defined(DEBUG) 
     498    fprintf(stderr, "set_horizontal_scrollbar_position to %i\n", position); 
     499#endif 
     500    // @@@ test and constrain against limits 
    502501    slider_pos_horizontal = position; 
    503502    XtVaSetValues(p_w->scroll_bar_horizontal, XmNvalue, position, NULL); 
     
    14401439} 
    14411440 
     1441void AW_window::get_scrollarea_size(AW_screen_area *square) { 
     1442    _get_area_size(AW_MIDDLE_AREA, square); 
     1443    square->r -= left_indent_of_horizontal_scrollbar; 
     1444    square->b -= top_indent_of_vertical_scrollbar; 
     1445} 
     1446 
    14421447void AW_window::update_scrollbar_settings_from_awars(AW_orientation orientation) { 
    1443     AW_screen_area screen; 
    1444     _get_area_size(AW_MIDDLE_AREA, &screen); 
     1448    AW_screen_area scrolled; 
     1449    get_scrollarea_size(&scrolled); 
    14451450 
    14461451    // @@@ DRY awar code 
    1447      
     1452 
    14481453    char buffer[200]; 
    14491454    if (orientation == AW_HORIZONTAL) { 
    14501455        sprintf(buffer, "window/%s/horizontal_page_increment", window_defaults_name);  
    1451         XtVaSetValues(p_w->scroll_bar_horizontal, XmNpageIncrement, (int)((screen.r-left_indent_of_horizontal_scrollbar)*(get_root()->awar(buffer)->read_int()*0.01)), NULL); 
     1456        XtVaSetValues(p_w->scroll_bar_horizontal, XmNpageIncrement, (int)(scrolled.r*(get_root()->awar(buffer)->read_int()*0.01)), NULL); 
    14521457 
    14531458        sprintf(buffer, "window/%s/scroll_width_horizontal", window_defaults_name); 
     
    14591464    else { 
    14601465        sprintf(buffer, "window/%s/vertical_page_increment", window_defaults_name); 
    1461         XtVaSetValues(p_w->scroll_bar_vertical, XmNpageIncrement, (int)((screen.b-top_indent_of_vertical_scrollbar-bottom_indent_of_vertical_scrollbar)*(get_root()->awar(buffer)->read_int()*0.01)), NULL); 
     1466        XtVaSetValues(p_w->scroll_bar_vertical, XmNpageIncrement, (int)(scrolled.b*(get_root()->awar(buffer)->read_int()*0.01)), NULL); 
    14621467 
    14631468        sprintf(buffer, "window/%s/scroll_width_vertical", window_defaults_name); 
     
    24832488} 
    24842489 
    2485 void AW_window::set_vertical_scrollbar_bottom_indent(int indent) { 
    2486     XtVaSetValues(p_w->scroll_bar_vertical, XmNbottomOffset, (int)(3+indent), NULL); 
    2487     bottom_indent_of_vertical_scrollbar = indent; 
    2488 } 
    2489  
    24902490void AW_root::apply_sensitivity(AW_active mask) { 
    24912491    aw_assert(legal_mask(mask)); 
  • branches/e4fix/WINDOW/aw_common.hxx

    r7669 r8350  
    249249        // set clipping coordinates 
    250250        screen = screen_; 
     251        aw_assert(screen.t == 0 && screen.l == 0); 
    251252    } 
    252253 
  • branches/e4fix/WINDOW/aw_window.hxx

    r8349 r8350  
    213213 
    214214    bool expose_callback_added; 
    215      
     215 
     216    int left_indent_of_horizontal_scrollbar; 
     217    int top_indent_of_vertical_scrollbar; 
     218 
    216219    void all_menus_created() const; 
    217220    void create_toggle(const char *var_name, aw_toggle_data *tdata); 
     
    286289 
    287290    AW_color_idx alloc_named_data_color(int colnum, char *colorname); 
    288     void        _get_area_size(AW_area area, AW_screen_area *square); 
    289     int         label_widget(void *wgt, AW_label str, char *mnemonic=0, int width = 0, int alignment = 0); 
     291 
     292    void _get_area_size(AW_area area, AW_screen_area *square); 
     293    void get_scrollarea_size(AW_screen_area *square); 
     294     
     295    int label_widget(void *wgt, AW_label str, char *mnemonic=0, int width = 0, int alignment = 0); 
    290296 
    291297    // ------------------------------ 
     
    297303    bool  window_is_shown; 
    298304 
    299     int left_indent_of_horizontal_scrollbar; 
    300     int top_indent_of_vertical_scrollbar; 
    301     int bottom_indent_of_vertical_scrollbar; 
    302305    int slider_pos_vertical; 
    303306    int slider_pos_horizontal; 
     
    305308 
    306309    AW_screen_area *picture;      // the result of tell scrolled 
    307                                 // picture size 
     310    // picture size 
    308311 
    309312    // -------------------------------- 
     
    391394    void set_horizontal_scrollbar_left_indent(int indent); 
    392395    void set_vertical_scrollbar_top_indent(int indent); 
    393     void set_vertical_scrollbar_bottom_indent(int indent); 
    394396 
    395397    void update_scrollbar_settings_from_awars(AW_orientation orientation);