void WShowRibbon( WAccelEditInfo *einfo, HMENU menu ) { char *mtext; if( !einfo && !menu ) { return; } mtext = NULL; if( einfo->show_ribbon ) { mtext = WAllocRCString( W_SHOWTOOLBAR ); ShowWindow( einfo->ribbon->win, SW_HIDE ); WSetStatusByID( einfo->wsb, -1, W_TOOLBARHIDDEN ); } else { mtext = WAllocRCString( W_HIDETOOLBAR ); ShowWindow ( einfo->ribbon->win, SW_SHOW ); WSetStatusByID( einfo->wsb, -1, W_TOOLBARSHOWN ); } einfo->show_ribbon = !einfo->show_ribbon; WResizeWindows( einfo ); ModifyMenu( menu, IDM_ACC_SHOWRIBBON, MF_BYCOMMAND | MF_STRING, IDM_ACC_SHOWRIBBON, mtext ); if( mtext ) { WFreeRCString( mtext ); } }
Bool WQueryClearRes( WMenuEditInfo *einfo ) { int ret; UINT style; char *title; char *text; if( einfo != NULL ) { style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; text = WAllocRCString( W_MENUCLEARWARNING ); title = WAllocRCString( W_MENUCLEARTITLE ); ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { WFreeRCString( text ); } if( title != NULL ) { WFreeRCString( title ); } if( ret == IDYES ) { return( TRUE ); } } return( FALSE ); }
Bool WSetStatusByID( WStatBar *wsb, DWORD id1, DWORD id2 ) { char *str1; char *str2; Bool ret; ret = FALSE; str1 = NULL; str2 = NULL; if( id1 != -1 ) { str1 = WAllocRCString( id1 ); } if( id2 != -1 ) { str2 = WAllocRCString( id2 ); } ret = WSetStatusText( wsb, str1, str2 ); if( str1 != NULL ) { WFreeRCString( str1 ); } if( str2 != NULL ) { WFreeRCString( str2 ); } return( ret ); }
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 ); }
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 WInitDummyMenuEntry( void ) { WDummyMenuEntry = (WMenuEntry *)WMemAlloc( sizeof( WMenuEntry ) ); memset( WDummyMenuEntry, 0, sizeof( WMenuEntry ) ); WDummyMenuEntry->item = ResNewMenuItem(); WDummyMenuEntry->item->Item.Normal.ItemText = WAllocRCString( W_MENUITEM ); WDummyMenuEntry->item->Item.Normal.ItemID = 101; }
static Bool WQueryReplaceString( HWND parent ) { char *title; char *text; int ret; text = WAllocRCString( W_QUERYREPLACESTRING ); title = WAllocRCString( W_INSERTNEWSTRING ); ret = MessageBox( parent, text, title, MB_APPLMODAL | MB_ICONEXCLAMATION | MB_YESNO ); if( text != NULL ) { WFreeRCString( text ); } if( title != NULL ) { WFreeRCString( title ); } return( ret == IDYES ); }
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 WCreatePrevWindow( HINSTANCE inst, WMenuEditInfo *einfo ) { int x, y, width, height, i; HWND win; HMENU sys_menu; RECT rect; char *title; if( !einfo || ( einfo->edit_dlg == (HWND)NULL ) ) { return ( FALSE ); } win = GetDlgItem( einfo->edit_dlg, IDM_MENUEDTESTPOS ); GetWindowRect( win, &rect ); x = rect.left; y = rect.top; width = 206; height = 63; title = WAllocRCString( W_PREVIEWMENU ); einfo->preview_window = CreateWindow( WPrevClass, title, WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU, x, y, width, height, einfo->edit_dlg, (HMENU) NULL, inst, einfo ); if( title ) { WFreeRCString( title ); } if( einfo->preview_window == (HWND)NULL ) { return( FALSE ); } sys_menu = GetSystemMenu( einfo->preview_window, FALSE ); if( sys_menu != (HMENU)NULL ) { i = GetMenuItemCount( sys_menu ); for( ; i>=0; i-- ) { DeleteMenu( sys_menu, i, MF_BYPOSITION ); } } SendMessage( einfo->preview_window, WM_NCACTIVATE, (WPARAM)TRUE, (LPARAM)NULL ); return ( TRUE ); }
Bool WInitStatusLines( HINSTANCE inst ) { LOGFONT lf; TEXTMETRIC tm; HFONT old_font; HDC dc; char *status_font; char *cp; int point_size; Bool use_default; memset( &lf, 0, sizeof( LOGFONT ) ); dc = GetDC( (HWND)NULL ); lf.lfWeight = FW_BOLD; use_default = TRUE; status_font = WAllocRCString( W_STATUSFONT ); if( status_font != NULL ) { cp = (char *)_mbschr( (unsigned char const *)status_font, '.' ); if( cp != NULL ) { *cp = '\0'; strcpy( lf.lfFaceName, status_font ); cp++; point_size = atoi( cp ); use_default = FALSE; } WFreeRCString( status_font ); } if( use_default ) { strcpy( lf.lfFaceName, STATUS_FONTNAME ); point_size = STATUS_POINTSIZE; } lf.lfHeight = -MulDiv( point_size, GetDeviceCaps( dc, LOGPIXELSY ), 72 ); WStatusFont = CreateFontIndirect( &lf ); old_font = SelectObject( dc, WStatusFont ); GetTextMetrics( dc, &tm ); SelectObject( dc, old_font ); ReleaseDC( (HWND)NULL, dc ); WStatusDepth = tm.tmHeight + STATUS_LINE_PAD + VERT_BORDER * 2; StatusWndInit( inst, WStatusWndProc, 0, NULL ); return( TRUE ); }
char *WCreateEditTitle( WMenuEditInfo *einfo ) { char *title; char *fname; char *text; int offset, len; title = NULL; fname = NULL; if( einfo == NULL ) { return( NULL ); } if( einfo->file_name == NULL ) { fname = einfo->info->file_name; } else { fname = einfo->file_name; } text = WAllocRCString( W_MENUAPPTITLE ); if( fname == NULL || text == NULL ) { return( NULL ); } offset = WRFindFnOffset( fname ); fname = &fname[offset]; len = strlen( fname ) + strlen( text ) + 6; title = (char *)WMemAlloc( len ); if( title != NULL ) { strcpy( title, text ); strcat( title, " - [" ); strcat( title, fname ); strcat( title, "]" ); } if( text != NULL ) { WFreeRCString( text ); } return( title ); }
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 ); }