X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwchat.c;fp=winboard%2Fwchat.c;h=0000000000000000000000000000000000000000;hb=b10966961672512a212cc61192d0b08cf91c4c0c;hp=3be1e7f7d33d2bb1dd196b8191470c2a97d8c083;hpb=e147dd97d26b46902200491dbe0a8755266555d3;p=xboard.git diff --git a/winboard/wchat.c b/winboard/wchat.c deleted file mode 100644 index 3be1e7f..0000000 --- a/winboard/wchat.c +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Chat window (PV) - * - * Author: H.G.Muller (August 2009) - * - * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free - * Software Foundation, Inc. - * - * ------------------------------------------------------------------------ - * - * GNU XBoard is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * GNU XBoard is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. * - * - *------------------------------------------------------------------------ - ** See the file ChangeLog for a revision history. */ - -#include "config.h" - -#include /* required for all Windows applications */ -#include -#include -#include -#include -#include -#include -#include - -#include "common.h" -#include "frontend.h" -#include "winboard.h" -#include "backend.h" - -#include "wsnap.h" - -int chatCount; -static int onTop; -extern char chatPartner[MAX_CHAT][MSG_SIZ]; -HANDLE chatHandle[MAX_CHAT]; -static WNDPROC chatInputWindowProc; - -void SendToICS P((char *s)); -void ChatPopUp P((char *s)); -void ChatPopDown(); - -/* Imports from backend.c */ -extern int opponentKibitzes; - -/* Imports from winboard.c */ -VOID SaveInHistory(char *cmd); -char *PrevInHistory(char *cmd); -char *NextInHistory(); -extern HWND ChatDialog; - -extern HINSTANCE hInst; -extern HWND hwndConsole; -extern char ics_handle[]; - -extern WindowPlacement wpChat[MAX_CHAT]; -extern WindowPlacement wpConsole; - -extern BoardSize boardSize; - -/* Module variables */ -#define H_MARGIN 5 -#define V_MARGIN 5 - -// front end, although we might make GetWindowRect front end instead -static int GetControlWidth( HWND hDlg, int id ) -{ - RECT rc; - - GetWindowRect( GetDlgItem( hDlg, id ), &rc ); - - return rc.right - rc.left; -} - -// front end? -static int GetControlHeight( HWND hDlg, int id ) -{ - RECT rc; - - GetWindowRect( GetDlgItem( hDlg, id ), &rc ); - - return rc.bottom - rc.top; -} - -static void SetControlPos( HWND hDlg, int id, int x, int y, int width, int height ) -{ - HWND hControl = GetDlgItem( hDlg, id ); - - SetWindowPos( hControl, HWND_TOP, x, y, width, height, SWP_NOZORDER ); -} - -// Also here some of the size calculations should go to the back end, and their actual application to a front-end routine -static void ResizeWindowControls( HWND hDlg ) -{ - RECT rc; - int clientWidth; - int clientHeight; - int maxControlWidth; - int buttonWidth, buttonHeight; - - /* Initialize variables */ - GetClientRect( hDlg, &rc ); - - clientWidth = rc.right - rc.left; - clientHeight = rc.bottom - rc.top; - - maxControlWidth = clientWidth - 2*H_MARGIN; - buttonWidth = GetControlWidth(hDlg, IDC_Send); - buttonHeight = GetControlHeight(hDlg, IDC_Send); - - /* Resize controls */ - SetControlPos( hDlg, IDC_Clear, maxControlWidth+H_MARGIN-2*buttonWidth-5, V_MARGIN, buttonWidth, buttonHeight ); - SetControlPos( hDlg, IDC_Send, maxControlWidth+H_MARGIN-buttonWidth, V_MARGIN, buttonWidth, buttonHeight ); - SetControlPos( hDlg, IDC_ChatMemo, H_MARGIN, 2*V_MARGIN+buttonHeight, maxControlWidth, clientHeight-3*V_MARGIN-2*buttonHeight ); - SetControlPos( hDlg, OPT_ChatInput, H_MARGIN, clientHeight-V_MARGIN-buttonHeight, maxControlWidth, buttonHeight ); - -// InvalidateRect( GetDlgItem(hDlg,IDC_EngineMemo1), NULL, FALSE ); -// InvalidateRect( GetDlgItem(hDlg,IDC_EngineMemo2), NULL, FALSE ); -} - -// front end. Actual printing of PV lines into the output field -static void InsertIntoMemo( HANDLE hDlg, char * text ) -{ - HANDLE hMemo = GetDlgItem(hDlg, IDC_ChatMemo); - - SendMessage( hMemo, EM_SETSEL, 1000000, 1000000 ); - - SendMessage( hMemo, EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) text ); - SendMessage( hMemo, EM_SCROLLCARET, 0, 0); -} - -LRESULT CALLBACK -InterceptArrowKeys(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - char buf[MSG_SIZ]; - char *p; - CHARRANGE sel; - - switch (message) { - case WM_KEYDOWN: // cloned from ConsoleInputSubClass() - switch (wParam) { - case VK_UP: - GetWindowText(hwnd, buf, MSG_SIZ); - p = PrevInHistory(buf); - if (p != NULL) { - SetWindowText(hwnd, p); - sel.cpMin = 999999; - sel.cpMax = 999999; - SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&sel); - return 0; - } - break; - case VK_DOWN: - p = NextInHistory(); - if (p != NULL) { - SetWindowText(hwnd, p); - sel.cpMin = 999999; - sel.cpMax = 999999; - SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&sel); - return 0; - } - break; - } - } - return (*chatInputWindowProc)(hwnd, message, wParam, lParam); -} - -// This seems pure front end -LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) -{ - static SnapData sd; - char buf[MSG_SIZ], mess[MSG_SIZ]; - int partner = -1, i, x, y; - static BOOL filterHasFocus[MAX_CHAT]; - WORD wMask; - HWND hMemo; - - for(i=0; ipartner), chatPartner[i]); - } else EnableWindow( GetDlgItem(hDlg, IDC_Focus1+i-(i>partner)), 0 ); - for(i=0; icode == EN_LINK) - { - ENLINK *pLink = (ENLINK*)lParam; - if (pLink->msg == WM_LBUTTONUP) - { - TEXTRANGE tr; - - tr.chrg = pLink->chrg; - tr.lpstrText = malloc(1+tr.chrg.cpMax-tr.chrg.cpMin); - SendMessage( GetDlgItem(hDlg, IDC_ChatMemo), EM_GETTEXTRANGE, 0, (LPARAM)&tr); - ShellExecute(NULL, "open", tr.lpstrText, NULL, NULL, SW_SHOW); - free(tr.lpstrText); - } - } - break; - - case WM_COMMAND: - /* - [AS] - If is pressed while editing the filter, it's better to apply - the filter rather than selecting the current game. - */ - if( LOWORD(wParam) == IDC_ChatPartner ) { - switch( HIWORD(wParam) ) { - case EN_SETFOCUS: - filterHasFocus[partner] = TRUE; - break; - case EN_KILLFOCUS: - filterHasFocus[partner] = FALSE; - break; - } - } - - if( filterHasFocus[partner] && (LOWORD(wParam) == IDC_Send) ) { - SetFocus(GetDlgItem(hDlg, OPT_ChatInput)); - wParam = IDC_Change; - } - /* [AS] End command replacement */ - - switch (LOWORD(wParam)) { - - case IDCANCEL: /* let Esc key switch focus back to console */ - SetFocus(GetDlgItem(hwndConsole, OPT_ConsoleInput)); - break; - - case IDC_Clear: - SendMessage( GetDlgItem(hDlg, IDC_ChatMemo), WM_SETTEXT, 0, (LPARAM) "" ); - break; - - case IDC_Change: - GetDlgItemText(hDlg, IDC_ChatPartner, chatPartner[partner], MSG_SIZ); - for(i=0; i %s\r\n", mess); // echo only tells to handle, not channel - InsertIntoMemo(hDlg, buf); - snprintf(buf, MSG_SIZ, "xtell %s %s\n", chatPartner[partner], mess); - } else - snprintf(buf, MSG_SIZ, "tell %s %s\n", chatPartner[partner], mess); - } - SendToICS(buf); - break; - - case IDC_Focus1: - case IDC_Focus2: - case IDC_Focus3: - case IDC_Focus4: - i = LOWORD(wParam) - IDC_Focus1; - if(i >= partner) i++; - onTop = i; - SetFocus(GetDlgItem(hDlg, IDC_Send)); - if(chatHandle[i]) { - int j; - for(j=0; j