Create new (empty) branch for board themes
[xboard.git] / winboard / whistory.c
diff --git a/winboard/whistory.c b/winboard/whistory.c
deleted file mode 100644 (file)
index 4d0080f..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-/*\r
- * Move history for WinBoard\r
- *\r
- * Author: Alessandro Scotti (Dec 2005)\r
- * front-end code split off by HGM\r
- *\r
- * Copyright 2005 Alessandro Scotti\r
- *\r
- * Enhancements Copyright 2009, 2010, 2014, 2015, 2016 Free Software\r
- * Foundation, Inc.\r
- *\r
- * ------------------------------------------------------------------------\r
- *\r
- * GNU XBoard is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or (at\r
- * your option) any later version.\r
- *\r
- * GNU XBoard is distributed in the hope that it will be useful, but\r
- * WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see http://www.gnu.org/licenses/.\r
- *\r
- * ------------------------------------------------------------------------\r
- ** See the file ChangeLog for a revision history.  */\r
-\r
-#include "config.h"\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <malloc.h>\r
-#include <windows.h> /* required for all Windows applications */\r
-#include <richedit.h>\r
-#include <commdlg.h>\r
-#include <dlgs.h>\r
-\r
-#include "common.h"\r
-#include "frontend.h"\r
-#include "backend.h"\r
-#include "winboard.h"\r
-#include "wsnap.h"\r
-\r
-// templates for calls into back-end\r
-void RefreshMemoContent P((void));\r
-void MemoContentUpdated P((void));\r
-void FindMoveByCharIndex P(( int char_index ));\r
-\r
-#define DEFAULT_COLOR       0xFFFFFFFF\r
-\r
-#define H_MARGIN            2\r
-#define V_MARGIN            2\r
-\r
-static BOOLEAN moveHistoryDialogUp = FALSE;\r
-\r
-// ------------- low-level front-end actions called by MoveHistory back-end -----------------\r
-\r
-// low-level front-end, after calculating from & to is left to caller\r
-// it task is to highlight the indicated characters. (In WinBoard it makes them bold and blue.)\r
-void HighlightMove( int from, int to, Boolean highlight )\r
-{\r
-        CHARFORMAT cf;\r
-        HWND hMemo = GetDlgItem( moveHistoryDialog, IDC_MoveHistory );\r
-\r
-        SendMessage( hMemo, EM_SETSEL, from, to);\r
-\r
-\r
-        /* Set style */\r
-        ZeroMemory( &cf, sizeof(cf) );\r
-\r
-        cf.cbSize = sizeof(cf);\r
-        cf.dwMask = CFM_BOLD | CFM_COLOR;\r
-\r
-        if( highlight ) {\r
-            cf.dwEffects |= CFE_BOLD;\r
-            cf.crTextColor = RGB( 0x00, 0x00, 0xFF );\r
-        }\r
-        else {\r
-            cf.dwEffects |= CFE_AUTOCOLOR;\r
-        }\r
-\r
-        SendMessage( hMemo, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf );\r
-}\r
-\r
-// low-level front-end, but replace Windows data types to make it callable from back-end\r
-// its task is to clear the contents of the move-history text edit\r
-void ClearHistoryMemo()\r
-{\r
-    SendDlgItemMessage( moveHistoryDialog, IDC_MoveHistory, WM_SETTEXT, 0, (LPARAM) "" );\r
-}\r
-\r
-// low-level front-end, made callable from back-end by passing flags and color numbers\r
-// its task is to append the given text to the text edit\r
-// the bold argument says 0 = normal, 1 = bold typeface\r
-// the colorNr argument says 0 = font-default, 1 = gray\r
-int AppendToHistoryMemo( char * text, int bold, int colorNr )\r
-{\r
-    CHARFORMAT cf;\r
-    DWORD flags = bold ? CFE_BOLD :0;\r
-    DWORD color = colorNr ? GetSysColor(COLOR_GRAYTEXT) : DEFAULT_COLOR;\r
-\r
-    HWND hMemo = GetDlgItem( moveHistoryDialog, IDC_MoveHistory );\r
-\r
-    /* Select end of text */\r
-    int cbTextLen = (int) SendMessage( hMemo, WM_GETTEXTLENGTH, 0, 0 );\r
-\r
-    SendMessage( hMemo, EM_SETSEL, cbTextLen, cbTextLen );\r
-\r
-    /* Set style */\r
-    ZeroMemory( &cf, sizeof(cf) );\r
-\r
-    cf.cbSize = sizeof(cf);\r
-    cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_COLOR | CFM_UNDERLINE;\r
-    cf.dwEffects = flags;\r
-\r
-    if( color != DEFAULT_COLOR ) {\r
-        cf.crTextColor = color;\r
-    }\r
-    else {\r
-        cf.dwEffects |= CFE_AUTOCOLOR;\r
-    }\r
-\r
-    SendMessage( hMemo, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf );\r
-\r
-    /* Append text */\r
-    SendMessage( hMemo, EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) text );\r
-\r
-    /* Return offset of appended text */\r
-    return cbTextLen;\r
-}\r
-\r
-// low-level front-end; wrapper for the code to scroll the mentioned character in view (-1 = end)\r
-void ScrollToCurrent(int caretPos)\r
-{\r
-    if(caretPos < 0)\r
-        caretPos = (int) SendDlgItemMessage( moveHistoryDialog, IDC_MoveHistory, WM_GETTEXTLENGTH, 0, 0 );\r
-    SendDlgItemMessage( moveHistoryDialog, IDC_MoveHistory, EM_SETSEL, caretPos, caretPos );\r
-\r
-    SendDlgItemMessage( moveHistoryDialog, IDC_MoveHistory, EM_SCROLLCARET, 0, 0 );\r
-}\r
-\r
-\r
-// ------------------------------ call backs --------------------------\r
-\r
-// front-end. Universal call-back for any event. Recognized vents are dialog creation, OK and cancel button-press\r
-// (dead code, as these buttons do not exist?), mouse clicks on the text edit, and moving / sizing\r
-LRESULT CALLBACK HistoryDialogProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )\r
-{\r
-    static SnapData sd;\r
-\r
-    switch (message) {\r
-    case WM_INITDIALOG:\r
-        if( moveHistoryDialog == NULL ) {\r
-            moveHistoryDialog = hDlg;\r
-            Translate(hDlg, DLG_MoveHistory);\r
-\r
-            /* Enable word wrapping and notifications */\r
-            SendDlgItemMessage( moveHistoryDialog, IDC_MoveHistory, EM_SETTARGETDEVICE, 0, 0 );\r
-\r
-            SendDlgItemMessage( moveHistoryDialog, IDC_MoveHistory, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS );\r
-\r
-            /* Set font */\r
-           SendDlgItemMessage( moveHistoryDialog, IDC_MoveHistory, WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0 ));\r
-\r
-            /* Restore window placement */\r
-            RestoreWindowPlacement( hDlg, &wpMoveHistory );\r
-        }\r
-\r
-        /* Update memo */\r
-        RefreshMemoContent();\r
-\r
-        MemoContentUpdated();\r
-\r
-        return FALSE;\r
-\r
-    case WM_COMMAND:\r
-        switch (LOWORD(wParam)) {\r
-        case IDOK:\r
-          EndDialog(hDlg, TRUE);\r
-          return TRUE;\r
-\r
-        case IDCANCEL:\r
-          EndDialog(hDlg, FALSE);\r
-          return TRUE;\r
-\r
-        default:\r
-          break;\r
-        }\r
-\r
-        break;\r
-\r
-    case WM_NOTIFY:\r
-        if( wParam == IDC_MoveHistory ) {\r
-            MSGFILTER * lpMF = (MSGFILTER *) lParam;\r
-\r
-            if( lpMF->msg == WM_LBUTTONDBLCLK && (lpMF->wParam & (MK_CONTROL | MK_SHIFT)) == 0 ) {\r
-                POINTL pt;\r
-                LRESULT index;\r
-\r
-                pt.x = LOWORD( lpMF->lParam );\r
-                pt.y = HIWORD( lpMF->lParam );\r
-\r
-                index = SendDlgItemMessage( hDlg, IDC_MoveHistory, EM_CHARFROMPOS, 0, (LPARAM) &pt );\r
-\r
-                FindMoveByCharIndex( index ); // [HGM] also does the actual moving to it, now\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
-        SetWindowPos( GetDlgItem( moveHistoryDialog, IDC_MoveHistory ),\r
-            HWND_TOP,\r
-            H_MARGIN, V_MARGIN,\r
-            LOWORD(lParam) - 2*H_MARGIN,\r
-            HIWORD(lParam) - 2*V_MARGIN,\r
-            SWP_NOZORDER );\r
-        break;\r
-\r
-    case WM_GETMINMAXINFO:\r
-        {\r
-            MINMAXINFO * mmi = (MINMAXINFO *) lParam;\r
-        \r
-            mmi->ptMinTrackSize.x = 100;\r
-            mmi->ptMinTrackSize.y = 100;\r
-        }\r
-        break;\r
-\r
-    case WM_CLOSE:\r
-        MoveHistoryPopDown();\r
-        break;\r
-\r
-    case WM_ENTERSIZEMOVE:\r
-        return OnEnterSizeMove( &sd, hDlg, wParam, lParam );\r
-\r
-    case WM_SIZING:\r
-        return OnSizing( &sd, hDlg, wParam, lParam );\r
-\r
-    case WM_MOVING:\r
-        return OnMoving( &sd, hDlg, wParam, lParam );\r
-\r
-    case WM_EXITSIZEMOVE:\r
-        return OnExitSizeMove( &sd, hDlg, wParam, lParam );\r
-    }\r
-\r
-    return FALSE;\r
-}\r
-\r
-// ------------ standard entry points into MoveHistory code -----------\r
-\r
-// front-end\r
-VOID MoveHistoryPopUp()\r
-{\r
-  FARPROC lpProc;\r
-  \r
-  CheckMenuItem(GetMenu(hwndMain), IDM_ShowMoveHistory, MF_CHECKED);\r
-\r
-  if( moveHistoryDialog ) {\r
-    SendMessage( moveHistoryDialog, WM_INITDIALOG, 0, 0 );\r
-\r
-    if( ! moveHistoryDialogUp ) {\r
-        ShowWindow(moveHistoryDialog, SW_SHOW);\r
-    }\r
-  }\r
-  else {\r
-    lpProc = MakeProcInstance( (FARPROC) HistoryDialogProc, hInst );\r
-\r
-    /* Note to self: dialog must have the WS_VISIBLE style set, otherwise it's not shown! */\r
-    CreateDialog( hInst, MAKEINTRESOURCE(DLG_MoveHistory), hwndMain, (DLGPROC)lpProc );\r
-\r
-    FreeProcInstance(lpProc);\r
-  }\r
-\r
-  moveHistoryDialogUp = TRUE;\r
-\r
-// Note that in WIndows creating the dialog causes its call-back to perform\r
-// RefreshMemoContent() and MemoContentUpdated() immediately after it is realized.\r
-// To port this to X we might have to do that from here.\r
-}\r
-\r
-// front-end\r
-VOID MoveHistoryPopDown()\r
-{\r
-  CheckMenuItem(GetMenu(hwndMain), IDM_ShowMoveHistory, MF_UNCHECKED);\r
-\r
-  if( moveHistoryDialog ) {\r
-      ShowWindow(moveHistoryDialog, SW_HIDE);\r
-  }\r
-\r
-  moveHistoryDialogUp = FALSE;\r
-}\r
-\r
-// front-end\r
-Boolean MoveHistoryIsUp()\r
-{\r
-    return moveHistoryDialogUp;\r
-}\r
-\r
-// front-end\r
-Boolean MoveHistoryDialogExists()\r
-{\r
-    return moveHistoryDialog != NULL;\r
-}\r