Commit 10b34839 authored by Alexander Nicolaysen Sørnes's avatar Alexander Nicolaysen Sørnes Committed by Alexandre Julliard

wordpad: Allow toggling of toolbar.

parent 34d1beed
...@@ -52,6 +52,10 @@ BEGIN ...@@ -52,6 +52,10 @@ BEGIN
MENUITEM "&Get text", ID_EDIT_GETTEXT MENUITEM "&Get text", ID_EDIT_GETTEXT
END END
END END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR
END
POPUP "F&ormat" POPUP "F&ormat"
BEGIN BEGIN
POPUP "&Hintergrund" POPUP "&Hintergrund"
......
...@@ -52,6 +52,10 @@ BEGIN ...@@ -52,6 +52,10 @@ BEGIN
MENUITEM "&Get text", ID_EDIT_GETTEXT MENUITEM "&Get text", ID_EDIT_GETTEXT
END END
END END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR
END
POPUP "F&ormat" POPUP "F&ormat"
BEGIN BEGIN
POPUP "&Background" POPUP "&Background"
......
...@@ -52,6 +52,10 @@ BEGIN ...@@ -52,6 +52,10 @@ BEGIN
MENUITEM "&Recevoir texte", ID_EDIT_GETTEXT MENUITEM "&Recevoir texte", ID_EDIT_GETTEXT
END END
END END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR
END
POPUP "Forma&t" POPUP "Forma&t"
BEGIN BEGIN
POPUP "&Fond" POPUP "&Fond"
......
...@@ -52,6 +52,10 @@ BEGIN ...@@ -52,6 +52,10 @@ BEGIN
MENUITEM "Sz&vegszerzs", ID_EDIT_GETTEXT MENUITEM "Sz&vegszerzs", ID_EDIT_GETTEXT
END END
END END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR
END
POPUP "F&ormtum" POPUP "F&ormtum"
BEGIN BEGIN
POPUP "&Httr" POPUP "&Httr"
......
...@@ -53,6 +53,10 @@ BEGIN ...@@ -53,6 +53,10 @@ BEGIN
MENUITEM "텍스트 얻기(&G)", ID_EDIT_GETTEXT MENUITEM "텍스트 얻기(&G)", ID_EDIT_GETTEXT
END END
END END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR
END
POPUP "형식(&O)" POPUP "형식(&O)"
BEGIN BEGIN
POPUP "배경(&B)" POPUP "배경(&B)"
......
...@@ -52,6 +52,10 @@ BEGIN ...@@ -52,6 +52,10 @@ BEGIN
MENUITEM "&Haal tekst", ID_EDIT_GETTEXT MENUITEM "&Haal tekst", ID_EDIT_GETTEXT
END END
END END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR
END
POPUP "&Opmaak" POPUP "&Opmaak"
BEGIN BEGIN
POPUP "&Achtergrond" POPUP "&Achtergrond"
......
...@@ -52,6 +52,10 @@ BEGIN ...@@ -52,6 +52,10 @@ BEGIN
MENUITEM "&Hent tekst", ID_EDIT_GETTEXT MENUITEM "&Hent tekst", ID_EDIT_GETTEXT
END END
END END
POPUP "&Vis"
BEGIN
MENUITEM "Verk&tylinje", ID_TOGGLE_TOOLBAR
END
POPUP "F&ormat" POPUP "F&ormat"
BEGIN BEGIN
POPUP "&Bakgrunn" POPUP "&Bakgrunn"
......
...@@ -53,6 +53,10 @@ BEGIN ...@@ -53,6 +53,10 @@ BEGIN
MENUITEM "&Pobie tekst", ID_EDIT_GETTEXT MENUITEM "&Pobie tekst", ID_EDIT_GETTEXT
END END
END END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR
END
POPUP "F&ormat" POPUP "F&ormat"
BEGIN BEGIN
POPUP "&To" POPUP "&To"
......
...@@ -50,6 +50,10 @@ BEGIN ...@@ -50,6 +50,10 @@ BEGIN
MENUITEM "& ", ID_EDIT_GETTEXT MENUITEM "& ", ID_EDIT_GETTEXT
END END
END END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR
END
POPUP "&" POPUP "&"
BEGIN BEGIN
POPUP "&" POPUP "&"
......
...@@ -54,6 +54,10 @@ BEGIN ...@@ -54,6 +54,10 @@ BEGIN
MENUITEM "&Metni al", ID_EDIT_GETTEXT MENUITEM "&Metni al", ID_EDIT_GETTEXT
END END
END END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR
END
POPUP "&Biim" POPUP "&Biim"
BEGIN BEGIN
POPUP "&Arkaplan" POPUP "&Arkaplan"
......
...@@ -53,6 +53,10 @@ ...@@ -53,6 +53,10 @@
#define ID_FORMAT_ITALIC 1401 #define ID_FORMAT_ITALIC 1401
#define ID_FORMAT_UNDERLINE 1402 #define ID_FORMAT_UNDERLINE 1402
#define ID_TOGGLE_TOOLBAR 1500
#define BANDID_TOOLBAR 0
#define IDC_STATUSBAR 2000 #define IDC_STATUSBAR 2000
#define IDC_EDITOR 2001 #define IDC_EDITOR 2001
#define IDC_TOOLBAR 2002 #define IDC_TOOLBAR 2002
......
...@@ -48,6 +48,8 @@ static HWND hEditorWnd; ...@@ -48,6 +48,8 @@ static HWND hEditorWnd;
static WCHAR wszFilter[MAX_STRING_LEN]; static WCHAR wszFilter[MAX_STRING_LEN];
static LRESULT OnSize( HWND hWnd, WPARAM wParam, LPARAM lParam );
/* Load string resources */ /* Load string resources */
static void DoLoadStrings(void) static void DoLoadStrings(void)
{ {
...@@ -324,6 +326,43 @@ static void DoDefaultFont(void) ...@@ -324,6 +326,43 @@ static void DoDefaultFont(void)
SendMessage(hEditorWnd, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&fmt); SendMessage(hEditorWnd, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&fmt);
} }
static void toggle_toolbar(int bandId)
{
HWND hwndReBar = GetDlgItem(hMainWnd, IDC_REBAR);
REBARBANDINFOW rbbinfo;
RECT rect;
if(!hwndReBar)
return;
rbbinfo.cbSize = sizeof(rbbinfo);
rbbinfo.fMask = RBBIM_STYLE;
SendMessageW(hwndReBar, RB_GETBANDINFO, bandId, (LPARAM)&rbbinfo);
SendMessageW(hwndReBar, RB_SHOWBAND, bandId, (rbbinfo.fStyle & RBBS_HIDDEN));
GetWindowRect(hMainWnd, &rect);
(void) OnSize(hMainWnd, SIZE_RESTORED, MAKELONG(rect.bottom, rect.right));
}
static int rebar_height(void)
{
HWND hwndReBar = GetDlgItem(hMainWnd, IDC_REBAR);
REBARBANDINFOW rbbinfo;
if(!hwndReBar)
return 0;
rbbinfo.cbSize = sizeof(rbbinfo);
rbbinfo.fMask = RBBIM_STYLE;
SendMessageW(hwndReBar, RB_GETBANDINFO, BANDID_TOOLBAR, (LPARAM)&rbbinfo);
return (rbbinfo.fStyle & RBBS_HIDDEN) ? 0 : SendMessage(hwndReBar, RB_GETBARHEIGHT, 0, 0);
}
static LRESULT OnCreate( HWND hWnd, WPARAM wParam, LPARAM lParam) static LRESULT OnCreate( HWND hWnd, WPARAM wParam, LPARAM lParam)
{ {
HWND hToolBarWnd, hReBarWnd; HWND hToolBarWnd, hReBarWnd;
...@@ -389,7 +428,7 @@ static LRESULT OnCreate( HWND hWnd, WPARAM wParam, LPARAM lParam) ...@@ -389,7 +428,7 @@ static LRESULT OnCreate( HWND hWnd, WPARAM wParam, LPARAM lParam)
rbb.cxMinChild = 0; rbb.cxMinChild = 0;
rbb.cyChild = rbb.cyMinChild = HIWORD(SendMessage(hToolBarWnd, TB_GETBUTTONSIZE, 0, 0)); rbb.cyChild = rbb.cyMinChild = HIWORD(SendMessage(hToolBarWnd, TB_GETBUTTONSIZE, 0, 0));
SendMessage(hReBarWnd, RB_INSERTBAND, -1, (LPARAM)&rbb); SendMessageW(hReBarWnd, RB_INSERTBAND, BANDID_TOOLBAR, (LPARAM)&rbb);
hDLL = LoadLibrary("RICHED20.DLL"); hDLL = LoadLibrary("RICHED20.DLL");
assert(hDLL); assert(hDLL);
...@@ -674,6 +713,10 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) ...@@ -674,6 +713,10 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
SendMessage(hwndEditor, EM_SETBKGNDCOLOR, 0, RGB(255,255,192)); SendMessage(hwndEditor, EM_SETBKGNDCOLOR, 0, RGB(255,255,192));
break; break;
case ID_TOGGLE_TOOLBAR:
toggle_toolbar(BANDID_TOOLBAR);
break;
default: default:
SendMessage(hwndEditor, WM_COMMAND, wParam, lParam); SendMessage(hwndEditor, WM_COMMAND, wParam, lParam);
break; break;
...@@ -685,8 +728,10 @@ static LRESULT OnInitPopupMenu( HWND hWnd, WPARAM wParam, LPARAM lParam ) ...@@ -685,8 +728,10 @@ static LRESULT OnInitPopupMenu( HWND hWnd, WPARAM wParam, LPARAM lParam )
{ {
HMENU hMenu = (HMENU)wParam; HMENU hMenu = (HMENU)wParam;
HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR); HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR);
HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR);
PARAFORMAT pf; PARAFORMAT pf;
int nAlignment = -1; int nAlignment = -1;
REBARBANDINFOW rbbinfo;
pf.cbSize = sizeof(PARAFORMAT); pf.cbSize = sizeof(PARAFORMAT);
SendMessage(hwndEditor, EM_GETPARAFORMAT, 0, (LPARAM)&pf); SendMessage(hwndEditor, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
...@@ -701,17 +746,26 @@ static LRESULT OnInitPopupMenu( HWND hWnd, WPARAM wParam, LPARAM lParam ) ...@@ -701,17 +746,26 @@ static LRESULT OnInitPopupMenu( HWND hWnd, WPARAM wParam, LPARAM lParam )
CheckMenuItem(hMenu, ID_ALIGN_RIGHT, MF_BYCOMMAND|(nAlignment == PFA_RIGHT) ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hMenu, ID_ALIGN_RIGHT, MF_BYCOMMAND|(nAlignment == PFA_RIGHT) ? MF_CHECKED : MF_UNCHECKED);
EnableMenuItem(hMenu, ID_EDIT_UNDO, MF_BYCOMMAND|(SendMessage(hwndEditor, EM_CANUNDO, 0, 0)) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(hMenu, ID_EDIT_UNDO, MF_BYCOMMAND|(SendMessage(hwndEditor, EM_CANUNDO, 0, 0)) ? MF_ENABLED : MF_GRAYED);
EnableMenuItem(hMenu, ID_EDIT_REDO, MF_BYCOMMAND|(SendMessage(hwndEditor, EM_CANREDO, 0, 0)) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(hMenu, ID_EDIT_REDO, MF_BYCOMMAND|(SendMessage(hwndEditor, EM_CANREDO, 0, 0)) ? MF_ENABLED : MF_GRAYED);
rbbinfo.cbSize = sizeof(rbbinfo);
rbbinfo.fMask = RBBIM_STYLE;
SendMessageW(hwndReBar, RB_GETBANDINFO, 0, (LPARAM)&rbbinfo);
CheckMenuItem(hMenu, ID_TOGGLE_TOOLBAR, MF_BYCOMMAND|(rbbinfo.fStyle & RBBS_HIDDEN) ?
MF_UNCHECKED : MF_CHECKED);
return 0; return 0;
} }
static LRESULT OnSize( HWND hWnd, WPARAM wParam, LPARAM lParam ) static LRESULT OnSize( HWND hWnd, WPARAM wParam, LPARAM lParam )
{ {
int nStatusSize = 0, nTBSize = 0; int nStatusSize = 0;
RECT rc; RECT rc;
HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR); HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR);
HWND hwndStatusBar = GetDlgItem(hWnd, IDC_STATUSBAR); HWND hwndStatusBar = GetDlgItem(hWnd, IDC_STATUSBAR);
HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR); HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR);
HWND hwndToolBar = GetDlgItem(hwndReBar, IDC_TOOLBAR); HWND hwndToolBar = GetDlgItem(hwndReBar, IDC_TOOLBAR);
int rebarHeight;
if (hwndStatusBar) if (hwndStatusBar)
{ {
...@@ -726,14 +780,14 @@ static LRESULT OnSize( HWND hWnd, WPARAM wParam, LPARAM lParam ) ...@@ -726,14 +780,14 @@ static LRESULT OnSize( HWND hWnd, WPARAM wParam, LPARAM lParam )
rc.bottom = HIWORD(lParam); rc.bottom = HIWORD(lParam);
SendMessage(hwndToolBar, TB_AUTOSIZE, 0, 0); SendMessage(hwndToolBar, TB_AUTOSIZE, 0, 0);
SendMessage(hwndReBar, RB_SIZETORECT, 0, (LPARAM)&rc); SendMessage(hwndReBar, RB_SIZETORECT, 0, (LPARAM)&rc);
nTBSize = SendMessage(hwndReBar, RB_GETBARHEIGHT, 0, 0);
GetClientRect(hwndReBar, &rc); GetClientRect(hwndReBar, &rc);
MoveWindow(hwndReBar, 0, 0, LOWORD(lParam), rc.right, FALSE); MoveWindow(hwndReBar, 0, 0, LOWORD(lParam), rc.right, FALSE);
} }
if (hwndEditor) if (hwndEditor)
{ {
rebarHeight = rebar_height();
GetClientRect(hWnd, &rc); GetClientRect(hWnd, &rc);
MoveWindow(hwndEditor, 0, nTBSize, rc.right, rc.bottom-nStatusSize-nTBSize, TRUE); MoveWindow(hwndEditor, 0, rebarHeight, rc.right, rc.bottom-nStatusSize-rebarHeight, TRUE);
} }
return DefWindowProcW(hWnd, WM_SIZE, wParam, lParam); return DefWindowProcW(hWnd, WM_SIZE, wParam, lParam);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment