From 2de3d95ea5091b14d91f6003a605391fcd08d7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Wed, 6 Jun 2007 11:21:08 +0200 Subject: [PATCH] wordpad: Allow toggling of statusbar. --- programs/wordpad/De.rc | 1 + programs/wordpad/En.rc | 1 + programs/wordpad/Fr.rc | 1 + programs/wordpad/Hu.rc | 1 + programs/wordpad/Ko.rc | 1 + programs/wordpad/Nl.rc | 1 + programs/wordpad/No.rc | 1 + programs/wordpad/Pl.rc | 1 + programs/wordpad/Ru.rc | 1 + programs/wordpad/Tr.rc | 1 + programs/wordpad/resource.h | 1 + programs/wordpad/wordpad.c | 33 +++++++++++++++++++++++++++------ 12 files changed, 38 insertions(+), 6 deletions(-) diff --git a/programs/wordpad/De.rc b/programs/wordpad/De.rc index b09e743a1b3..dbaad477263 100644 --- a/programs/wordpad/De.rc +++ b/programs/wordpad/De.rc @@ -55,6 +55,7 @@ BEGIN POPUP "&View" BEGIN MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR + MENUITEM "&Statusbar", ID_TOGGLE_STATUSBAR END POPUP "F&ormat" BEGIN diff --git a/programs/wordpad/En.rc b/programs/wordpad/En.rc index a83eec6325e..d4099b2f499 100644 --- a/programs/wordpad/En.rc +++ b/programs/wordpad/En.rc @@ -55,6 +55,7 @@ BEGIN POPUP "&View" BEGIN MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR + MENUITEM "&Statusbar", ID_TOGGLE_STATUSBAR END POPUP "F&ormat" BEGIN diff --git a/programs/wordpad/Fr.rc b/programs/wordpad/Fr.rc index 0205954a683..a840f98c1f4 100644 --- a/programs/wordpad/Fr.rc +++ b/programs/wordpad/Fr.rc @@ -55,6 +55,7 @@ BEGIN POPUP "&View" BEGIN MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR + MENUITEM "&Statusbar", ID_TOGGLE_STATUSBAR END POPUP "Forma&t" BEGIN diff --git a/programs/wordpad/Hu.rc b/programs/wordpad/Hu.rc index 5ebcdee144f..3632029ec48 100644 --- a/programs/wordpad/Hu.rc +++ b/programs/wordpad/Hu.rc @@ -55,6 +55,7 @@ BEGIN POPUP "&View" BEGIN MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR + MENUITEM "&Statusbar", ID_TOGGLE_STATUSBAR END POPUP "F&ormátum" BEGIN diff --git a/programs/wordpad/Ko.rc b/programs/wordpad/Ko.rc index b01f68f3d3c..a45e8e5d6e7 100644 --- a/programs/wordpad/Ko.rc +++ b/programs/wordpad/Ko.rc @@ -56,6 +56,7 @@ BEGIN POPUP "&View" BEGIN MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR + MENUITEM "&Statusbar", ID_TOGGLE_STATUSBAR END POPUP "Çü½Ä(&O)" BEGIN diff --git a/programs/wordpad/Nl.rc b/programs/wordpad/Nl.rc index ed05fcc2ba7..5c5bd14d274 100644 --- a/programs/wordpad/Nl.rc +++ b/programs/wordpad/Nl.rc @@ -55,6 +55,7 @@ BEGIN POPUP "&View" BEGIN MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR + MENUITEM "&Statusbar", ID_TOGGLE_STATUSBAR END POPUP "&Opmaak" BEGIN diff --git a/programs/wordpad/No.rc b/programs/wordpad/No.rc index 4955ebd4f2c..e339b3af15e 100644 --- a/programs/wordpad/No.rc +++ b/programs/wordpad/No.rc @@ -55,6 +55,7 @@ BEGIN POPUP "&Vis" BEGIN MENUITEM "Verk&tøylinje", ID_TOGGLE_TOOLBAR + MENUITEM "&Statuslinje", ID_TOGGLE_STATUSBAR END POPUP "F&ormat" BEGIN diff --git a/programs/wordpad/Pl.rc b/programs/wordpad/Pl.rc index 161a4027b54..1d1362e10b7 100644 --- a/programs/wordpad/Pl.rc +++ b/programs/wordpad/Pl.rc @@ -56,6 +56,7 @@ BEGIN POPUP "&View" BEGIN MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR + MENUITEM "&Statusbar", ID_TOGGLE_STATUSBAR END POPUP "F&ormat" BEGIN diff --git a/programs/wordpad/Ru.rc b/programs/wordpad/Ru.rc index 37bb29154bb..8b0ea29573e 100644 --- a/programs/wordpad/Ru.rc +++ b/programs/wordpad/Ru.rc @@ -53,6 +53,7 @@ BEGIN POPUP "&View" BEGIN MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR + MENUITEM "&Statusbar", ID_TOGGLE_STATUSBAR END POPUP "Ôîð&ìàò" BEGIN diff --git a/programs/wordpad/Tr.rc b/programs/wordpad/Tr.rc index 35b9aefdfbe..d59856cfdca 100644 --- a/programs/wordpad/Tr.rc +++ b/programs/wordpad/Tr.rc @@ -57,6 +57,7 @@ BEGIN POPUP "&View" BEGIN MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR + MENUITEM "&Statusbar", ID_TOGGLE_STATUSBAR END POPUP "&Biçim" BEGIN diff --git a/programs/wordpad/resource.h b/programs/wordpad/resource.h index da122db0229..667b555f673 100644 --- a/programs/wordpad/resource.h +++ b/programs/wordpad/resource.h @@ -54,6 +54,7 @@ #define ID_FORMAT_UNDERLINE 1402 #define ID_TOGGLE_TOOLBAR 1500 +#define ID_TOGGLE_STATUSBAR 1501 #define BANDID_TOOLBAR 0 diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c index 7a16b15ff4f..bc18d31b505 100644 --- a/programs/wordpad/wordpad.c +++ b/programs/wordpad/wordpad.c @@ -326,11 +326,19 @@ static void DoDefaultFont(void) SendMessage(hEditorWnd, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&fmt); } +static void update_window(void) +{ + RECT rect; + + GetWindowRect(hMainWnd, &rect); + + (void) OnSize(hMainWnd, SIZE_RESTORED, MAKELONG(rect.bottom, rect.right)); +} + static void toggle_toolbar(int bandId) { HWND hwndReBar = GetDlgItem(hMainWnd, IDC_REBAR); REBARBANDINFOW rbbinfo; - RECT rect; if(!hwndReBar) return; @@ -342,9 +350,7 @@ static void toggle_toolbar(int bandId) SendMessageW(hwndReBar, RB_SHOWBAND, bandId, (rbbinfo.fStyle & RBBS_HIDDEN)); - GetWindowRect(hMainWnd, &rect); - - (void) OnSize(hMainWnd, SIZE_RESTORED, MAKELONG(rect.bottom, rect.right)); + update_window(); } static int rebar_height(void) @@ -518,6 +524,7 @@ static LRESULT OnNotify( HWND hWnd, WPARAM wParam, LPARAM lParam) static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) { HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR); + HWND hwndStatus = GetDlgItem(hWnd, IDC_STATUSBAR); if ((HWND)lParam == hwndEditor) return 0; @@ -717,6 +724,11 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) toggle_toolbar(BANDID_TOOLBAR); break; + case ID_TOGGLE_STATUSBAR: + ShowWindow(hwndStatus, IsWindowVisible(hwndStatus) ? SW_HIDE : SW_SHOW); + update_window(); + break; + default: SendMessage(hwndEditor, WM_COMMAND, wParam, lParam); break; @@ -729,6 +741,7 @@ static LRESULT OnInitPopupMenu( HWND hWnd, WPARAM wParam, LPARAM lParam ) HMENU hMenu = (HMENU)wParam; HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR); HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR); + HWND hwndStatus = GetDlgItem(hWnd, IDC_STATUSBAR); PARAFORMAT pf; int nAlignment = -1; REBARBANDINFOW rbbinfo; @@ -754,6 +767,8 @@ static LRESULT OnInitPopupMenu( HWND hWnd, WPARAM wParam, LPARAM lParam ) CheckMenuItem(hMenu, ID_TOGGLE_TOOLBAR, MF_BYCOMMAND|(rbbinfo.fStyle & RBBS_HIDDEN) ? MF_UNCHECKED : MF_CHECKED); + CheckMenuItem(hMenu, ID_TOGGLE_STATUSBAR, MF_BYCOMMAND|IsWindowVisible(hwndStatus) ? + MF_CHECKED : MF_UNCHECKED); return 0; } @@ -770,8 +785,14 @@ static LRESULT OnSize( HWND hWnd, WPARAM wParam, LPARAM lParam ) if (hwndStatusBar) { SendMessage(hwndStatusBar, WM_SIZE, 0, 0); - GetClientRect(hwndStatusBar, &rc); - nStatusSize = rc.bottom - rc.top; + if (IsWindowVisible(hwndStatusBar)) + { + GetClientRect(hwndStatusBar, &rc); + nStatusSize = rc.bottom - rc.top; + } else + { + nStatusSize = 0; + } } if (hwndToolBar) {