static bool OpenStatusWindow( const char *title ) /***********************************************/ { gui_text_metrics metrics; // int i; gui_rect rect; // for( i = STAT_BLANK; i < sizeof( Messages ) / sizeof( Messages[0] ); ++i ) { // Messages[i] = GetVariableStrVal( Messages[i] ); // } GUIGetDlgTextMetrics( &metrics ); CharSize.x = metrics.avg.x; CharSize.y = 5 * metrics.avg.y / 4; GUITruncToPixel( &CharSize ); StatusInfo.parent = MainWnd; StatusInfo.title = GUIStrDup( title, NULL ); StatusInfo.rect.width = STATUS_WIDTH * CharSize.x; StatusInfo.rect.height = STATUS_HEIGHT * CharSize.y; GUIGetClientRect( MainWnd, &rect ); if( GUIIsGUI() ) { StatusInfo.rect.y = BitMapBottom; } else { StatusInfo.rect.y = (GUIScale.y - StatusInfo.rect.height) / 2; } if( StatusInfo.rect.y > rect.height - StatusInfo.rect.height ) { StatusInfo.rect.y = rect.height - StatusInfo.rect.height; } StatusInfo.rect.x = (GUIScale.x - StatusInfo.rect.width) / 2; StatusBarLen = 0; StatusWnd = GUICreateWindow( &StatusInfo ); GUIGetClientRect( StatusWnd, &StatusRect ); Cancel.parent = StatusWnd; Cancel.text = LIT( Cancel ); Cancel.rect.height = 7 * CharSize.y / 4; Cancel.rect.width = (strlen( Cancel.text ) + 4) * CharSize.x; Cancel.rect.x = (StatusRect.width - Cancel.rect.width) / 2; Cancel.rect.y = CANNERY_ROW * CharSize.y; StatusBarRect.x = BAR_INDENT * CharSize.x; StatusBarRect.width = StatusRect.width - 2 * BAR_INDENT * CharSize.x; StatusBarRect.y = STATUS_ROW * CharSize.y; StatusBarRect.height = CharSize.y; #ifndef _UI StatusBarRect.y -= CharSize.y / 2; StatusBarRect.height += CharSize.y; #endif StatusBarLen = StatusBarRect.width / CharSize.x; if( !GUIAddControl( &Cancel, &ToolPlain, &ToolStandout ) ) { SetupError( "IDS_CONTROLERROR" ); return( false ); } return( true ); }
bool GUICreateHot( gui_control_info *ctl_info, VFIELD *field ) { a_hot_spot *hot_spot; bool ok; if( field == NULL ) { return( false ); } hot_spot = (a_hot_spot *)GUIMemAlloc( sizeof( a_hot_spot ) ); field->u.hs = hot_spot; if( hot_spot == NULL ) { return( false ); } field->typ = FLD_HOT; hot_spot->str = GUIStrDup( ctl_info->text, &ok ); if( !ok ) { return( false ); } hot_spot->event = ctl_info->id + GUI_FIRST_USER_EVENT; hot_spot->row = field->area.row; hot_spot->startcol = field->area.col; hot_spot->length = field->area.width; if( ctl_info->control_class == GUI_DEFPUSH_BUTTON ) { hot_spot->flags = HOT_DEFAULT; } else { hot_spot->flags = 0; } return( true ); }
static vhandle DoSetVariable( vhandle var_handle, const char *strval, char *vbl_name ) /************************************************************************************/ { a_variable *tmp_variable; if( strval == NULL ) { strval = ""; } if( var_handle != NO_VAR ) { tmp_variable = &GlobalVarList[var_handle]; if( tmp_variable->has_value ) { if( strcmp( tmp_variable->strval, strval ) == 0 ) { if( tmp_variable->hook ) { tmp_variable->hook( var_handle ); } return( var_handle ); } GUIMemFree( tmp_variable->strval ); // free the old string } } else { var_handle = NewVariable( vbl_name ); } tmp_variable = &GlobalVarList[var_handle]; GUIStrDup( strval, &tmp_variable->strval ); tmp_variable->has_value = TRUE; if( tmp_variable->hook ) { tmp_variable->hook( var_handle ); } return( var_handle ); }
bool GUICreateHot( gui_control_info *info, a_hot_spot_field *hot_spot_field ) { a_hot_spot *hot_spot; if( hot_spot_field == NULL ) { return( false ); } hot_spot = (a_hot_spot *)GUIMemAlloc( sizeof( a_hot_spot ) ); hot_spot_field->ptr = hot_spot; if( hot_spot == NULL ) { return( false ); } hot_spot_field->typ = FLD_HOT; if( !GUIStrDup( info->text, &hot_spot->str ) ) { return( false ); } hot_spot->event = info->id + GUI_FIRST_USER_EVENT; hot_spot->row = hot_spot_field->area.row; hot_spot->startcol = hot_spot_field->area.col; hot_spot->length = hot_spot_field->area.width; if( info->control_class == GUI_DEFPUSH_BUTTON ) { hot_spot->flags = HOT_DEFAULT; } else { hot_spot->flags = (unsigned short)NULL; } return( true ); }
bool GUIXCreateToolBar( gui_window *wnd, bool fixed, gui_ord height, int num_items, gui_toolbar_struct *toolinfo, bool excl, gui_colour_set *plain, gui_colour_set *standout, gui_rect *float_pos ) { int size; int i; int j; toolbarinfo *tbar; float_pos = float_pos; if( ( wnd->parent != NULL ) || ( plain == NULL ) || ( standout == NULL ) ) { return( false ); } tbar = wnd->tbinfo = (toolbarinfo *)GUIMemAlloc( sizeof( toolbarinfo ) ); if( tbar == NULL ) { return( false ); } size = sizeof( gui_toolbar_struct ) * num_items; tbar->info = (gui_toolbar_struct *)GUIMemAlloc( size ); if( tbar->info == NULL ) { GUIMemFree( tbar ); wnd->tbinfo = NULL; return( false ); } memset( tbar->info, 0, size ); tbar->excl = excl; tbar->has_colours = ( plain != NULL ) && ( standout != NULL ); if( tbar->has_colours ) { tbar->plain.fore = plain->fore; tbar->plain.back = plain->back; tbar->standout.fore = standout->fore; tbar->standout.back = standout->back; } for( i = 0; i < num_items; i++ ) { bool ok; tbar->info[i].label = GUIStrDup( toolinfo[i].label, &ok ); if( !ok ) { for( j = 0; j < i; j++ ) { GUIMemFree( (void *)tbar->info[j].label ); } GUIMemFree( tbar->info ); GUIMemFree( tbar ); wnd->tbinfo = NULL; return( false ); } tbar->info[i].id = toolinfo[i].id; } tbar->num_items = num_items; tbar->floattoolbar = NULL; tbar->switching = false; if( fixed ) { return( GUIXCreateFixedToolbar( wnd ) ); } else { return( CreateFloatingToolbar( wnd, height ) ); } }
char *GUIGetListBoxText( a_list *list, gui_ctl_idx choice, bool get_curr ) { lb_data data; data = (lb_data)list->data_handle; if( get_curr ) { choice = list->choice; } return( GUIStrDup( data[choice], NULL ) ); }
extern a_dialog_header *AddNewDialog( const char *dlg_name ) /**********************************************************/ // Add new dialogs to front of linked list. // Delete default dialogs if specified. { a_dialog_header *tmp_dialog; a_dialog_header *new_dialog; new_dialog = (a_dialog_header *)GUIMemAlloc( sizeof( a_dialog_header ) ); memset( new_dialog, '\0', sizeof( *new_dialog ) ); new_dialog->name = GUIStrDup( dlg_name, NULL ); new_dialog->adjusted = false; new_dialog->def_dlg = false; new_dialog->defaults_set = false; new_dialog->ret_val = DLG_NEXT; new_dialog->any_check = NO_VAR; new_dialog->pVariables[0] = NO_VAR; new_dialog->pConditions[0] = NULL; /* check if old dialog existed */ tmp_dialog = FindDialogByName( dlg_name ); if( tmp_dialog != NULL ) { new_dialog->next = tmp_dialog->next; new_dialog->prev = tmp_dialog->prev; if( new_dialog->next != NULL ) { new_dialog->next->prev = new_dialog; } if( new_dialog->prev != NULL ) { new_dialog->prev->next = new_dialog; } if( FirstDialog == NULL ) { FirstDialog = new_dialog; LastDialog = new_dialog; } if( FirstDialog == tmp_dialog ) { FirstDialog = new_dialog; } if( LastDialog == tmp_dialog ) { LastDialog = new_dialog; } FreeDialog( tmp_dialog ); // replace old default dialog } else { new_dialog->prev = LastDialog; new_dialog->next = NULL; if( FirstDialog == NULL ) { FirstDialog = new_dialog; LastDialog = new_dialog; } else { LastDialog->next = new_dialog; } LastDialog = new_dialog; } return( new_dialog ); }
char *GUIGetListBoxText( a_list *list, int choice, bool get_curr ) { char *text; char **data; data = (char **)list->data; if( get_curr ) { choice = list->choice; } GUIStrDup( data[choice], &text ); return( text ); }
static char *GetFontInfo( LOGFONT *lf ) { char buff[MAX_STR]; char *str; GetFontFormatString( lf, buff ); if( GUIStrDup( buff, &str ) ) { return( str ); } else { return( NULL ); } }
static char *ResNameOrOrdinalToStr( ResNameOrOrdinal *name, int base ) { char temp[15]; char *cp; bool ok; cp = NULL; if( name != NULL ) { if( name->ord.fFlag == 0xff) { utoa( name->ord.wOrdinalID, temp, base ); ok = GUIStrDup( temp, &cp ); } else { ok = GUIStrDup( name->name, &cp ); } if( !ok || ( cp == NULL ) ) { return( NULL ); } } return( cp ); }
bool GUISetHotSpotText( a_hot_spot *hot_spot, const char *text ) { char *new_str; bool ok; if( text == NULL ) text = ""; new_str = GUIStrDup( text, &ok ); if( ok ) { GUIMemFree( hot_spot->str ); hot_spot->str = new_str; } return( ok ); }
static char *GUIGetInternalLiteralString( int id ) { char *str; str = NULL; GUIStrTextBuffer[0] = '\0'; if( GUIIsLoadStrInitialized() ) { if( !GUILoadString( id, GUIStrTextBuffer, BUFFER_SIZE ) ) { GUIStrTextBuffer[0] = '\0'; } } GUIStrDup( GUIStrTextBuffer, &str ); return( str ); }
static vhandle NewVariable( char *vbl_name ) /******************************************/ { a_variable *tmp_variable; vhandle var_handle; var_handle = GlobalVarArray.num; BumpArray( &GlobalVarArray ); tmp_variable = &GlobalVarList[var_handle]; GUIStrDup( vbl_name, &tmp_variable->name ); tmp_variable->id = var_handle; tmp_variable->has_value = FALSE; tmp_variable->autoset = NULL; tmp_variable->restriction = 0; tmp_variable->hook = NULL; tmp_variable->strval = NULL; if( GlobalVarHash ) { HashInsert( GlobalVarHash, vbl_name, var_handle ); } return( var_handle ); }
a_list *GUICreateEditMLE( char * text ) { a_list *list; char *text_copy; char *line; char *end; char *absolute_end; #define MLE_NEWLINE "\r\n" list = (a_list * )GUIMemAlloc( sizeof( a_list ) ); if( list == NULL ) { return( NULL ); } if( !GUIFillInListBox( list ) ) { GUIMemFree( list ); list = NULL; } else { GUIStrDup( text, &text_copy ); line = text_copy; absolute_end = text_copy + strlen( text_copy ); end = strstr( line, MLE_NEWLINE ); if( end != NULL ) { *end = '\0'; } while( line != absolute_end && end != NULL ) { GUIListBoxAddText( list, line, -1 ); line = end + 2; end = strstr( line, MLE_NEWLINE ); if( end != NULL ) { *end = '\0'; } } GUIListBoxAddText( list, line, -1 ); GUIMemFree( text_copy ); } return( list ); }
bool GUIXCreateDialog( gui_create_info *dlg_info, gui_window *wnd, int num_controls, gui_control_info *controls_info, bool sys, long dlg_id ) { EVENT ev; int i; a_dialog *ui_dlg_info; VFIELD *fields; char *title; VFIELD *focus; int size; bool colours_set; bool ok; if( dlg_id != -1 ) { if( !GUICreateDialogFromRes( dlg_id, dlg_info->parent, dlg_info->call_back, dlg_info->extra ) ) { return( false ); } GUIMemFree( wnd ); return( true ); } sys = sys; RadioGroup = NULL; Group = false; fields = NULL; title = NULL; ui_dlg_info = NULL; colours_set = false; wnd->flags |= DIALOG; if( !GUISetupStruct( wnd, dlg_info, true ) ) { return( false ); } size = ( num_controls + 1 ) * sizeof( VFIELD ); fields = (VFIELD *)GUIMemAlloc( size ); if( fields == NULL ) { return( false ); } memset( fields, 0, size ); focus = NULL; for( i = 0; i < num_controls; i++ ) { uiyield(); if( !GUIDoAddControl( &controls_info[i], wnd, &fields[i] ) ) { GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true ); return( false ); } else { if( ( focus == NULL ) && ( controls_info[i].style & GUI_FOCUS ) ) { focus = &fields[i]; } } } CleanUpRadioGroups(); fields[num_controls].typ = FLD_VOID; /* mark end of list */ title = GUIStrDup( dlg_info->title, &ok ); if( !ok ) { GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true ); return( false ); } colours_set = GUISetDialColours(); ui_dlg_info = uibegdialog( title, fields, wnd->screen.area.height, wnd->screen.area.width, wnd->screen.area.row, wnd->screen.area.col ); if( ui_dlg_info == NULL ) { GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true ); return( false ); } if( focus != NULL ) { uidialogsetcurr( ui_dlg_info, focus ); } if( !InsertDialog( wnd, ui_dlg_info, num_controls, title, colours_set ) ) { GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true ); return( false ); } for( i = 0; i < num_controls; i++ ) { uiyield(); GUIInsertControl( wnd, &controls_info[i], i ); } GUIEVENTWND( wnd, GUI_INIT_DIALOG, NULL ); uipushlist( NULL ); uipushlist( GUIUserEvents ); GUIPushControlEvents(); uipushlist( DlgEvents ); while( ( GetDialog( ui_dlg_info ) != NULL ) ) { ev = uidialog( ui_dlg_info ); switch( ev ) { case EV_KILL_UI: uiforceevadd( EV_KILL_UI ); case EV_ESCAPE: GUIEVENTWND( wnd, GUI_DIALOG_ESCAPE, NULL ); GUICloseDialog( wnd ); break; default : GUIProcessControlNotify( ev, ui_dlg_info, wnd ); } } return( true ); }
bool GUIDoAddControl( gui_control_info *ctl_info, gui_window *wnd, VFIELD *field ) { a_radio *radio; a_check *check; a_combo_box *combo_box; an_edit_control *edit_control; bool group_allocated; SAREA area; bool ok; group_allocated = false; if( (ctl_info->style & GUI_GROUP) && (ctl_info->control_class == GUI_RADIO_BUTTON) ) { if( !Group ) { RadioGroup = (a_radio_group *)GUIMemAlloc( sizeof( a_radio_group ) ); if( RadioGroup == NULL ) { return( false ); } RadioGroup->value = -1; RadioGroup->caption = GUIStrDup( ctl_info->text, &ok ); if( !ok ) { CleanUpRadioGroups(); return( false ); } Group = true; group_allocated = true; } } GUIGetSAREA( wnd, &area ); if( !GUISetDialogArea( wnd, &field->area, &ctl_info->rect, &area ) ) { return( false ); } field->typ = ui_types[ctl_info->control_class]; if( field->typ == FLD_EDIT && ( ctl_info->style & GUI_EDIT_INVISIBLE ) ) { field->typ = FLD_INVISIBLE_EDIT; } switch( field->typ ) { case FLD_HOT : if( !GUICreateHot( ctl_info, field ) ) { return( false ); } break; case FLD_RADIO : radio = (a_radio *)GUIMemAlloc( sizeof( a_radio ) ); field->u.radio = radio; ok = false; if( radio != NULL ) { radio->str = GUIStrDup( ctl_info->text, &ok ); } if( !ok ) { if( group_allocated ) { CleanUpRadioGroups(); } return( false ); } radio->value = GUI_FIRST_USER_EVENT + ctl_info->id; radio->group = RadioGroup; if( ( ctl_info->style & GUI_CHECKED ) && ( ctl_info->style & GUI_AUTOMATIC ) ) { RadioGroup->def = radio->value; RadioGroup->value = radio->value; } break; case FLD_CHECK : check = (a_check *)GUIMemAlloc( sizeof( a_check ) ); field->u.check = check; ok = false; if( check != NULL ) check->str = GUIStrDup( ctl_info->text, &ok ); if( !ok ) { return( false ); } check->val = 0; if( ( ctl_info->style & GUI_CHECKED ) && ( ctl_info->style & GUI_AUTOMATIC ) ) { check->def = true; } else { check->def = false; } break; case FLD_COMBOBOX : combo_box = (a_combo_box *)GUIMemAlloc( sizeof( a_combo_box ) ); if( combo_box == NULL ) { return( false ); } field->u.combo = combo_box; combo_box->edit.buffer = NULL; combo_box->edit.length = 0; if( !GUIFillInListBox( &combo_box->list ) ) { return( false ); } if( ctl_info->text != NULL ) { if( !GUISetEditText( &combo_box->edit, ctl_info->text, false ) ) { return( false ); } } combo_box->perm = false; break; case FLD_EDIT : case FLD_INVISIBLE_EDIT : edit_control = (an_edit_control *)GUIMemAlloc( sizeof( an_edit_control ) ); if( edit_control == NULL ) { return( false ); } field->u.edit = edit_control; edit_control->buffer = NULL; GUISetEditText( edit_control, ctl_info->text, field->typ != FLD_EDIT ); break; case FLD_PULLDOWN : case FLD_LISTBOX : field->u.list = (a_list *)GUICreateListBox(); if( field->u.list == NULL ) { return( false ); } break; case FLD_EDIT_MLE: field->u.list = (a_list *)GUICreateEditMLE( ctl_info->text ); if( field->u.list == NULL ) { return( false ); } break; case FLD_TEXT : case FLD_FRAME : field->u.str = GUIStrDup( ctl_info->text, &ok ); if( !ok ) { return( false ); } break; default : return( false ); break; } if( (ctl_info->style & GUI_GROUP) && (ctl_info->control_class == GUI_RADIO_BUTTON) ) { if( Group && !group_allocated ) { RadioGroup = NULL; Group = false; } } return( true ); }
void VarSetAutoSetCond( vhandle var_handle, char *cond ) /******************************************************/ { GUIStrDup( cond, &GlobalVarList[var_handle].autoset ); }