Author: janderwald
Date: Wed May 3 20:17:12 2006
New Revision: 21793
URL:
http://svn.reactos.ru/svn/reactos?rev=21793&view=rev
Log:
implement notepad view status bar -
TODO: update caret position on arrow key/mouse scroll events
Modified:
trunk/reactos/base/applications/notepad/dialog.c
trunk/reactos/base/applications/notepad/dialog.h
trunk/reactos/base/applications/notepad/main.c
trunk/reactos/base/applications/notepad/main.h
trunk/reactos/base/applications/notepad/notepad.h
trunk/reactos/base/applications/notepad/notepad.rbuild
trunk/reactos/base/applications/notepad/notepad_res.h
Modified: trunk/reactos/base/applications/notepad/dialog.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/notepad/d…
==============================================================================
--- trunk/reactos/base/applications/notepad/dialog.c (original)
+++ trunk/reactos/base/applications/notepad/dialog.c Wed May 3 20:17:12 2006
@@ -236,7 +236,7 @@
SendMessage(Globals.hEdit, EM_SETMODIFY, FALSE, 0);
SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
SetFocus(Globals.hEdit);
-
+
/* If the file starts with .LOG, add a time/date at the end and set cursor after
* See
http://support.microsoft.com/?kbid=260563
*/
@@ -366,7 +366,7 @@
hCombo = GetDlgItem(hDlg, ID_EOLN);
if (hCombo)
- Globals.iEoln = SendMessage(hCombo, CB_GETCURSEL, 0, 0);
+ Globals.iEoln = SendMessage(hCombo, CB_GETCURSEL, 0, 0);
}
break;
}
@@ -620,7 +620,7 @@
{
static const WCHAR editW[] = { 'e','d','i','t',0 };
DWORD dwStyle;
- RECT rc;
+ RECT rc, rcstatus;
DWORD size;
LPWSTR pTemp;
@@ -637,6 +637,19 @@
DestroyWindow(Globals.hEdit);
GetClientRect(Globals.hMainWnd, &rc);
dwStyle = Globals.bWrapLongLines ? EDIT_STYLE_WRAP : EDIT_STYLE;
+ EnableMenuItem(GetMenu(Globals.hMainWnd), CMD_STATUSBAR,
+ MF_BYCOMMAND | (Globals.bWrapLongLines ? MF_DISABLED | MF_GRAYED : MF_ENABLED));
+ if ( Globals.hStatusBar )
+ {
+ if ( Globals.bWrapLongLines )
+ ShowWindow(Globals.hStatusBar, SW_HIDE);
+ else if ( Globals.bShowStatusBar )
+ {
+ GetClientRect(Globals.hStatusBar, &rcstatus);
+ rc.bottom -= (rcstatus.bottom - rcstatus.top);
+ ShowWindow(Globals.hStatusBar, SW_SHOW);
+ }
+ }
Globals.hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, editW, NULL, dwStyle,
0, 0, rc.right, rc.bottom, Globals.hMainWnd,
NULL, Globals.hInstance, NULL);
@@ -645,6 +658,7 @@
SetWindowTextW(Globals.hEdit, pTemp);
SetFocus(Globals.hEdit);
HeapFree(GetProcessHeap(), 0, pTemp);
+ DrawMenuBar(Globals.hMainWnd);
}
VOID DIALOG_SelectFont(VOID)
@@ -780,6 +794,50 @@
HeapFree(GetProcessHeap(), 0, pszText);
}
+VOID DIALOG_StatusBarUpdateCaretPos(VOID)
+{
+ int line;
+ int col;
+ int ccol;
+ POINT point;
+ TCHAR buff[MAX_PATH];
+
+ GetCaretPos(&point);
+ line = SendMessage(Globals.hEdit, EM_LINEFROMCHAR, (WPARAM)-1, (LPARAM)0);
+ ccol = SendMessage(Globals.hEdit, EM_CHARFROMPOS, (WPARAM)0,
(LPARAM)MAKELPARAM(point.x, point.y));
+ ccol = LOWORD(ccol);
+ col = ccol - SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, (LPARAM)0);
+
+ _stprintf(buff, TEXT("%S %d, %S %d"), Globals.szStatusBarLine, line+1,
Globals.szStatusBarCol, col+1);
+ SendMessage(Globals.hStatusBar, SB_SETTEXT, (WPARAM) SB_SIMPLEID, (LPARAM)buff);
+}
+
+VOID DIALOG_ViewStatusBar(VOID)
+{
+ RECT rc;
+ RECT rcstatus;
+
+ Globals.bShowStatusBar = !Globals.bShowStatusBar;
+ if ( !Globals.hStatusBar )
+ {
+ Globals.hStatusBar = CreateStatusWindow(WS_CHILD | WS_VISIBLE | WS_EX_STATICEDGE,
TEXT("test"), Globals.hMainWnd, CMD_STATUSBAR_WND_ID );
+ LoadString(Globals.hInstance, STRING_LINE, Globals.szStatusBarLine, MAX_PATH-1);
+ LoadString(Globals.hInstance, STRING_COLUMN, Globals.szStatusBarCol, MAX_PATH-1);
+ SendMessage(Globals.hStatusBar, SB_SIMPLE, (WPARAM)TRUE, (LPARAM)0);
+ }
+ CheckMenuItem(GetMenu(Globals.hMainWnd), CMD_STATUSBAR,
+ MF_BYCOMMAND | (Globals.bShowStatusBar ? MF_CHECKED : MF_UNCHECKED));
+ DrawMenuBar(Globals.hMainWnd);
+ GetClientRect(Globals.hMainWnd, &rc);
+ GetClientRect(Globals.hStatusBar, &rcstatus);
+ if ( Globals.bShowStatusBar )
+ rc.bottom -= (rcstatus.bottom - rcstatus.top);
+
+ MoveWindow(Globals.hEdit, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
TRUE);
+ ShowWindow(Globals.hStatusBar, Globals.bShowStatusBar);
+ DIALOG_StatusBarUpdateCaretPos();
+}
+
VOID DIALOG_HelpContents(VOID)
{
WinHelp(Globals.hMainWnd, helpfileW, HELP_INDEX, 0);
Modified: trunk/reactos/base/applications/notepad/dialog.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/notepad/d…
==============================================================================
--- trunk/reactos/base/applications/notepad/dialog.h (original)
+++ trunk/reactos/base/applications/notepad/dialog.h Wed May 3 20:17:12 2006
@@ -43,6 +43,9 @@
VOID DIALOG_SelectFont(VOID);
+VOID DIALOG_ViewStatusBar(VOID);
+VOID DIALOG_StatusBarUpdateCaretPos(VOID);
+
VOID DIALOG_HelpContents(VOID);
VOID DIALOG_HelpSearch(VOID);
VOID DIALOG_HelpHelp(VOID);
Modified: trunk/reactos/base/applications/notepad/main.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/notepad/m…
==============================================================================
--- trunk/reactos/base/applications/notepad/main.c (original)
+++ trunk/reactos/base/applications/notepad/main.c Wed May 3 20:17:12 2006
@@ -75,6 +75,8 @@
case CMD_WRAP: DIALOG_EditWrap(); break;
case CMD_FONT: DIALOG_SelectFont(); break;
+ case CMD_STATUSBAR: DIALOG_ViewStatusBar(); break;
+
case CMD_HELP_CONTENTS: DIALOG_HelpContents(); break;
case CMD_HELP_SEARCH: DIALOG_HelpSearch(); break;
case CMD_HELP_ON_HELP: DIALOG_HelpHelp(); break;
@@ -82,7 +84,7 @@
MAKEINTRESOURCE(IDD_ABOUTBOX),
Globals.hMainWnd,
AboutDialogProc);
- break;
+ break;
case CMD_ABOUT_WINE: DIALOG_HelpAboutWine(); break;
default:
@@ -267,7 +269,11 @@
CheckMenuItem(GetMenu(Globals.hMainWnd), CMD_WRAP,
MF_BYCOMMAND | (Globals.bWrapLongLines ? MF_CHECKED : MF_UNCHECKED));
-
+ if ( !Globals.bWrapLongLines )
+ {
+ CheckMenuItem(GetMenu(Globals.hMainWnd), CMD_STATUSBAR,
+ MF_BYCOMMAND | (Globals.bShowStatusBar ? MF_CHECKED : MF_UNCHECKED));
+ }
EnableMenuItem(menu, CMD_UNDO,
SendMessage(Globals.hEdit, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED);
EnableMenuItem(menu, CMD_PASTE,
@@ -277,9 +283,10 @@
EnableMenuItem(menu, CMD_CUT, enable);
EnableMenuItem(menu, CMD_COPY, enable);
EnableMenuItem(menu, CMD_DELETE, enable);
-
+
EnableMenuItem(menu, CMD_SELECT_ALL,
GetWindowTextLength(Globals.hEdit) ? MF_ENABLED : MF_GRAYED);
+ DrawMenuBar(Globals.hMainWnd);
}
/***********************************************************************
@@ -308,6 +315,8 @@
}
case WM_COMMAND:
+ if (HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == EN_HSCROLL || HIWORD(wParam)
== EN_VSCROLL)
+ DIALOG_StatusBarUpdateCaretPos();
NOTEPAD_MenuCommand(LOWORD(wParam));
break;
@@ -350,11 +359,10 @@
DoOpenFile(szFileName);
break;
}
-
+ case WM_CHAR:
case WM_INITMENUPOPUP:
NOTEPAD_InitMenuPopup((HMENU)wParam, lParam);
break;
-
default:
if (msg == aFINDMSGSTRING)
{
@@ -515,7 +523,7 @@
class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
class.lpszMenuName = MAKEINTRESOURCE(MAIN_MENU);
class.lpszClassName = className;
- class.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_NPICON),
+ class.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_NPICON),
IMAGE_ICON, 16, 16, 0);
if (!RegisterClassEx(&class)) return FALSE;
Modified: trunk/reactos/base/applications/notepad/main.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/notepad/m…
==============================================================================
--- trunk/reactos/base/applications/notepad/main.h (original)
+++ trunk/reactos/base/applications/notepad/main.h Wed May 3 20:17:12 2006
@@ -45,9 +45,11 @@
HWND hMainWnd;
HWND hFindReplaceDlg;
HWND hEdit;
+ HWND hStatusBar;
HFONT hFont; /* Font used by the edit control */
LOGFONT lfFont;
BOOL bWrapLongLines;
+ BOOL bShowStatusBar;
WCHAR szFindText[MAX_PATH];
WCHAR szReplaceText[MAX_PATH];
WCHAR szFileName[MAX_PATH];
@@ -59,6 +61,8 @@
WCHAR szMarginRight[MAX_PATH];
WCHAR szHeader[MAX_PATH];
WCHAR szFooter[MAX_PATH];
+ WCHAR szStatusBarLine[MAX_PATH];
+ WCHAR szStatusBarCol[MAX_PATH];
int iEncoding;
int iEoln;
Modified: trunk/reactos/base/applications/notepad/notepad.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/notepad/n…
==============================================================================
--- trunk/reactos/base/applications/notepad/notepad.h (original)
+++ trunk/reactos/base/applications/notepad/notepad.h Wed May 3 20:17:12 2006
@@ -5,7 +5,9 @@
#include <stdio.h>
#include <windows.h>
#include <commdlg.h>
+#include <commctrl.h>
#include <tchar.h>
+#include <Richedit.h>
#include "main.h"
#include "dialog.h"
Modified: trunk/reactos/base/applications/notepad/notepad.rbuild
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/notepad/n…
==============================================================================
--- trunk/reactos/base/applications/notepad/notepad.rbuild (original)
+++ trunk/reactos/base/applications/notepad/notepad.rbuild Wed May 3 20:17:12 2006
@@ -6,6 +6,7 @@
<library>user32</library>
<library>gdi32</library>
<library>comdlg32</library>
+ <library>comctl32</library>
<library>advapi32</library>
<library>shell32</library>
<file>dialog.c</file>
Modified: trunk/reactos/base/applications/notepad/notepad_res.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/notepad/n…
==============================================================================
--- trunk/reactos/base/applications/notepad/notepad_res.h (original)
+++ trunk/reactos/base/applications/notepad/notepad_res.h Wed May 3 20:17:12 2006
@@ -57,7 +57,8 @@
#define CMD_WRAP 0x119
#define CMD_FONT 0x140
-#define CMD_STATUSBAR 0x150
+#define CMD_STATUSBAR 0x150
+#define CMD_STATUSBAR_WND_ID 0x151
#define CMD_HELP_CONTENTS 0x130
#define CMD_HELP_SEARCH 0x131
@@ -100,3 +101,5 @@
#define STRING_CR 0x184
#define STRING_LICENSE 0x185
+#define STRING_LINE 0x186
+#define STRING_COLUMN 0x187