Beispiel #1
0
void PlayerPanel::DrawPlayerInformation(HDC DC, int X, int Y, int Width, int Height)
{
  if (Game != NULL)
  {
    const ChessPlayer* Player = Game->GetPlayer(Color);
    SetBkMode(DC,TRANSPARENT);
    SetTextColor(DC, GetSysColor(COLOR_BTNTEXT));
    /* Highlight the active player */
    if (Game->GetActivePlayer() == Color && Game->GetState() != Undefined)
    {
      HBRUSH OldBrush = (HBRUSH)SelectObject(DC,CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)));
      HPEN OldPen = (HPEN)SelectObject(DC,CreatePen(PS_SOLID,1,GetSysColor(COLOR_HIGHLIGHT)));
      Rectangle(DC,X,Y,X+Width,Y+Height);
      DeleteObject(SelectObject(DC,OldPen));
      DeleteObject(SelectObject(DC,OldBrush));
      SetTextColor(DC,GetSysColor(COLOR_HIGHLIGHTTEXT));
    }
    if (Game->GetState() >= Started)
    {
      /* Draw the player's time */
      SIZE S;
      HFONT OldFont = (HFONT)SelectObject(DC,EasyCreateFont(DC,DefaultSystemFont,8,0));
      char* Str = timeformat(Player->MoveTime/1000);
      GetTextExtentPoint32(DC,Str,strlen(Str),&S);
      TextOut(DC,X+4,Height-S.cy-2,Str,strlen(Str));
      delete[] Str;
      DeleteObject(SelectObject(DC,OldFont));
    }
    /* Draw the player's status */
    string Text;
    if (IsReady)
      Text = "Ready";
    else if (Game->GetActivePlayer() == Color)
    {
      if (Game->IsPlayerChecked() && Game->IsPlayerMated())
        Text = "Checkmate";
      else if (Game->IsPlayerMated())
        Text = "Stalemate";
      else if (Game->IsPlayerChecked())
        Text = "Check";
    }
    if (Text.length() > 0)
    {
      SIZE S;
      HFONT OldFont = (HFONT)SelectObject(DC,EasyCreateFont(DC,DefaultSystemFont,8,fsBold));
      GetTextExtentPoint32(DC,Text.c_str(),Text.length(),&S);
      TextOut(DC,X+Width-S.cx-4,Height-S.cy-2,Text.c_str(),Text.length());
      DeleteObject(SelectObject(DC,OldFont));
    }
    /* Clean up */
    SetBkMode(DC,OPAQUE);
  }
}
Beispiel #2
0
void ApplyRegSettings()
{
	int i;

	if(g_hFont)
		DeleteObject(g_hFont);

	g_hFont = EasyCreateFont(g_nFontSize, g_fFontBold, g_nFontSmoothing, g_szFontName);

	TextView_SetLineSpacing(g_hwndTextView, g_nPaddingAbove, g_nPaddingBelow);

	TextView_SetStyleBool(g_hwndTextView, TXS_SELMARGIN,	g_fSelMargin);
	TextView_SetStyleBool(g_hwndTextView, TXS_LINENUMBERS,	g_fLineNumbers);
	TextView_SetStyleBool(g_hwndTextView, TXS_LONGLINES,	g_fLongLines);

	TextView_SetStyleBool(g_hwndTextView, TXS_HIGHLIGHTCURLINE,	g_nHLCurLine);

	TextView_SetCaretWidth(g_hwndTextView, 2);
	TextView_SetLongLine(g_hwndTextView, g_nLongLineLimit);
	
	SendMessage(g_hwndTextView, WM_SETFONT, (WPARAM)g_hFont, 0);

	for(i = 0; i < TXC_MAX_COLOURS; i++)
	{
		TextView_SetColor(g_hwndTextView, i, g_rgbColourList[i]);
	}

	//
	//	System-wide options require Administrator access. On Vista we
	//	need to elevate using the UAC prompt. Only do this if the settings have actually
	//	changed
	//
	//SetExplorerContextMenu(g_fAddToExplorerContextMenu);
	//SetImageFileExecutionOptions(g_fReplaceNotepad);
}
Beispiel #3
0
void UpdatePreviewPane(HWND hwnd)
{
	TCHAR szFaceName[200];
	int idx = SendDlgItemMessage(hwnd, IDC_FONTLIST, CB_GETCURSEL, 0, 0);
	int size;
	DWORD data;

	SendDlgItemMessage(hwnd, IDC_FONTLIST, CB_GETLBTEXT, idx, (LONG)szFaceName);

	size = GetDlgItemInt(hwnd, IDC_SIZELIST, 0, FALSE);

	if(g_hPreviewFont != 0)
		DeleteObject(g_hPreviewFont);

	g_hPreviewFont = EasyCreateFont(size, 
								IsDlgButtonChecked(hwnd, IDC_BOLD),
								g_tempFontSmoothing,
								szFaceName);

	idx  = SendDlgItemMessage(hwnd, IDC_ITEMLIST, LB_GETCURSEL, 0, 0);
	data = SendDlgItemMessage(hwnd, IDC_ITEMLIST, LB_GETITEMDATA, idx, 0);


	if((short)LOWORD(data) >= 0)
		g_crPreviewFG = REALIZE_SYSCOL(g_rgbTempColourList[LOWORD(data)]);
	else
		g_crPreviewFG = GetSysColor(COLOR_WINDOWTEXT);

	if((short)HIWORD(data) >= 0)
		g_crPreviewBG = REALIZE_SYSCOL(g_rgbTempColourList[HIWORD(data)]);
	else
		g_crPreviewBG = GetSysColor(COLOR_WINDOW);

	InvalidateRect(GetDlgItem(hwnd, IDC_PREVIEW), 0, TRUE); 
}
Beispiel #4
0
void UpdateFontPreview(HWND hwnd)
{
	TCHAR szFont[LF_FACESIZE];
	int   nSize;
	HFONT hFont;

	//idx = SendDlgItemMessage(hwnd, IDC_FONTLIST, CB_GETCURSEL, 0, 0);
	GetDlgItemText(hwnd, IDC_FONTLIST, szFont, sizeof(szFont));

	//ComboBox_GetDlgSelData(
	nSize = GetDlgItemInt(hwnd, IDC_FONTSIZE, 0, FALSE);

	hFont = EasyCreateFont(szFont, nSize, FALSE);

	if(hFont)
	{
		HWND hwndHV = GetDlgItem(hwnd, IDC_HEXVIEW_PREVIEW);
		DeleteObject(g_hPreviewFont);

		g_hPreviewFont = hFont;

		SendMessage(hwndHV, WM_SETFONT, (WPARAM)hFont, 0);
		InvalidateRect(hwndHV, 0, 0);
	}
	//HexView_SetFont
	
}
Beispiel #5
0
void PlayerPanel::DrawChessPiece(HDC DC, int X, int Y)
{
  if (Set != NULL)
  {
    /* Set the style */
    SetBkMode(DC,TRANSPARENT);
    SetTextColor(DC, GetSysColor(COLOR_BTNTEXT));
    HFONT OldFont = (HFONT)SelectObject(DC,EasyCreateFont(DC,Set->FontName.c_str(),PixelsToPoints(DC, Height-4),0));
    /* Draw the piece */
    TextOut(DC,X,Y,Set->Letters.substr(Color == White ? 0 : 6, 1).c_str(),1);
    /* Clean up */
    DeleteObject(SelectObject(DC,OldFont));
    SetBkMode(DC,OPAQUE);
  }
}
static void DrawChessPiece(HDC DC, int X, int Y, int Piece)
{
  if (CurSet != NULL)
  {
    /* Set the style */
    SetBkMode(DC,TRANSPARENT);
    SetTextColor(DC, GetSysColor(COLOR_BTNTEXT));
    HFONT OldFont = (HFONT)SelectObject(DC,EasyCreateFont(DC,CurSet->FontName.c_str(),32,0));
    /* Draw the piece */
    SIZE Size;
    GetTextExtentPoint32(DC,CurSet->Letters.substr(Piece,1).c_str(),1,&Size);
    TextOut(DC,X-Size.cx/2,Y-Size.cy/2,CurSet->Letters.substr(Piece,1).c_str(),1);
    /* Clean up */
    SetBkMode(DC,OPAQUE);
    DeleteObject(SelectObject(DC,OldFont));
  }
}
Beispiel #7
0
LRESULT __stdcall PlayerPanel::PlayerButtonProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
  switch (Msg)
  {
    case WM_LBUTTONDOWN:
    {
      SetCapture(hWnd);

      /* Show menu */
      if (GetWindowLong(hWnd, GWL_USERDATA) < 2)
      {
        RECT R;
        GetWindowRect(hWnd, &R);
        PostMessage(GetParent(hWnd), WM_CONTEXTMENU, (WPARAM)hWnd, MAKELPARAM(R.left,R.bottom));
      }

      /* Set button status to pressed */
      SetWindowLong(hWnd, GWL_USERDATA, 2);
      InvalidateRect(hWnd, NULL, TRUE);
      return 0;
    }
    case WM_LBUTTONUP:
    {
      ReleaseCapture();

      /* Set button status to hover */
      SetWindowLong(hWnd, GWL_USERDATA, 1);
      InvalidateRect(hWnd, NULL, TRUE);
      return 0;
    }
    case WM_MOUSEMOVE:
    {
      /* Track mouse leave */
      TRACKMOUSEEVENT* Event = new TRACKMOUSEEVENT;
      Event->cbSize = sizeof(TRACKMOUSEEVENT);
      Event->dwFlags = TME_LEAVE;
      Event->hwndTrack = hWnd;
      TrackMouseEvent(Event);

      /* Set button status to hover */
      SetWindowLong(hWnd, GWL_USERDATA, 1);
      InvalidateRect(hWnd, NULL, TRUE);
      return 0;
    }
    case WM_MOUSELEAVE:
    {
      if (GetWindowLong(hWnd, GWL_USERDATA) < 2)
      {
        /* Set button status to none */
        SetWindowLong(hWnd, GWL_USERDATA, 0);
        InvalidateRect(hWnd, NULL, TRUE);
      }
      return 0;
    }
    case WM_PAINT:
    {
      PlayerPanel* Panel = (PlayerPanel*)GetWindowLong(GetParent(hWnd), GWL_USERDATA);

      if (Panel != NULL)
      {
        PAINTSTRUCT PS;
        HDC DC = BeginPaint(hWnd, &PS);
        if (DC != NULL)
        {
          RECT R;
          GetClientRect(hWnd, &R);

          /* Paint the background */
          if (GetWindowLong(hWnd, GWL_USERDATA) == 0)
          {
            /* Plain background */
            HBRUSH OldBrush = (HBRUSH)SelectObject(DC,CreateSolidBrush(GetSysColor(Panel->Game != NULL && Panel->Game->GetActivePlayer() == Panel->Color && Panel->Game->GetState() != Undefined ? COLOR_HIGHLIGHT : COLOR_BTNFACE)));
            HPEN OldPen = (HPEN)SelectObject(DC,CreatePen(PS_SOLID,1,GetSysColor(Panel->Game != NULL && Panel->Game->GetActivePlayer() == Panel->Color && Panel->Game->GetState() != Undefined ? COLOR_HIGHLIGHT : COLOR_BTNFACE)));
            Rectangle(DC,R.top,R.left,R.right-R.left,R.bottom-R.top);
            DeleteObject(SelectObject(DC,OldPen));
            DeleteObject(SelectObject(DC,OldBrush));
          }
          else
          {
            /* Button frame background */
            DRAWITEMSTRUCT* Item = new DRAWITEMSTRUCT;
            Item->hDC = DC;
            Item->itemState = (GetWindowLong(hWnd, GWL_USERDATA) > 1 ? ODS_SELECTED : ODS_DEFAULT);
            Item->rcItem = R;
            DrawCustomButton(hWnd, Item);
            delete Item;
          }

          /* Draw the player's name */
          if (Panel->Game != NULL)
          {
            InflateRect(&R,-5,-1);
            const ChessPlayer* Player = Panel->Game->GetPlayer(Panel->Color);
            SetBkMode(DC,TRANSPARENT);
            SetTextColor(DC, GetSysColor(Panel->Game->GetActivePlayer() == Panel->Color && Panel->Game->GetState() != Undefined && GetWindowLong(hWnd, GWL_USERDATA) == 0 ? COLOR_HIGHLIGHTTEXT : COLOR_BTNTEXT));
            HFONT OldFont = (HFONT)SelectObject(DC,EasyCreateFont(DC,DefaultSystemFont,9,0));
            const char* Text = Player->Name.c_str();
            if (strlen(Text) == 0)
            {
              if (Panel->Color == White)
                Text = "White";
              else
                Text = "Black";
            }
            DrawText(DC,Text,strlen(Text),&R,DT_NOPREFIX|DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_END_ELLIPSIS);
            DeleteObject(SelectObject(DC,OldFont));
          }
        }
        EndPaint(hWnd, &PS);
      }
      return 0;
    }
  }
  return CallWindowProc(OldPlayerButtonProc, hWnd, Msg, wParam, lParam);
}
Beispiel #8
0
PlayerPanel::PlayerPanel(HINSTANCE hInstance, HWND hParent, RECT* R, ChessPieceColor NewColor)
{
  Handle = NULL;
  PlayerButton = NULL;
  PlayerMenu = NULL;

  Game = NULL;
  Color = NewColor;
  Set = NULL;
  IsReady = false;
  TooltipVisible = false;
  Height = R->bottom-R->top;
  Width = R->right-R->left;

  if (ClassAtom == 0)
  {
    /* Register the window's class */
    WNDCLASSEX WndClass;
    WndClass.cbSize = sizeof(WNDCLASSEX);
    WndClass.lpszClassName = ClassName;
    WndClass.hInstance = hInstance;
    WndClass.lpfnWndProc = PanelWindowProc;
    WndClass.style = 0;
    WndClass.hbrBackground = NULL;
    WndClass.hIcon = 0;
    WndClass.hIconSm = 0;
    WndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
    WndClass.lpszMenuName = NULL;
    WndClass.cbClsExtra = 0;
    WndClass.cbWndExtra = 0;
    ClassAtom = RegisterClassEx(&WndClass);
  }
  /* Creates the window */
  if (ClassAtom != 0)
  {
    Handle = CreateWindowEx(0,ClassName,NULL,WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
        R->top,R->bottom,Width,Height,hParent,NULL,hInstance,this);
    if (Handle != NULL)
    {
      /* Create the child windows */
      PlayerButton = CreateWindowEx(0,"BUTTON",NULL,WS_CHILD|WS_CLIPSIBLINGS|WS_TABSTOP|WS_VISIBLE,
          0,0,0,0,Handle,NULL,hInstance,NULL);
      OldPlayerButtonProc = (WNDPROC)SetWindowLong(PlayerButton,GWL_WNDPROC,(LONG)PlayerButtonProc);

      ButtonTip = CreateWindowEx(0,TOOLTIPS_CLASS,NULL,WS_POPUP|TTS_NOPREFIX,
          CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,Handle,NULL,hInstance,NULL);

      TOOLINFO toolInfo;
      toolInfo.cbSize = sizeof(toolInfo);
      toolInfo.hwnd = Handle;
      toolInfo.uFlags = TTF_IDISHWND | TTF_ABSOLUTE | TTF_TRACK;
      toolInfo.uId = (UINT_PTR)PlayerButton;
      toolInfo.hinst = hInstance;
      toolInfo.lpszText = new char[MAX_PATH];
      LoadString(hInstance, IDS_TOOLTIP_PLAYERBUTTON, toolInfo.lpszText, MAX_PATH);
      SendMessage(ButtonTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);

      /* Initialize child window placement */
      ApplyThemeToCustomButton(Handle);
      UpdateSize(Width, Height);

      /* Change the window's appearance */
      HFONT Font = EasyCreateFont(NULL,DefaultSystemFont,10,fsBold);
      PostMessage(PlayerButton,WM_SETFONT,(WPARAM)Font,FALSE);

      /* Create the popup menu */
      PlayerMenu = CreatePopupMenu();
      AppendMenu(PlayerMenu,Color == White ? IDS_PLAYERMENU_JOINASWHITE : IDS_PLAYERMENU_JOINASBLACK);
      AppendMenu(PlayerMenu,IDS_PLAYERMENU_LEAVE);
      AppendSeparator(PlayerMenu);
      AppendMenu(PlayerMenu,IDS_PLAYERMENU_READY);

      /* Set the menu items default state */
      EnableMenuItem(PlayerMenu,Color == White ? IDS_PLAYERMENU_JOINASWHITE : IDS_PLAYERMENU_JOINASBLACK,MF_BYCOMMAND|MF_GRAYED);
      EnableMenuItem(PlayerMenu,IDS_PLAYERMENU_LEAVE,MF_BYCOMMAND|MF_GRAYED);
      EnableMenuItem(PlayerMenu,IDS_PLAYERMENU_READY,MF_BYCOMMAND|MF_GRAYED);
    }
  }
}
Beispiel #9
0
BOOL InitFontOptionsDlg(HWND hwnd)
{
	HWND	hwndPreview;
	int		i;
	LOGFONT lf;
	HFONT   hDlgFont;
	TCHAR	ach[LF_FACESIZE];

	// make a temporary copy of the current colour settings
	memcpy(g_rgbTempColourList, g_rgbColourList, sizeof(COLORREF) * TXC_MAX_COLOURS);

	//
	//	Load the TrueType icon for the font-list
	//
	g_hIcon2 = LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(IDI_ICON2), IMAGE_ICON, 16, 16, 0);
	g_hIcon3 = LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(IDI_ICON3), IMAGE_ICON, 16, 16, 0);
	
	//
	//	Create two fonts (normal+bold) based on current dialog's font settings
	//
	hDlgFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
	GetObject(hDlgFont, sizeof(lf), &lf);
		
	g_hNormalFont = CreateFontIndirect(&lf);
	lf.lfWeight   = FW_BOLD;
	g_hBoldFont   = CreateFontIndirect(&lf);

	//
	//	Manually set the COMBO item-heights because WM_MEASUREITEM has already
	//  been sent and we missed it..
	//
	SetComboItemHeight(GetDlgItem(hwnd, IDC_FGCOLCOMBO), 14);
	SetComboItemHeight(GetDlgItem(hwnd, IDC_BGCOLCOMBO), 14);
	SetComboItemHeight(GetDlgItem(hwnd, IDC_FONTLIST), 16);
	
	g_tempFontSmoothing = g_nFontSmoothing;
	g_hPreviewFont = EasyCreateFont(g_nFontSize, g_fFontBold, g_tempFontSmoothing, g_szFontName);

	// Create the list of fonts
	FillFontComboList(GetDlgItem(hwnd, IDC_FONTLIST));

	// Update the font-size-list
	InitSizeList(hwnd);
	
	//
	//	Subclass the PREVIEW static control so we can custom-draw it
	//
	hwndPreview = GetDlgItem(hwnd, IDC_PREVIEW);
	oldPreviewProc = (WNDPROC)SetWindowLongPtr(hwndPreview, GWLP_WNDPROC, (LONG)PreviewWndProc);
	
