예제 #1
0
static bool DlgRelocNum( gui_ord *pnum, int adjust, gui_coord *charuse )
{
    gui_ord     num;

    num = *pnum;
    if( num >= DLG_ROW_0 && num <= DLG_ROW_n ) {
        num -= DLG_ROW( 0 );
        num += adjust;
        num *= charuse->y;
    } else if( num >= DLG_COL_0 && num <= DLG_COL_n ) {
        num -= DLG_COL( 0 );
        num += adjust;
        num *= charuse->x;
    } else {
        return( false );
    }
    *pnum = num;
    return( true );
}
예제 #2
0
static void AdjustDialogControls( a_dialog_header *curr_dialog )
/**************************************************************/
{
    int                 i,j;
    int                 num_push_buttons, curr_button;
    gui_control_class   a_control_class;
    gui_control_info    *control, *next, *prev;
    int                 width;
    int                 but_pos;

    if( curr_dialog->def_dlg )
        return;

    if( curr_dialog->adjusted )
        return;

    curr_dialog->adjusted = TRUE;
    width = curr_dialog->cols;

    for( i = 0; i < curr_dialog->num_controls; i++ ) {
        control = &curr_dialog->controls[i];
        a_control_class = control->control_class;

        switch( a_control_class ) {

        case GUI_RADIO_BUTTON:
#if !defined( _UI )
            /* Align left edge of control with left of leftmost Button */
            but_pos = WIN_BUTTON_POS( 1, MAX_CTRL_PER_LINE, width, WIN_BW );
            control->rect.x = DLG_COL( but_pos );
#endif
            control->rect.width = DLG_COL( width - C0 - 1 );
            break;

        case GUI_CHECK_BOX:
#if !defined( _UI )
            /* Align left edge of control with left of leftmost Button */
            but_pos = WIN_BUTTON_POS( 1, MAX_CTRL_PER_LINE, width, WIN_BW );
            control->rect.x = DLG_COL( but_pos );
#endif
            // look for another control on this row
            control->rect.width = DLG_COL( width - C0 - 1 );
            if( i + 1 >= curr_dialog->num_controls )
                break;

            next = &curr_dialog->controls[i + 1];
            if( next->rect.y != control->rect.y )
                break;

            control->rect.width = DLG_COL( (width / 2) - C0 - 1 );
            if( next->control_class != GUI_CHECK_BOX )
                break;

            j = i;
            num_push_buttons = 1;
            while( ++j < curr_dialog->num_controls ) {
                next = &curr_dialog->controls[j];
                if( next->control_class != GUI_CHECK_BOX ||
                    next->rect.y != control->rect.y )
                    break;
                ++num_push_buttons;
            }
            curr_button = 0;
            while( i < j ) {
                control->rect.width =
                    DLG_COL( (width / num_push_buttons) - C0 - 1 );
#if defined( __NT__ ) && !defined( _UI )
                but_pos = WIN_BUTTON_POS( curr_button + 1,
                                          NORMAL_CHECKMARKS,
                                          width,
                                          WIN_BW );
                control->rect.x = DLG_COL( but_pos );
#else
                control->rect.x = DLG_COL(
                    C0 + (width / num_push_buttons) * curr_button );
#endif
                ++curr_button;
                ++i;
                ++control;
            }
            --i;
            break;

        case GUI_PUSH_BUTTON:
        case GUI_DEFPUSH_BUTTON:
            j = i;
            num_push_buttons = 1;
            while( ++j < curr_dialog->num_controls ) {
                next = &curr_dialog->controls[j];
                if( ( next->control_class != GUI_PUSH_BUTTON &&
                      next->control_class != GUI_DEFPUSH_BUTTON ) ||
                    next->rect.y != control->rect.y ) {
                    break;
                } else {
                    ++num_push_buttons;
                    ++i;
                }
            }
            if( j == curr_dialog->num_controls ) {
                for( curr_button = 1; curr_button <= num_push_buttons; ++curr_button )
                {
#if !defined( _UI )
                    but_pos = WIN_BUTTON_POS( curr_button, num_push_buttons,
                                              width, WIN_BW );
                    control->rect.x     = DLG_COL( but_pos );
                    control->rect.width =
                        DLG_COL( max( strlen( control->text ) + BUTTON_EXTRA,
                                      WIN_BW ) );
#else
                    but_pos = BUTTON_POS( curr_button, num_push_buttons, width, BW );
                    control->rect.x     = DLG_COL( but_pos );
                    control->rect.width = DLG_COL(
                        max( strlen( control->text ) + BUTTON_EXTRA,
                             BW ) );
#endif
                    ++control;
                }
            } else {
#if !defined( _UI )
                but_pos = WIN_BUTTON_POS( NORMAL_BUTTONS,
                                          NORMAL_BUTTONS,
                                          width,
                                          WIN_BW );
                control->rect.x     = DLG_COL( but_pos );
                /* The dynamic system does not handle buttons too wide for dialog. */
                control->rect.width =
                    DLG_COL( max( strlen( control->text ) + BUTTON_EXTRA,
                                  WIN_BW ) );
                /* control->rect.width = DLG_COL( WIN_BW ); */
#else
                but_pos = BUTTON_POS( NORMAL_BUTTONS, MAX_CTRL_PER_LINE, width, BW );
                control->rect.x     = DLG_COL( but_pos );
                control->rect.width =
                    DLG_COL( max( strlen( control->text ) + BUTTON_EXTRA,
                                  BW ) );
#endif
            }
            break;

        case GUI_EDIT:
            if( i > 0 ) {
                prev = &curr_dialog->controls[i - 1];
                if( prev->control_class == GUI_PUSH_BUTTON &&
                    prev->rect.y == control->rect.y ) {
                    // dialog_edit_button  (edit control and push button together)
                    control->rect.width =
                        DLG_COL( prev->rect.x - control->rect.x - BUTTON_EXTRA );
                    break;
                }
            }
            if( control->text != NULL ) {
                control->rect.width =
                    DLG_COL( width - strlen(control->text) - BUTTON_EXTRA );
            } else {
                control->rect.width = DLG_COL( width - C0 - 5 );
            }
            break;

        case GUI_STATIC:
            if( control->id != -1 && curr_dialog->pVisibilityConds[i] == NULL &&
                (i <= 0 || (curr_dialog->controls[i - 1].control_class != GUI_EDIT &&
                curr_dialog->controls[i - 1].control_class != GUI_PUSH_BUTTON) ||
                curr_dialog->controls[i - 1].rect.y != curr_dialog->controls[i].rect.y) ) {
#if !defined( _UI )
                /* Align left edge of control with left of leftmost Button */
                but_pos = WIN_BUTTON_POS( 1, MAX_CTRL_PER_LINE, width, WIN_BW );
                control->rect.x = DLG_COL( but_pos );
#endif
                control->rect.width = DLG_COL( width - 1 );
            } else {
                control->rect.width  = min( control->rect.width, DLG_COL( width ) );
            }
            break;

        default:
            break;
        }
    }
}