#include "config.h"\r
\r
#include <windows.h> /* required for all Windows applications */\r
+#include <richedit.h>\r
#include <stdio.h>\r
#include <stdlib.h>\r
#include <malloc.h>\r
\r
/* Module globals */\r
static char *editTagsText, **resPtr;\r
+static HWND memo;\r
BOOL editTagsUp = FALSE;\r
BOOL canEditTags = FALSE;\r
\r
{\r
static HANDLE hwndText;\r
static int sizeX, sizeY;\r
- int len, newSizeX, newSizeY, flags;\r
+ int len, newSizeX, newSizeY;\r
char *str;\r
RECT rect;\r
MINMAXINFO *mmi;\r
case WM_INITDIALOG: /* message: initialize dialog box */\r
/* Initialize the dialog items */\r
Translate(hDlg, DLG_EditTags);\r
- hwndText = GetDlgItem(hDlg, OPT_TagsText);\r
+ hwndText = memo = GetDlgItem(hDlg, OPT_TagsText);\r
SendMessage(hwndText, WM_SETFONT, \r
(WPARAM)font[boardSize][EDITTAGS_FONT]->hf, MAKELPARAM(FALSE, 0));\r
SetDlgItemText(hDlg, OPT_TagsText, editTagsText);\r
EnableWindow(GetDlgItem(hDlg, OPT_TagsCancel), canEditTags);\r
- EnableWindow(GetDlgItem(hDlg, OPT_EditTags), !canEditTags);\r
+ EnableWindow(GetDlgItem(hDlg, OPT_EditTags), !canEditTags || bookUp);\r
SendMessage(hwndText, EM_SETREADONLY, !canEditTags, 0);\r
if (bookUp) {\r
+ SetDlgItemText(hDlg, OPT_EditTags, _("&Play Move"));\r
SetWindowText(hDlg, _("Edit Book"));\r
SetFocus(hwndText);\r
} else\r
}\r
if (!editTagsDialog) {\r
editTagsDialog = hDlg;\r
- flags = SWP_NOZORDER;\r
GetClientRect(hDlg, &rect);\r
sizeX = rect.right;\r
sizeY = rect.bottom;\r
+ SendDlgItemMessage( hDlg, OPT_TagsText, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS );\r
if (wpTags.x != CW_USEDEFAULT && wpTags.y != CW_USEDEFAULT &&\r
wpTags.width != CW_USEDEFAULT && wpTags.height != CW_USEDEFAULT) {\r
WINDOWPLACEMENT wp;\r
return TRUE;\r
\r
case OPT_EditTags:\r
+ if(bookUp) addToBookFlag = !addToBookFlag; else\r
EditTagsEvent();\r
return TRUE;\r
\r
}\r
break;\r
\r
+ case WM_NOTIFY: // [HGM] vari: cloned from whistory.c\r
+ if( wParam == OPT_TagsText ) {\r
+ MSGFILTER * lpMF = (MSGFILTER *) lParam;\r
+\r
+ if( lpMF->msg == WM_RBUTTONDOWN ) {\r
+ POINTL pt;\r
+ LRESULT index;\r
+\r
+ pt.x = LOWORD( lpMF->lParam );\r
+ pt.y = HIWORD( lpMF->lParam );\r
+\r
+ index = SendDlgItemMessage( hDlg, OPT_TagsText, EM_CHARFROMPOS, 0, (LPARAM) &pt );\r
+\r
+ hwndText = GetDlgItem(hDlg, OPT_TagsText); // cloned from above\r
+ len = GetWindowTextLength(hwndText);\r
+ str = (char *) malloc(len + 1);\r
+ GetWindowText(hwndText, str, len + 1);\r
+ if(bookUp) PlayBookMove(str, index);\r
+ free(str);\r
+\r
+ /* Zap the message for good: apparently, returning non-zero is not enough */\r
+ lpMF->msg = WM_USER;\r
+\r
+ return TRUE;\r
+ }\r
+ }\r
+ break;\r
+\r
case WM_SIZE:\r
newSizeX = LOWORD(lParam);\r
newSizeY = HIWORD(lParam);\r
return FALSE;\r
}\r
\r
+VOID AddBookMove(char *text)\r
+{\r
+ SendMessage( memo, EM_SETSEL, 999999, 999999 ); // [HGM] multivar: choose insertion point\r
+ SendMessage( memo, EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) text );\r
+}\r
+\r
VOID TagsPopDown(void)\r
{\r
if (editTagsDialog) ShowWindow(editTagsDialog, SW_HIDE);\r
CheckMenuItem(GetMenu(hwndMain), IDM_Tags, MF_UNCHECKED);\r
- editTagsUp = bookUp = FALSE;\r
+ editTagsUp = bookUp = addToBookFlag = FALSE;\r
}\r
\r
\r