void GUIDrawIcon( gui_window * wnd ) { SAREA area; int length; ATTR attr; char *str; COPYAREA( wnd->screen.area, area ); area.row = 0; area.col = 0; attr = wnd->colours[GUI_ICON]; uivfill( &wnd->screen, area, attr, ' ' ); uidrawbox( &wnd->screen, &area, attr, NULL ); str = NULL; if( wnd->icon_name != NULL ) { str = wnd->icon_name; } else { if( wnd->screen.name != NULL ) { str = wnd->screen.name; } } if( str != NULL ) { length = strlen( str ); if( length > ( area.width - 2 ) ) { length = area.width - 2; } uivtextput( &wnd->screen, ( area.height / 2 ), 1, attr, str, length ); } }
void GUICheckResizeAreaForChildren( gui_window *wnd, SAREA *area, resize_dir dir ) { gui_window *child_wnd; SAREA *child; SAREA use; SAREA old_use; if( ( wnd->flags & CHECK_CHILDREN_ON_RESIZE ) == 0 ) { return; } GUISetUseArea( wnd, area, &use ); use.row += wnd->screen.area.row; use.col += wnd->screen.area.col; COPYAREA( use, old_use ); for( child_wnd = wnd->child; child_wnd != NULL; child_wnd = child_wnd->sibling ) { child = &child_wnd->screen.area; CheckChildResize( child, &use, dir ); } if( use.row != old_use.row ) { area->row += ( use.row - old_use.row ); } if( use.col != old_use.col ) { area->col += ( use.col - old_use.col ); } if( use.width != old_use.width ) { area->width += ( use.width - old_use.width ); } if( use.height != old_use.height ) { area->height += ( use.height - old_use.height ); } }
static void RedrawResize( gui_window *wnd, SAREA *old ) { if( ( ( wnd->use.width > old->width ) && ( wnd->use.height > old->height ) ) || GUI_WND_MINIMIZED( wnd ) ) { GUIWholeWndDirty( wnd ); } else { if( wnd->flags & NEEDS_RESIZE_REDRAW ) { if( wnd->use.width > old->width ) { COPYAREA( wnd->use, wnd->dirty ); wnd->dirty.col += old->width; wnd->dirty.width = wnd->use.width - old->width; } if( wnd->use.height > old->height ) { COPYAREA( wnd->use, wnd->dirty ); wnd->dirty.row += old->height; wnd->dirty.height = wnd->use.height - old->height; } } if( !EMPTY_AREA( wnd->dirty ) ) { wnd->flags |= CONTENTS_INVALID; } GUIWndUpdate( wnd ); } }
bool GUIGetDlgRect( gui_window *wnd, SAREA *area ) { a_dialog *ui_dlg_info; if( GUI_IS_DIALOG( wnd ) ) { ui_dlg_info = GUIGetDialog( wnd ); if( ui_dlg_info != NULL ) { uigetdialogarea( ui_dlg_info, area ); } else { COPYAREA( wnd->screen.area, *area ); } GUIAdjustDialogArea( area, +1 ); return( true ); } return( false ); }
void GUICheckResizeAreaForParent( gui_window *wnd, SAREA *area, resize_dir dir ) { SAREA parent; int diff; if( wnd->parent != NULL ) { COPYAREA( wnd->parent->use, parent ); parent.row += wnd->parent->screen.area.row; parent.col += wnd->parent->screen.area.col; if( dir & RESIZE_RIGHT ) { if( ( area->col + area->width ) > ( parent.col + parent.width ) ) { area->width = parent.col + parent.width - area->col; } } else { if( dir & RESIZE_LEFT ) { diff = 0; if( area->col < parent.col ) { diff = parent.col - area->col; } area->col += diff; area->width -= diff; } } if( dir & RESIZE_DOWN ) { if( ( area->row + area->height ) > ( parent.row + parent.height ) ) { area->height = parent.row + parent.height - area->row; } } else { if( dir & RESIZE_UP ) { diff = 0; if( area->row < parent.row ) { diff = parent.row - area->row; } area->row += diff; area->height -= diff; } } } }
EVENT GUICreateMenuPopup( gui_window *wnd, gui_point *location, MENUITEM *menu, gui_mouse_track track, gui_ctl_id *curr_id ) { EVENT ev; gui_ctl_id id; ATTR attr_active; ATTR attr_hot; ATTR attr_curr_active; ATTR attr_hot_curr; ATTR attr_inactive; ATTR attr_curr_inactive; ATTR attr_menu; gui_window *top; SAREA area; DESCMENU desc; MenuWnd = wnd; if( MenuState == MENU_NONE ) { MenuState = MENU_SYS; } if( menu == NULL ) { return( EV_NO_EVENT ); } attr_active = UIData->attrs[ATTR_ACTIVE]; attr_hot = UIData->attrs[ATTR_HOT]; attr_curr_active = UIData->attrs[ATTR_CURR_ACTIVE]; attr_hot_curr = UIData->attrs[ATTR_HOT_CURR]; attr_inactive = UIData->attrs[ATTR_INACTIVE]; attr_curr_inactive = UIData->attrs[ATTR_CURR_INACTIVE]; attr_menu = UIData->attrs[ATTR_MENU]; UIData->attrs[ATTR_ACTIVE] = wnd->colours[GUI_MENU_PLAIN]; UIData->attrs[ATTR_HOT] = wnd->colours[GUI_MENU_STANDOUT]; UIData->attrs[ATTR_CURR_ACTIVE] = wnd->colours[GUI_MENU_ACTIVE]; UIData->attrs[ATTR_HOT_CURR] = wnd->colours[GUI_MENU_ACTIVE_STANDOUT]; UIData->attrs[ATTR_INACTIVE] = wnd->colours[GUI_MENU_GRAYED]; UIData->attrs[ATTR_CURR_INACTIVE] = wnd->colours[GUI_MENU_GRAYED_ACTIVE]; UIData->attrs[ATTR_MENU] = wnd->colours[GUI_MENU_FRAME]; ev = 0; if( ( curr_id != NULL ) && ( *curr_id != 0 ) ) { ev = ID2EV( *curr_id ); } top = GUIGetTopWnd( wnd ); COPYAREA( top->use, area ); area.row += top->screen.area.row; area.col += top->screen.area.col; if( !uiposfloatingpopup( menu, &desc, wnd->screen.area.row + location->y, wnd->screen.area.col + location->x, &area, NULL ) ) { return( EV_NO_EVENT ); } ev = uicreatepopupinarea( menu, &desc, track & GUI_TRACK_LEFT, track & GUI_TRACK_RIGHT, ev, &area, false ); if( ev == EV_KILL_UI ) { uiforceevadd( EV_KILL_UI ); ev = EV_NO_EVENT; } GUIProcessMenuCurr( NULL ); UIData->attrs[ATTR_ACTIVE] = attr_active; UIData->attrs[ATTR_HOT] = attr_hot; UIData->attrs[ATTR_CURR_ACTIVE] = attr_curr_active; UIData->attrs[ATTR_HOT_CURR] = attr_hot_curr; UIData->attrs[ATTR_INACTIVE] = attr_inactive; UIData->attrs[ATTR_CURR_INACTIVE] = attr_curr_inactive; UIData->attrs[ATTR_MENU] = attr_menu; if( ( ev != EV_MOUSE_DCLICK ) && ( ev != EV_NO_EVENT ) ) { if( IS_CTLEVENT( ev ) ) { id = EV2ID( ev ); GUIEVENTWND( wnd, GUI_CLICKED, &id ); if( curr_id != NULL ) { *curr_id = id; } } else { GUIProcessSysMenuEvent( ev, wnd ); } } if( MenuState == MENU_SYS ) { MenuState = MENU_NONE; } MenuWnd = NULL; return( ev ); }