//	g_rgbAutoColourList[TXC_LONGLINE]	= MixRGB(GetSysColor(COLOR_3DFACE), GetSysColor(COLOR_WINDOW));
//	g_rgbAutoColourList[TXC_LINENUMBER]	= MixRGB(GetSysColor(COLOR_3DFACE), GetSysColor(COLOR_WINDOW));
//	g_rgbAutoColourList[TXC_LINENUMBER] = MixRGB(g_rgbAutoColourList[TXC_LINENUMBER], GetSysColor(COLOR_WINDOW));

	//g_rgbAutoColourList[TXC_LONGLINE]	= MixRGB(GetSysColor(COLOR_3DFACE), GetSysColor(COLOR_WINDOW));
	//g_rgbAutoColourList[TXC_LINENUMBER]	= MixRGB(GetSysColor(COLOR_3DFACE), GetSysColor(COLOR_WINDOW));
	//g_rgbAutoColourList[TXC_LINENUMBER] = MixRGB(g_rgbAutoColourList[TXC_LINENUMBER], GetSysColor(COLOR_WINDOW));

	AddColourListItem(hwnd, IDC_LIST1, TXC_FOREGROUND,		TXC_BACKGROUND,   _T("Text"));
	AddColourListItem(hwnd, IDC_LIST1, TXC_HIGHLIGHTTEXT,	TXC_HIGHLIGHT,    _T("Selected Text"));
	AddColourListItem(hwnd, IDC_LIST1, TXC_HIGHLIGHTTEXT2,  TXC_HIGHLIGHT2,   _T("Inactive Selection"));
	AddColourListItem(hwnd, IDC_LIST1, TXC_SELMARGIN1,		TXC_SELMARGIN2,   _T("Left Margin"));
	AddColourListItem(hwnd, IDC_LIST1, TXC_LINENUMBERTEXT,  TXC_LINENUMBER,   _T("Line Numbers"));
	AddColourListItem(hwnd, IDC_LIST1, -1,					TXC_LONGLINE,	  _T("Long Lines"));
	AddColourListItem(hwnd, IDC_LIST1, TXC_CURRENTLINETEXT, TXC_CURRENTLINE,  _T("Current Line"));
	
	SendDlgItemMessage(hwnd, IDC_ITEMLIST, LB_SETCURSEL, 0, 0);
	PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_ITEMLIST, LBN_SELCHANGE), (LPARAM)GetDlgItem(hwnd, IDC_ITEMLIST));

	for(i = 0; i < NUM_DEFAULT_COLOURS; i++)
	{
		AddColourComboItem(hwnd, IDC_FGCOLCOMBO, CUSTCOL[i].cr, CUSTCOL[i].szName);
		AddColourComboItem(hwnd, IDC_BGCOLCOMBO, CUSTCOL[i].cr, CUSTCOL[i].szName);
	}
	
	SendDlgItemMessage(hwnd, IDC_FGCOLCOMBO, CB_SETCURSEL, 1, 0);
	SendDlgItemMessage(hwnd, IDC_BGCOLCOMBO, CB_SETCURSEL, 0, 0);
	
	SendDlgItemMessage(hwnd, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10,0));
	SendDlgItemMessage(hwnd, IDC_SPIN2, UDM_SETRANGE, 0, MAKELONG(10,0));

	//
	//	Select
	//
	_stprintf(ach, _T("%d"), g_nFontSize);

	SendDlgItemMessage(hwnd, IDC_SIZELIST, CB_SELECTSTRING, -1, (LONG)ach);
	SendDlgItemMessage(hwnd, IDC_FONTLIST, CB_SELECTSTRING, -1, (LONG)g_szFontName);

	SetDlgItemInt(hwnd, IDC_PADDINGA, g_nPaddingAbove, 0);
	SetDlgItemInt(hwnd, IDC_PADDINGB, g_nPaddingBelow, 0);

	if((g_fPaddingFlags & COURIERNEW) && lstrcmpi(g_szFontName, _T("Courier New")) == 0)
	{
		SetDlgItemInt(hwnd, IDC_PADDINGA, g_nPaddingAbove, 0);
		SetDlgItemInt(hwnd, IDC_PADDINGB, g_nPaddingBelow, 1);
	}

	if((g_fPaddingFlags & LUCIDACONS) && lstrcmpi(g_szFontName, _T("Lucida Console")) == 0)
	{
		//SetDlgItemInt(hwnd, IDC_PADDINGA, g_nPaddingAbove, 2);
		//SetDlgItemInt(hwnd, IDC_PADDINGB, g_nPaddingBelow, 1);
		//SendDlgItemMessage(hwnd, IDC_
	}

	CheckDlgButton(hwnd, IDC_BOLD,    g_fFontBold);

	UpdatePreviewPane(hwnd);

	return TRUE;
}
void PreviewFont(HWND hWnd, PFont Font)
{
  HDC DC = GetWindowDC(hWnd);
  SendMessage(hWnd, WM_SETFONT, (WPARAM)EasyCreateFont(DC, Font), TRUE);
  ReleaseDC(hWnd, DC);
}