void WFreeMenuEInfo( WMenuEditInfo *einfo ) { if( einfo != NULL ) { if( einfo->menu != NULL ) { WFreeMenu( einfo->menu ); einfo->menu = NULL; } if( einfo->wsb != NULL ) { WDestroyStatusLine( einfo->wsb ); einfo->wsb = NULL; } if( einfo->ribbon != NULL ) { WDestroyRibbon( einfo ); } if( einfo->preview_window != (HWND)NULL && IsWindow( einfo->preview_window ) ) { DestroyWindow( einfo->preview_window ); einfo->preview_window = (HWND)NULL; } if( einfo->edit_dlg != (HWND)NULL && IsWindow( einfo->edit_dlg ) ) { DestroyWindow( einfo->edit_dlg ); einfo->edit_dlg = (HWND)NULL; } if( einfo->win != (HWND)NULL && IsWindow( einfo->win ) ) { SetWindowLong( einfo->win, 0, (LONG)0 ); DestroyWindow( einfo->win ); einfo->win = (HWND)NULL; } if( einfo->file_name != NULL ) { WMemFree( einfo->file_name ); } WMemFree( einfo ); } }
void WFreeAccelEInfo( WAccelEditInfo *einfo ) { if( einfo != NULL ) { if( einfo->tbl != NULL ) { WFreeAccelTable( einfo->tbl ); einfo->tbl = NULL; } if( einfo->wsb != NULL ) { WDestroyStatusLine( einfo->wsb ); einfo->wsb = NULL; } if( einfo->ribbon != NULL ) { WDestroyRibbon( einfo ); } if( einfo->edit_dlg != (HWND)NULL && IsWindow( einfo->edit_dlg ) ) { DestroyWindow( einfo->edit_dlg ); einfo->edit_dlg = (HWND)NULL; } if( einfo->win != (HWND)NULL && IsWindow( einfo->win ) ) { SetWindowLong( einfo->win, 0, (LONG)0 ); DestroyWindow( einfo->win ); einfo->win = (HWND)NULL; } if( einfo->file_name != NULL ) { WMemFree( einfo->file_name ); } WMemFree( einfo ); } }
Bool WFreeAccelTableEntry( WAccelTable *tbl, WAccelEntry *entry ) { Bool ok; ok = (tbl != NULL && entry != NULL); if( ok ) { if( entry->next != NULL ) { entry->next->prev = entry->prev; } if( entry->prev != NULL ) { entry->prev->next = entry->next; } if( tbl->first_entry == entry ) { tbl->first_entry = entry->next; } if( entry->symbol != NULL ) { WMemFree( entry->symbol ); } WMemFree( entry ); tbl->num--; } return( ok ); }
static Bool WWriteStringEntry( WStringBlock *block, uint_16 string_id, FILE *fp ) { char *strtext; char *text; Bool ok; strtext = NULL; text = WResIDNameToStr( block->block.String[string_id & 0xf] ); ok = (text != NULL); if( ok ) { strtext = WConvertStringFrom( text, "\t\n\"\\", "tn\"\\" ); ok = (strtext != NULL); } if( ok ) { if( block->symbol[string_id & 0xf] ) { fprintf( fp, " %s, \"%s\"\n", block->symbol[string_id & 0xf], strtext ); } else { fprintf( fp, " %u, \"%s\"\n", string_id, strtext ); } } if( strtext != NULL ) { WMemFree( strtext ); } if( text != NULL ) { WMemFree( text ); } return( ok ); }
void WFreeAccelTableEntries( WAccelEntry *entry ) { WAccelEntry *e; while( entry != NULL ) { e = entry; entry = entry->next; if( e->symbol != NULL ) { WMemFree( e->symbol ); } WMemFree( e ); } }
void WINEXPORT WMenuFreeMenuInfo( WMenuInfo *info ) { if( info != NULL ) { if( info->res_name != NULL ) { WMemFree( info->res_name ); } if( info->file_name != NULL ) { WMemFree( info->file_name ); } if( info->data != NULL ) { WMemFree( info->data ); } WMemFree( info ); } }
Bool WResolveEntrySymbol( WAccelEntry *entry, WRHashTable *symbol_table ) { uint_16 id; WRHashValueList *vlist; Bool ok; vlist = NULL; ok = (entry != NULL && symbol_table != NULL); if( ok ) { if( entry->is32bit ) { id = entry->entry32.Id; } else { id = (uint_16)entry->entry.Id; } vlist = WRLookupValue( symbol_table, id ); ok = (vlist != NULL && vlist->next == NULL); } if( ok ) { if( entry->symbol != NULL ) { WMemFree( entry->symbol ); } entry->symbol = WStrDup( vlist->entry->name ); ok = (entry->symbol != NULL); } if( vlist != NULL ) { WRValueListFree( vlist ); } return( ok ); }
void WFreeAccelTable( WAccelTable *tbl ) { if( tbl != NULL ) { WFreeAccelTableEntries( tbl->first_entry ); WMemFree( tbl ); } }
static void handleLoadSymbols( WAccelEditInfo *einfo ) { char *file; file = WLoadSymbols( &einfo->info->symbol_table, einfo->info->symbol_file, einfo->win, TRUE ); if( file == NULL ) { return; } if( einfo->info->symbol_file != NULL ) { WMemFree( einfo->info->symbol_file ); } einfo->info->symbol_file = file; // lookup the id associated with the symbol for all entries WResolveAllEntrySymIDs( einfo ); // look for the symbol matching the id for all entries WResolveAllEntrySymbols( einfo ); WInitEditWindowListBox( einfo ); if( einfo->current_pos != -1 ) { SendDlgItemMessage( einfo->edit_dlg, IDM_ACCEDLIST, LB_SETCURSEL, einfo->current_pos, 0 ); } WRAddSymbolsToComboBox( einfo->info->symbol_table, einfo->edit_dlg, IDM_ACCEDCMDID, WR_HASHENTRY_ALL ); einfo->info->modified = TRUE; WDoHandleSelChange( einfo, FALSE, TRUE ); }
WAccelInfo *WAccelGetEInfo( WAccelHandle hndl, Bool keep ) { WAccelEditInfo *einfo; WAccelInfo *info; int ok; info = NULL; einfo = (WAccelEditInfo *)WGetEditSessionInfo( hndl ); ok = (einfo != NULL); if( ok ) { info = einfo->info; ok = (info != NULL); } if( ok ) { if( einfo->info->modified ) { if( info->data != NULL ) { WMemFree( info->data ); } info->data = NULL; info->data_size = 0; WMakeDataFromAccelTable( einfo->tbl, &info->data, &info->data_size ); } if( !keep ) { WUnRegisterEditSession( hndl ); WFreeAccelEInfo( einfo ); } } return( info ); }
void WDestroyStatusLine( WStatBar *wsb ) { if( wsb != NULL ) { StatusWndDestroy( wsb->stat ); WMemFree( wsb ); } }
static void handleLoadSymbols( WMenuEditInfo *einfo ) { char *file; file = WLoadSymbols( &einfo->info->symbol_table, einfo->info->symbol_file, einfo->win, TRUE ); if( file == NULL ) { return; } if( einfo->info->symbol_file != NULL ) { WMemFree( einfo->info->symbol_file ); } einfo->info->symbol_file = file; // lookup the id associated with the symbol for all entries WResolveMenuSymIDs( einfo ); // look for the symbol matching the id for all entries WResolveMenuEntries( einfo ); WRAddSymbolsToComboBox( einfo->info->symbol_table, einfo->edit_dlg, IDM_MENUEDID, WR_HASHENTRY_ALL ); einfo->info->modified = TRUE; WDoHandleSelChange( einfo, FALSE, TRUE ); }
Bool WSetEditWindowText( HWND dlg, MenuFlags flags, char *text ) { Bool ok; char *t; char *n; ok = (dlg != (HWND)NULL); if( ok ) { if( flags & MENU_SEPARATOR ) { t = ""; } else { t = text; if( t == NULL ) { t = ""; } } } if( ok ) { n = WConvertStringFrom( t, "\t\x8", "ta" ); if( n != NULL ) { ok = WSetEditWithStr( GetDlgItem( dlg, IDM_MENUEDTEXT ), n ); WMemFree( n ); } else { ok = WSetEditWithStr( GetDlgItem( dlg, IDM_MENUEDTEXT ), t ); } } return( ok ); }
void WHandleClear( WMenuEditInfo *einfo ) { if( einfo->menu != NULL && einfo->menu->first_entry != NULL ) { if( WQueryClearRes( einfo ) ) { WSetEditWindowText( einfo->edit_dlg, 0, NULL ); WSetEditWindowID( einfo->edit_dlg, 0, TRUE, NULL ); WResetEditWindowFlags( einfo->edit_dlg ); SendDlgItemMessage( einfo->edit_dlg, IDM_MENUEDLIST, LB_RESETCONTENT, 0, 0 ); WFreeMenuEntries( einfo->menu->first_entry ); einfo->menu->first_entry = NULL; einfo->current_entry = NULL; einfo->current_pos = -1; einfo->first_preview_id = FIRST_PREVIEW_ID; WResetPrevWindowMenu( einfo ); if( einfo->info->stand_alone ) { if( einfo->file_name != NULL ) { WMemFree( einfo->file_name ); einfo->file_name = NULL; WSetEditTitle( einfo ); } if( einfo->info->symbol_table != NULL ) { WRFreeHashTable( einfo->info->symbol_table ); einfo->info->symbol_table = WRInitHashTable(); } } einfo->info->modified = TRUE; SetFocus( einfo->edit_dlg ); WSetStatusByID( einfo->wsb, W_MENUCLEARMSG, -1 ); } } }
static Bool WQueryNukePopup( WMenuEditInfo *einfo ) { int ret; UINT style; char *title; char *text; style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; title = WCreateEditTitle( einfo ); text = WAllocRCString( W_QUERYNUKEPOPUP ); ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { WFreeRCString( text ); } if( title != NULL ) { WMemFree( title ); } if( ret == IDYES ) { return( TRUE ); } return( FALSE ); }
void WHandleClear( WAccelEditInfo *einfo ) { if( einfo->tbl != NULL && einfo->tbl->num != 0 ) { if( WQueryClearRes( einfo ) ) { WResetEditWindow( einfo ); SendDlgItemMessage( einfo->edit_dlg, IDM_ACCEDLIST, LB_RESETCONTENT, 0, 0 ); WFreeAccelTableEntries( einfo->tbl->first_entry ); einfo->tbl->first_entry = NULL; einfo->tbl->num = 0; einfo->current_entry = NULL; einfo->current_pos = -1; einfo->getting_key = FALSE; if( einfo->info->stand_alone ) { if( einfo->file_name != NULL ) { WMemFree( einfo->file_name ); einfo->file_name = NULL; WSetEditTitle( einfo ); } if( einfo->info->symbol_table != NULL ) { WRFreeHashTable( einfo->info->symbol_table ); einfo->info->symbol_table = WRInitHashTable(); } } einfo->info->modified = TRUE; SetFocus( einfo->edit_dlg ); WSetStatusByID( einfo->wsb, W_ACCELCLEARMSG, -1 ); } } }
WMenuInfo *WMenuGetEInfo( WMenuHandle hndl, Bool keep ) { WMenuEditInfo *einfo; WMenuInfo *info; int ok; info = NULL; einfo = (WMenuEditInfo *)WGetEditSessionInfo( hndl ); ok = (einfo != NULL); if( ok ) { info = einfo->info; ok = (info != NULL); } if( ok ) { if( einfo->info->modified ) { if( info->data != NULL ) { WMemFree( info->data ); info->data = NULL; } info->data_size = 0; WMakeDataFromMenu( einfo->menu, &info->data, &info->data_size ); } if( !keep ) { WUnRegisterEditSession( hndl ); WFreeMenuEInfo( einfo ); } } return( info ); }
Bool WPasteMenuItem( WMenuEditInfo *einfo ) { WMenuEntry *entry; void *data; uint_32 dsize; Bool ok; data = NULL; ok = (einfo != NULL); if( ok ) { ok = WGetClipData( einfo->win, WItemClipbdFormat, &data, &dsize ); } if( ok ) { entry = WMakeMenuEntryFromClipData( data, dsize ); ok = (entry != NULL); } if( ok ) { ok = WResolveEntries( entry, einfo->info->symbol_table ); } if( ok ) { ok = WInsertMenuEntry( einfo, entry, TRUE ); } if( data != NULL ) { WMemFree( data ); } return( ok ); }
static Bool WQueryChangeEntry( WMenuEditInfo *einfo ) { int ret; UINT style; char *title; char *text; style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; title = WCreateEditTitle( einfo ); text = WAllocRCString( W_CHANGEMODIFIEDMENUITEM ); ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { WFreeRCString( text ); } if( title != NULL ) { WMemFree( title ); } if( ret == IDYES ) { return( TRUE ); } return( FALSE ); }
Bool WWriteAccToRC( WAccelEditInfo *einfo, char *file, Bool append ) { WAccelEntry *entry; FILE *fp; char *rname; Bool ok; rname = NULL; ok = (einfo != NULL && einfo->tbl != NULL && einfo->info->res_name != NULL && file != NULL); if( ok ) { if( append ) { fp = fopen( file, "at" ); } else { fp = fopen( file, "wt" ); } ok = (fp != NULL); } if( ok ) { ok = ((rname = WResIDToStr( einfo->info->res_name )) != NULL); } if( ok ) { fprintf( fp, "%s ACCELERATORS\n", rname ); fwrite( "BEGIN\n", sizeof( char ), 6, fp ); } if( ok ) { entry = einfo->tbl->first_entry; while( entry != NULL && ok ) { ok = WWriteEntryToRC( einfo, entry, fp ); entry = entry->next; } } if( ok ) { fwrite( "END\n\n", sizeof( char ), 5, fp ); } if( rname ) { WMemFree( rname ); } if( fp ) { fclose( fp ); } return( ok ); }
Bool WGetEditWindowText( HWND dlg, char **text ) { Bool ok; char *n; ok = (dlg != (HWND)NULL && text != NULL); if( ok ) { n = WGetStrFromEdit( GetDlgItem( dlg, IDM_MENUEDTEXT ), NULL ); if( n != NULL && *n == '\0' ) { WMemFree( n ); n = NULL; } *text = WConvertStringTo( n, "\t\x8", "ta" ); if( n != NULL ) { WMemFree( n ); } ok = (*text != NULL); } return( ok ); }
static Bool WWriteEntryToRC( WAccelEditInfo *einfo, WAccelEntry *entry, FILE *fp ) { char *keytext; char *flagtext; uint_16 key, flags, id; Bool ok; flagtext = NULL; ok = (einfo != NULL && entry != NULL); if( ok ) { if( entry->is32bit ) { key = entry->entry32.Ascii; flags = entry->entry32.Flags; id = entry->entry32.Id; } else { key = entry->entry.Ascii; flags = entry->entry.Flags; id = (uint_16)entry->entry.Id; } keytext = WGetKeyText( key, flags ); ok = (keytext != NULL); } if( ok ) { ok = WSetFlagsText( flags, &flagtext ); } if( ok ) { fprintf( fp, " %s,\t", keytext ); if( entry->symbol ) { fprintf( fp, "%s", entry->symbol ); } else { fprintf( fp, "%d", (int)id ); } if( flagtext != NULL ) { fprintf( fp, "%s\n", flagtext ); } else { fwrite( "\n", sizeof( char ), 1, fp ); } } if( flagtext != NULL ) { WMemFree( flagtext ); } return( ok ); }
Bool WQuerySaveSym( WMenuEditInfo *einfo, Bool force_exit ) { int ret; UINT style; char *title; char *text; if( einfo == NULL || !einfo->info->stand_alone ) { return( TRUE ); } if( !WRIsHashTableDirty( einfo->info->symbol_table ) ) { return( TRUE ); } if( force_exit ) { style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; } else { style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION; } title = WCreateEditTitle( einfo ); text = WAllocRCString( W_UPDATEMODIFIEDSYM ); ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { WFreeRCString( text ); } if( title != NULL ) { WMemFree( title ); } if( ret == IDYES ) { if( einfo->info->symbol_file == NULL ) { char *fname; if( einfo->file_name == NULL ) { fname = einfo->info->file_name; } else { fname = einfo->file_name; } einfo->info->symbol_file = WCreateSymName( fname ); } return( WSaveSymbols( einfo, einfo->info->symbol_table, &einfo->info->symbol_file, FALSE ) ); } else if( ret == IDCANCEL ) { return( FALSE ); } return( TRUE ); }
Bool WClipMenuItem( WMenuEditInfo *einfo, Bool cut ) { HWND lbox; LRESULT index; void *data; uint_32 dsize; WMenuEntry *entry; Bool ok; data = NULL; ok = (einfo != NULL); if( ok ) { lbox = GetDlgItem( einfo->edit_dlg, IDM_MENUEDLIST ); ok = (lbox != (HWND)NULL); } if( ok ) { index = SendMessage( lbox, LB_GETCURSEL, 0, 0 ); ok = (index != LB_ERR); } if( ok ) { entry = (WMenuEntry *)SendMessage( lbox, LB_GETITEMDATA, (WPARAM)index, 0 ); ok = (entry != NULL); } if( ok ) { ok = WMakeClipDataFromMenuEntry( entry, &data, &dsize ); } if( ok ) { ok = WCopyClipData( einfo->win, WItemClipbdFormat, data, dsize ); } if( ok ) { if( cut ) { ok = WDeleteMenuEntry( einfo ); } } if( data != NULL ) { WMemFree( data ); } return( ok ); }
Bool WWriteMenuToRC( WMenuEditInfo *einfo, char *file, Bool append ) { FILE *fp; char *rname; Bool ok; rname = NULL; ok = ( einfo && einfo->menu ); if( ok ) { if( append ) { fp = fopen( file, "at" ); } else { fp = fopen( file, "wt" ); } ok = ( fp != NULL ); } if( ok ) { ok = ( ( rname = WResIDToStr( einfo->info->res_name ) ) != NULL ); } if( ok ) { fprintf( fp, "%s MENU\n", rname ); } if( ok ) { ok = WWriteMenuPopupItem( einfo->menu->first_entry, fp ); } if( rname ) { WMemFree( rname ); } if( fp ) { fclose( fp ); } return( ok ); }
WStringBlock *WInsertStringData( WStringEditInfo *einfo, uint_16 id, char *text, char *symbol, Bool *replace ) { Bool ok; WStringBlock *block; ok = (einfo != NULL && einfo->tbl != NULL && einfo->win != NULL && replace != NULL); if( ok ) { *replace = FALSE; block = WGetOrMakeStringBlock( einfo->tbl, id ); ok = (block != NULL); } if( ok ) { if( block->block.String[id & 0xf] == NULL ) { block->block.String[id & 0xf] = WResIDNameFromStr( text ); block->symbol[id & 0xf] = WStrDup( symbol ); einfo->info->modified = TRUE; } else { if( WQueryReplaceString( einfo->edit_dlg ) ) { WMemFree( block->block.String[id & 0xf] ); block->block.String[id & 0xf] = WResIDNameFromStr( text ); block->symbol[id & 0xf] = WStrDup( symbol ); einfo->info->modified = TRUE; *replace = TRUE; } else { if( WIsBlockEmpty( block ) ) { WRemoveStringBlock( einfo->tbl, block ); } ok = FALSE; } } } if( !ok ) { return( NULL ); } return( block ); }
static void handleSymbols( WMenuEditInfo *einfo ) { char *text; if( !WEditSymbols( einfo->win, &einfo->info->symbol_table, WGetEditInstance(), WMenuHelpRoutine ) ) { return; } WResolveMenuSymIDs( einfo ); text = WGetStrFromEdit( GetDlgItem( einfo->edit_dlg, IDM_MENUEDID ), NULL ); WRAddSymbolsToComboBox( einfo->info->symbol_table, einfo->edit_dlg, IDM_MENUEDID, WR_HASHENTRY_ALL ); if( text != NULL ) { WSetEditWithStr( GetDlgItem( einfo->edit_dlg, IDM_MENUEDID ), text ); WMemFree( text ); } WHandleSelChange( einfo ); }
void WSetEditTitle( WMenuEditInfo *einfo ) { char *title; Bool is_rc; title = WCreateEditTitle( einfo ); is_rc = FALSE; if( title == NULL ) { title = WAllocRCString( W_MENUAPPTITLE ); is_rc = TRUE; } if( title != NULL ) { SendMessage( einfo->win, WM_SETTEXT, 0, (LPARAM)title ); if( is_rc ) { WFreeRCString( title ); } else { WMemFree( title ); } } }
Bool WQuerySaveRes( WMenuEditInfo *einfo, Bool force_exit ) { int ret; UINT style; char *title; char *text; if( einfo != NULL && einfo->info->modified ) { ret = IDYES; if( einfo->info->stand_alone ) { if( force_exit ) { style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; } else { style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION; } title = WCreateEditTitle( einfo ); text = WAllocRCString( W_UPDATEMODIFIEDMENU ); ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { WFreeRCString( text ); } if( title != NULL ) { WMemFree( title ); } } if( ret == IDYES ) { if( einfo->info->stand_alone ) { return( WSaveObject( einfo, FALSE, FALSE ) ); } else { SendMessage( einfo->info->parent, MENU_PLEASE_SAVEME, 0, (LPARAM)einfo->hndl ); } } else if( ret == IDCANCEL ) { return( FALSE ); } } return( TRUE ); }
Bool WCreateEditWindow( HINSTANCE inst, WMenuEditInfo *einfo ) { int x, y, width, height; char *title; HMENU hmenu; HMENU menu; Bool is_rc; RECT rect; if( einfo == NULL ) { return( FALSE ); } x = CW_USEDEFAULT; y = CW_USEDEFAULT; width = appWidth; height = appHeight; if( einfo->info->stand_alone ) { WGetScreenPosOption( &rect ); if( !IsRectEmpty( &rect ) ) { x = rect.left; y = rect.top; width = max( appWidth, rect.right - rect.left ); height = max( appHeight, rect.bottom - rect.top ); } } is_rc = FALSE; title = WCreateEditTitle( einfo ); if( title == NULL ) { title = WAllocRCString( W_MENUAPPTITLE ); is_rc = TRUE; } menu = (HMENU)NULL; if( einfo->info->stand_alone ) { menu = LoadMenu( inst, WMainSOMenuName ); } einfo->win = CreateWindow( WMainClass, title, WS_OVERLAPPEDWINDOW, x, y, width, height, einfo->info->parent, menu, inst, einfo ); if( title != NULL ) { if( is_rc ) { WFreeRCString( title ); } else { WMemFree( title ); } } if( einfo->win == (HWND)NULL ) { return( FALSE ); } if( !WCreateRibbon( einfo ) ) { return( FALSE ); } einfo->wsb = WCreateStatusLine( einfo->win, inst ); if( einfo->wsb == NULL ) { return( FALSE ); } einfo->insert_subitems = FALSE; einfo->insert_before = FALSE; einfo->first_preview_id = FIRST_PREVIEW_ID; hmenu = GetMenu( einfo->win ); if( hmenu != (HMENU)NULL ) { EnableMenuItem( hmenu, IDM_MENU_CUT, MF_GRAYED ); EnableMenuItem( hmenu, IDM_MENU_COPY, MF_GRAYED ); } CheckMenuItem( hmenu, IDM_MENU_INSERTSUBITEMS, MF_UNCHECKED ); CheckMenuItem( hmenu, IDM_MENU_INSERTAFTER, MF_CHECKED ); if( !WCreateMenuEditWindow( einfo, inst ) ) { return( FALSE ); } if( WGetOption( WOptScreenMax ) ) { ShowWindow( einfo->win, SW_SHOWMAXIMIZED ); } else { ShowWindow( einfo->win, SW_SHOWNORMAL ); } UpdateWindow( einfo->win ); WResizeWindows( einfo ); SetFocus( einfo->edit_dlg ); return( TRUE ); }