Updated copyright notice to 2011
[xboard.git] / winboard / wedittags.c
index 3039f4c..22a23ab 100644 (file)
@@ -1,7 +1,7 @@
 /*\r
  * wedittags.c -- EditTags window for WinBoard\r
  *\r
- * Copyright 1995,2009 Free Software Foundation, Inc.\r
+ * Copyright 1995, 2009, 2010, 2011 Free Software Foundation, Inc.\r
  *\r
  * Enhancements Copyright 2005 Alessandro Scotti\r
  *\r
 #include <dlgs.h>\r
 \r
 #include "common.h"\r
-#include "winboard.h"\r
 #include "frontend.h"\r
 #include "backend.h"\r
-#include "wedittags.h"\r
+#include "winboard.h"\r
+\r
+#define _(s) T_(s)\r
 \r
 /* Module globals */\r
-static char *editTagsText;\r
-HWND editTagsDialog = NULL;\r
+static char *editTagsText, **resPtr;\r
 BOOL editTagsUp = FALSE;\r
 BOOL canEditTags = FALSE;\r
-int editTagsX, editTagsY, editTagsW, editTagsH;\r
 \r
 /* Imports from winboard.c */\r
 extern HINSTANCE hInst;\r
@@ -66,7 +65,8 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   switch (message) {\r
   case WM_INITDIALOG: /* message: initialize dialog box */\r
     /* Initialize the dialog items */\r
-    hwndText = GetDlgItem(hDlg, OPT_TagsText);\r
+    Translate(hDlg, DLG_EditTags);\r
+   hwndText = 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
@@ -74,10 +74,10 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     EnableWindow(GetDlgItem(hDlg, OPT_EditTags), !canEditTags);\r
     SendMessage(hwndText, EM_SETREADONLY, !canEditTags, 0);\r
     if (canEditTags) {\r
-      SetWindowText(hDlg, "Edit Tags");\r
+      SetWindowText(hDlg, _("Edit Tags"));\r
       SetFocus(hwndText);\r
     } else {\r
-      SetWindowText(hDlg, "Tags");\r
+      SetWindowText(hDlg, _("Tags"));\r
       SetFocus(GetDlgItem(hDlg, IDOK));\r
     }\r
     if (!editTagsDialog) {\r
@@ -86,18 +86,18 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       GetClientRect(hDlg, &rect);\r
       sizeX = rect.right;\r
       sizeY = rect.bottom;\r
-      if (editTagsX != CW_USEDEFAULT && editTagsY != CW_USEDEFAULT &&\r
-         editTagsW != CW_USEDEFAULT && editTagsH != CW_USEDEFAULT) {\r
+      if (wpTags.x != CW_USEDEFAULT && wpTags.y != CW_USEDEFAULT &&\r
+         wpTags.width != CW_USEDEFAULT && wpTags.height != CW_USEDEFAULT) {\r
        WINDOWPLACEMENT wp;\r
-       EnsureOnScreen(&editTagsX, &editTagsY, 0, 0);\r
+       EnsureOnScreen(&wpTags.x, &wpTags.y, 0, 0);\r
        wp.length = sizeof(WINDOWPLACEMENT);\r
        wp.flags = 0;\r
        wp.showCmd = SW_SHOW;\r
        wp.ptMaxPosition.x = wp.ptMaxPosition.y = 0;\r
-       wp.rcNormalPosition.left = editTagsX;\r
-       wp.rcNormalPosition.right = editTagsX + editTagsW;\r
-       wp.rcNormalPosition.top = editTagsY;\r
-       wp.rcNormalPosition.bottom = editTagsY + editTagsH;\r
+       wp.rcNormalPosition.left = wpTags.x;\r
+       wp.rcNormalPosition.right = wpTags.x + wpTags.width;\r
+       wp.rcNormalPosition.top = wpTags.y;\r
+       wp.rcNormalPosition.bottom = wpTags.y + wpTags.height;\r
        SetWindowPlacement(hDlg, &wp);\r
 \r
        GetClientRect(hDlg, &rect);\r
@@ -122,14 +122,15 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        GetWindowText(hwndText, str, len + 1);\r
        p = q = str;\r
        while (*q) {\r
-         if (*q == '\r'|| *q == '\n')\r
+         if (*q == '\r')\r
            q++;\r
          else\r
            *p++ = *q++;\r
        }\r
        *p = NULLCHAR;\r
+        if(resPtr) *resPtr = strdup(str), err = 0; else\r
        err = ReplaceTags(str, &gameInfo);\r
-       if (err) DisplayError("Error replacing tags.", err);\r
+       if (err) DisplayError(_("Error replacing tags."), err);\r
 \r
        free(str);\r
       }\r
@@ -171,7 +172,7 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 VOID TagsPopDown(void)\r
 {\r
   if (editTagsDialog) ShowWindow(editTagsDialog, SW_HIDE);\r
-  CheckMenuItem(GetMenu(hwndMain), IDM_EditTags, MF_UNCHECKED);\r
+  CheckMenuItem(GetMenu(hwndMain), IDM_Tags, MF_UNCHECKED);\r
   editTagsUp = FALSE;\r
 }\r
 \r
@@ -201,7 +202,7 @@ VOID EitherTagsPopUp(char *tags, char *msg, BOOLEAN edit)
   editTagsText = p;\r
   canEditTags = edit;\r
   \r
-  CheckMenuItem(GetMenu(hwndMain), IDM_EditTags, MF_CHECKED);\r
+  CheckMenuItem(GetMenu(hwndMain), IDM_Tags, MF_CHECKED);\r
   if (editTagsDialog) {\r
     SendMessage(editTagsDialog, WM_INITDIALOG, 0, 0);\r
     ShowWindow(editTagsDialog, SW_SHOW);\r
@@ -221,8 +222,9 @@ VOID TagsPopUp(char *tags, char *msg)
   SetActiveWindow(hwnd);\r
 }\r
 \r
-VOID EditTagsPopUp(char *tags)\r
+VOID EditTagsPopUp(char *tags, char **dest)\r
 {\r
+  resPtr = dest;\r
   EitherTagsPopUp(tags, "", TRUE);\r
 }\r
 \r