Allow adding played move to book
[xboard.git] / winboard / wedittags.c
index 6a8b1c6..79f4edc 100644 (file)
@@ -26,6 +26,7 @@
 #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
@@ -43,6 +44,7 @@
 \r
 /* Module globals */\r
 static char *editTagsText, **resPtr;\r
+static HWND memo;\r
 BOOL editTagsUp = FALSE;\r
 BOOL canEditTags = FALSE;\r
 \r
@@ -66,14 +68,15 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   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
@@ -150,6 +153,7 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       return TRUE;\r
       \r
     case OPT_EditTags:\r
+      if(bookUp) addToBookFlag = !addToBookFlag; else\r
       EditTagsEvent();\r
       return TRUE;\r
 \r
@@ -204,11 +208,17 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   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