[ros-diffs] [tkreuzer] 26834: implement a basic fontview.exe. It doesn't work on ROS atm due to missing implementation of GetFontResourceInfoW(), but works on XP.

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Sat May 19 03:33:28 CEST 2007


Author: tkreuzer
Date: Sat May 19 05:33:27 2007
New Revision: 26834

URL: http://svn.reactos.org/svn/reactos?rev=26834&view=rev
Log:
implement a basic fontview.exe. It doesn't work on ROS atm due to missing implementation of GetFontResourceInfoW(), but works on XP.

Added:
    trunk/rosapps/fontview/
    trunk/rosapps/fontview/display.c
    trunk/rosapps/fontview/display.h
    trunk/rosapps/fontview/fontview.c
    trunk/rosapps/fontview/fontview.h
    trunk/rosapps/fontview/fontview.rbuild
    trunk/rosapps/fontview/fontview.rc
    trunk/rosapps/fontview/lang/
    trunk/rosapps/fontview/lang/de-DE.rc
    trunk/rosapps/fontview/lang/en-US.rc
    trunk/rosapps/fontview/resource.h
Modified:
    trunk/rosapps/directory.rbuild

Modified: trunk/rosapps/directory.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/directory.rbuild?rev=26834&r1=26833&r2=26834&view=diff
==============================================================================
--- trunk/rosapps/directory.rbuild (original)
+++ trunk/rosapps/directory.rbuild Sat May 19 05:33:27 2007
@@ -20,6 +20,10 @@
 
 <directory name="downloader">
 	<xi:include href="downloader/downloader.rbuild" />
+</directory>
+
+<directory name="fontview">
+	<xi:include href="fontview/fontview.rbuild" />
 </directory>
 
 <directory name="gettype">

Added: trunk/rosapps/fontview/display.c
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/display.c?rev=26834&view=auto
==============================================================================
--- trunk/rosapps/fontview/display.c (added)
+++ trunk/rosapps/fontview/display.c Sat May 19 05:33:27 2007
@@ -1,0 +1,344 @@
+/*
+ *	fontview display class
+ *
+ *	display.c
+ *
+ *	Copyright (C) 2007	Timo Kreuzer <timo <dot> kreuzer <at> reactos <dot> org>
+ *
+ *	This program 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 2 of the License, or
+ *	(at your option) any later version.
+ *
+ *	This program 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, write to the Free Software
+ *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+
+#include "display.h"
+
+#define SPACING1 8
+#define SPACING2 5
+
+const WCHAR g_szFontDisplayClassName[] = L"FontDisplayClass";
+LRESULT CALLBACK DisplayProc(HWND, UINT, WPARAM, LPARAM);
+
+/* Internal data storage type */
+typedef struct
+{
+	int nHeight;
+	WCHAR szTypeFaceName[MAX_TYPEFACENAME];
+	WCHAR szFormat[MAX_FORMAT];
+	WCHAR szString[MAX_STRING];
+} DISPLAYDATA;
+
+/* This is the only public function, it registers the class */
+BOOL
+Display_InitClass(HINSTANCE hInstance)
+{
+	WNDCLASSEXW wincl;
+
+	/* Set the fontdisplay window class structure */
+	wincl.cbSize = sizeof(WNDCLASSEX);
+	wincl.style = CS_DBLCLKS;
+	wincl.lpfnWndProc = DisplayProc;
+	wincl.cbClsExtra = 0;
+	wincl.cbWndExtra = 0;
+	wincl.hInstance = hInstance;
+	wincl.hIcon = NULL;
+	wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
+	wincl.hbrBackground = GetStockObject(WHITE_BRUSH);
+	wincl.lpszMenuName = NULL;
+	wincl.lpszClassName = g_szFontDisplayClassName;
+	wincl.hIconSm = NULL;
+
+	/* Register the window class, and if it fails return FALSE */
+	if (!RegisterClassExW (&wincl))
+	{
+		return FALSE;
+	}
+	return TRUE;
+}
+
+static int
+Display_DrawText(HDC hDC, DISPLAYDATA* pData, int nYPos, BOOL bDraw)
+{
+	HFONT hOldFont, hFont, hFontNums;
+	TEXTMETRIC tm;
+	int i, y;
+	const int nSizes[7] = {12, 18, 24, 36, 48, 60, 72};
+	WCHAR szSize[5];
+	WCHAR szCaption[MAX_TYPEFACENAME + 20];
+
+	/* This is the location on the DC where we draw */
+	y = -nYPos;
+
+	/* Draw font name */
+	hFont = CreateFontW(50, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
+	                   ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
+	                   DEFAULT_PITCH , L"Ms Shell Dlg");
+	hOldFont = SelectObject(hDC, hFont);
+	if (bDraw)
+	{
+		swprintf(szCaption, L"%s (%s)", pData->szTypeFaceName, pData->szFormat);
+		TextOutW(hDC, 0, y, szCaption, wcslen(szCaption));
+	}
+	GetTextMetrics(hDC, &tm);
+	y += tm.tmHeight + SPACING1;
+	SelectObject(hDC, hOldFont);
+	DeleteObject(hFont);
+
+	/* Draw a seperation Line */
+	if (bDraw)
+	{
+		SelectObject(hDC, GetStockObject(BLACK_PEN));
+		MoveToEx(hDC, 0, y, NULL);
+		LineTo(hDC, 10000, y);
+	}
+	y += SPACING2;
+
+	/* Output font info */
+	hFont = CreateFontW(12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
+						ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
+						DEFAULT_PITCH , pData->szTypeFaceName);
+	hOldFont = SelectObject(hDC, hFont);
+	SelectObject(hDC, hOldFont);
+	DeleteObject(hFont);
+
+	/* Outout the lines for different sizes */
+	hFontNums = CreateFontW(12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
+						ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
+						DEFAULT_PITCH , L"Ms Shell Dlg");
+
+	for (i = 0; i < 7; i++)
+	{
+		hOldFont = SelectObject(hDC, hFontNums);
+		if (bDraw)
+		{
+			swprintf(szSize, L"%d", nSizes[i]);
+			TextOutW(hDC, 0, y, szSize, wcslen(szSize));
+		}
+		hFont = CreateFontW(nSizes[i], 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
+						ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
+						DEFAULT_PITCH , pData->szTypeFaceName);
+		SelectObject(hDC, hFont);
+		if (bDraw)
+		{
+			TextOutW(hDC, 20, y, pData->szString, wcslen(pData->szString));
+		}
+		GetTextMetrics(hDC, &tm);
+		y += tm.tmHeight + 2;
+		SelectObject(hDC, hOldFont);
+		DeleteObject(hFont);
+	}
+	DeleteObject(hFontNums);
+
+	return y;
+}
+
+static LRESULT
+Display_OnCreate(HWND hwnd)
+{
+	DISPLAYDATA* pData;
+
+	/* Initialize data structure */
+	pData = malloc(sizeof(DISPLAYDATA));
+	pData->nHeight = 0;
+	swprintf(pData->szTypeFaceName, L"");
+	swprintf(pData->szFormat, L"");
+	swprintf(pData->szString, L"");
+
+	/* Set the window's GWLP_USERDATA to our data structure */
+	SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pData);
+
+	return 0;
+}
+
+static LRESULT
+Display_OnPaint(HWND hwnd)
+{
+	DISPLAYDATA* pData;
+	PAINTSTRUCT ps;
+	SCROLLINFO si;
+
+	pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+
+	/* Get the Scroll position */
+	si.cbSize = sizeof(si);
+	si.fMask = SIF_POS;
+	GetScrollInfo(hwnd, SB_VERT, &si);
+
+	BeginPaint(hwnd, &ps);
+
+	/* fill with white */
+	FillRect(ps.hdc, &ps.rcPaint, GetStockObject(WHITE_BRUSH));
+
+	/* Draw the text */
+	Display_DrawText(ps.hdc, pData, si.nPos, TRUE);
+
+	EndPaint(hwnd, &ps);
+
+	return 0;
+}
+
+static LRESULT
+Display_OnSize(HWND hwnd)
+{
+	RECT rect;
+	SCROLLINFO si; 
+
+	GetClientRect(hwnd, &rect);
+
+	/* Set the new page size */
+	si.cbSize = sizeof(si);
+	si.fMask  = SIF_PAGE;
+	si.nPage  = rect.bottom;
+	SetScrollInfo(hwnd, SB_VERT, &si, TRUE); 
+// FIXME: handle exceeding of current pos -> redraw entire window
+// if new page size is < curent pos: current pos = maximum whatever and then redraw
+	return 0;
+}
+
+static LRESULT
+Display_OnVScroll(HWND hwnd, WPARAM wParam)
+{
+	SCROLLINFO si;
+	int nPos;
+
+	si.cbSize = sizeof(si);
+	si.fMask  = SIF_POS | SIF_RANGE | SIF_TRACKPOS;
+	GetScrollInfo(hwnd, SB_VERT, &si);
+
+	switch(LOWORD(wParam))
+	{
+		case SB_PAGEUP:
+			nPos = si.nPos - 50;
+			break;
+		case SB_PAGEDOWN:
+			nPos = si.nPos + 50;
+			break;
+		case SB_LINEUP:
+			nPos = si.nPos - 10;
+			break;
+		case SB_LINEDOWN:
+			nPos = si.nPos + 10;
+			break;
+//		case SB_THUMBTRACK:
+		case SB_THUMBPOSITION:
+			nPos = si.nTrackPos;
+			break;
+		default:
+			nPos = si.nPos;
+	}
+
+	nPos = max(nPos, si.nMin);
+	nPos = min(nPos, si.nMax);
+	if (nPos != si.nPos)
+	{
+		ScrollWindowEx(hwnd, 0, -(nPos - si.nPos), NULL, NULL, NULL, NULL, SW_INVALIDATE);
+		si.cbSize = sizeof(si);
+		si.nPos = nPos;
+		si.fMask  = SIF_POS;
+		SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
+		UpdateWindow(hwnd);
+	}
+	return 0;
+}
+
+static LRESULT
+Display_SetTypeFace(HWND hwnd, LPARAM lParam)
+{
+	DISPLAYDATA* pData;
+	HDC hDC;
+	RECT rect;
+	SCROLLINFO si;
+
+	/* Set the new type face name */
+	pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+	snwprintf(pData->szTypeFaceName, MAX_TYPEFACENAME, (WCHAR*)lParam);
+
+	/* Calculate new page dimensions */
+	hDC = GetDC(hwnd);
+	pData->nHeight = Display_DrawText(hDC, pData, 0, FALSE);
+	ReleaseDC(hwnd, hDC);
+
+	/* Set the vertical scrolling range and page size */
+	GetClientRect(hwnd, &rect);
+	si.cbSize = sizeof(si);
+	si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;
+	si.nMin   = 0;
+	si.nMax   = pData->nHeight;
+	si.nPage  = rect.bottom;
+	si.nPos   = 0;
+	si.nTrackPos = 0;
+	SetScrollInfo(hwnd, SB_VERT, &si, TRUE); 
+
+	return 0;
+}
+
+static LRESULT
+Display_SetString(HWND hwnd, LPARAM lParam)
+{
+	DISPLAYDATA* pData;
+
+	pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+	snwprintf(pData->szString, MAX_STRING, (WCHAR*)lParam);
+
+	// FIXME: redraw the window
+
+	return 0;
+}
+
+static LRESULT
+Display_OnDestroy(HWND hwnd)
+{
+	DISPLAYDATA* pData;
+
+	/* Free the data structure */
+	pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+	free(pData);
+
+	return 0;
+}
+
+LRESULT CALLBACK
+DisplayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    switch (message)
+    {
+		case WM_CREATE:
+			return Display_OnCreate(hwnd);
+
+		case WM_PAINT:
+			return Display_OnPaint(hwnd);
+
+		case WM_SIZE:
+			return Display_OnSize(hwnd);
+
+		case WM_VSCROLL:
+			return Display_OnVScroll(hwnd, wParam);
+
+		case FVM_SETTYPEFACE:
+			return Display_SetTypeFace(hwnd, lParam);
+
+		case FVM_SETSTRING:
+			return Display_SetString(hwnd, lParam);
+
+        case WM_DESTROY:
+			return Display_OnDestroy(hwnd);
+
+        default:
+            return DefWindowProc (hwnd, message, wParam, lParam);
+    }
+
+    return 0;
+}
+

Added: trunk/rosapps/fontview/display.h
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/display.h?rev=26834&view=auto
==============================================================================
--- trunk/rosapps/fontview/display.h (added)
+++ trunk/rosapps/fontview/display.h Sat May 19 05:33:27 2007
@@ -1,0 +1,18 @@
+#ifndef _DISPLAY_H
+#define _DISPLAY_H
+
+/* Messages for the display class */
+#define FVM_SETTYPEFACE WM_USER
+#define FVM_SETSTRING (WM_USER + 1)
+
+/* Size restrictions */
+#define MAX_STRING 100
+#define MAX_TYPEFACENAME 32
+#define MAX_FORMAT 20
+
+extern const WCHAR g_szFontDisplayClassName[];
+
+/* Public function */
+BOOL Display_InitClass(HINSTANCE hInstance);
+
+#endif // _DISPLAY_H

Added: trunk/rosapps/fontview/fontview.c
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/fontview.c?rev=26834&view=auto
==============================================================================
--- trunk/rosapps/fontview/fontview.c (added)
+++ trunk/rosapps/fontview/fontview.c Sat May 19 05:33:27 2007
@@ -1,0 +1,316 @@
+/*
+ *	fontview
+ *
+ *	fontview.c
+ *
+ *	Copyright (C) 2007	Timo Kreuzer <timo <dot> kreuzer <at> reactos <dot> org>
+ *
+ *	This program 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 2 of the License, or
+ *	(at your option) any later version.
+ *
+ *	This program 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, write to the Free Software
+ *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "fontview.h"
+
+HINSTANCE g_hInstance;
+WCHAR g_szTitle[MAX_LOADSTRING];
+WCHAR g_szTypeFaceName[MAX_TYPEFACENAME];
+static const WCHAR g_szFontViewClassName[] = L"FontViewWClass";
+
+/* Tye definition for the GetFontResourceInfo function */
+typedef BOOL (WINAPI *PGFRI)(LPCWSTR, DWORD *, LPWSTR, DWORD);
+
+DWORD
+FormatString(
+	DWORD dwFlags,
+	HINSTANCE hInstance,
+	DWORD dwStringId,
+	DWORD dwLanguageId,
+	LPWSTR lpBuffer,
+	DWORD nSize,
+	va_list* Arguments
+)
+{
+	DWORD dwRet;
+	int len;
+	WCHAR Buffer[1000];
+
+	len = LoadStringW(hInstance, dwStringId, (LPWSTR)Buffer, 1000);
+
+	if (len)
+	{
+		dwFlags |= FORMAT_MESSAGE_FROM_STRING;
+		dwFlags &= ~(FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_FROM_SYSTEM);
+		dwRet = FormatMessageW(dwFlags, Buffer, 0, dwLanguageId, lpBuffer, nSize, Arguments);
+		return dwRet;
+	}
+	return 0;
+}
+
+static void
+ErrorMsgBox(HWND hParent, DWORD dwCaptionID, DWORD dwMessageId, ...)
+{
+	HMODULE hModule;
+	HLOCAL hMemCaption = NULL;
+	HLOCAL hMemText = NULL;
+	va_list args;
+
+	hModule = GetModuleHandle(NULL);
+
+	va_start(args, dwMessageId);
+	FormatString(FORMAT_MESSAGE_ALLOCATE_BUFFER,
+	              NULL, dwMessageId, 0, (LPWSTR)&hMemText, 0, &args);
+	va_end(args);
+
+	FormatString(FORMAT_MESSAGE_ALLOCATE_BUFFER,
+	              NULL, dwCaptionID, 0, (LPWSTR)&hMemCaption, 0, NULL);
+
+	MessageBoxW(hParent, hMemText, hMemCaption, MB_ICONERROR);
+
+	LocalFree(hMemCaption);
+	LocalFree(hMemText);
+}
+
+int WINAPI 
+WinMain (HINSTANCE hThisInstance,
+         HINSTANCE hPrevInstance,
+         LPSTR lpCmdLine,
+         int nCmdShow)
+{
+	int argc;
+	WCHAR** argv;
+	DWORD dwSize;
+	HWND hMainWnd;
+	MSG msg;
+	WNDCLASSEXW wincl;
+
+	g_hInstance = hThisInstance;
+
+	/* Get unicode command line */
+	argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+	if (argc < 2)
+	{
+		ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_BADCMD, argv[1]);
+		return -1;
+	}
+
+	/* Try to add the font resource */
+	if (!AddFontResourceW(argv[1]))
+	{
+		ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);
+		return -1;
+	}
+
+	/* Load the GetFontResourceInfo function from gdi32.dll */
+	HINSTANCE hDLL = LoadLibraryW(L"GDI32.DLL");
+	PGFRI GetFontResourceInfoW = (PGFRI)GetProcAddress(hDLL, "GetFontResourceInfoW");
+
+	/* Get the font name */
+	dwSize = sizeof(g_szTypeFaceName);
+	if (!GetFontResourceInfoW(argv[1], &dwSize, g_szTypeFaceName, 1))
+	{
+		ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);
+		return -1;
+	}
+
+	if (!Display_InitClass(hThisInstance))
+	{
+		ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOCLASS);
+		return -1;
+	}
+
+	/* The main window class */
+	wincl.cbSize = sizeof (WNDCLASSEX);
+	wincl.style = CS_DBLCLKS;
+	wincl.lpfnWndProc = MainWndProc;
+	wincl.cbClsExtra = 0;
+	wincl.cbWndExtra = 0;
+	wincl.hInstance = hThisInstance;
+	wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
+	wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
+	wincl.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
+	wincl.lpszMenuName = NULL;
+	wincl.lpszClassName = g_szFontViewClassName;
+	wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
+
+	/* Register the window class, and if it fails quit the program */
+	if (!RegisterClassExW (&wincl))
+	{
+		ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOCLASS);
+		return 0;
+	}
+
+	/* The class is registered, let's create the main window */
+	hMainWnd = CreateWindowExW(
+				0,						/* Extended possibilites for variation */
+				g_szFontViewClassName,	/* Classname */
+				g_szTitle,				/* Title Text */
+				WS_OVERLAPPEDWINDOW,	/* default window */
+				CW_USEDEFAULT,			/* Windows decides the position */
+				CW_USEDEFAULT,			/* where the window ends up on the screen */
+				544,					/* The programs width */
+				375,					/* and height in pixels */
+				HWND_DESKTOP,			/* The window is a child-window to desktop */
+				NULL,					/* No menu */
+				hThisInstance,			/* Program Instance handler */
+				NULL					/* No Window Creation data */
+			);
+	ShowWindow (hMainWnd, nCmdShow);
+
+	/* Main message loop */
+	while (GetMessage (&msg, NULL, 0, 0))
+	{
+		TranslateMessage(&msg);
+		DispatchMessage(&msg);
+	}
+
+	RemoveFontResourceW(argv[1]);
+
+	return msg.wParam;
+}
+
+static LRESULT
+MainWnd_OnCreate(HWND hwnd)
+{
+	WCHAR szQuit[MAX_BUTTONNAME];
+	WCHAR szPrint[MAX_BUTTONNAME];
+	WCHAR szString[MAX_STRING];
+	HWND hDisplay, hButtonQuit, hButtonPrint;
+
+	/* create the display window */
+	hDisplay = CreateWindowExW(
+				0,						/* Extended style */
+				g_szFontDisplayClassName,	/* Classname */
+				L"",				/* Title text */
+				WS_CHILD | WS_VSCROLL| WS_VISIBLE,	/* Window style */
+				0,						/* X-pos */
+				HEADER_SIZE,			/* Y-Pos */
+				550,					/* Width */
+				370-HEADER_SIZE,		/* Height */
+				hwnd,					/* Parent */
+				(HMENU)IDC_DISPLAY,		/* Identifier */
+				g_hInstance,			/* Program Instance handler */
+				NULL					/* Window Creation data */
+			);
+
+	/* Init the display window wit the font name */
+	LoadStringW(g_hInstance, IDS_STRING, szString, MAX_STRING);
+
+	SendMessage(hDisplay, FVM_SETSTRING, 0, (LPARAM)szString);
+	SendMessage(hDisplay, FVM_SETTYPEFACE, 0, (LPARAM)g_szTypeFaceName);
+	/* Create the quit button */
+	LoadStringW(g_hInstance, IDS_QUIT, szQuit, MAX_BUTTONNAME);
+	hButtonQuit = CreateWindowExW(
+				0,						/* Extended style */
+				L"button",				/* Classname */
+				szQuit,					/* Title text */
+				WS_CHILD | WS_VISIBLE,	/* Window style */
+				BUTTON_POS_X,			/* X-pos */
+				BUTTON_POS_Y,			/* Y-Pos */
+				BUTTON_WIDTH,			/* Width */
+				BUTTON_HEIGHT,			/* Height */
+				hwnd,					/* Parent */
+				(HMENU)IDC_QUIT,		/* Identifier */
+				g_hInstance,			/* Program Instance handler */
+				NULL					/* Window Creation data */
+			);
+	SendMessage(hButtonQuit, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);
+
+	/* Create the print button */
+	LoadStringW(g_hInstance, IDS_PRINT, szPrint, MAX_BUTTONNAME);
+	hButtonPrint = CreateWindowExW(
+				0,						/* Extended style */
+				L"button",				/* Classname */
+				szPrint,				/* Title text */
+				WS_CHILD | WS_VISIBLE,	/* Window style */
+				450,					/* X-pos */
+				BUTTON_POS_Y,			/* Y-Pos */
+				BUTTON_WIDTH,			/* Width */
+				BUTTON_HEIGHT,			/* Height */
+				hwnd,					/* Parent */
+				(HMENU)IDC_PRINT,		/* Identifier */
+				g_hInstance,			/* Program Instance handler */
+				NULL					/* Window Creation data */
+			);
+	SendMessage(hButtonPrint, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);
+
+	return 0;
+}
+
+static LRESULT
+MainWnd_OnSize(HWND hwnd)
+{
+	RECT rc;
+
+	GetClientRect(hwnd, &rc);
+	MoveWindow(GetDlgItem(hwnd, IDC_PRINT), rc.right - BUTTON_WIDTH - BUTTON_POS_X, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, TRUE);
+	MoveWindow(GetDlgItem(hwnd, IDC_DISPLAY), 0, HEADER_SIZE, rc.right, rc.bottom - HEADER_SIZE, TRUE);
+
+	return 0;
+}
+
+static LRESULT
+MainWnd_OnPaint(HWND hwnd)
+{
+	HDC hDC;
+	PAINTSTRUCT ps;
+	RECT rc;
+
+	hDC = BeginPaint(hwnd, &ps);
+	GetClientRect(hwnd, &rc);
+	rc.top = HEADER_SIZE - 2;
+	rc.bottom = HEADER_SIZE;
+	FillRect(hDC, &rc, GetStockObject(GRAY_BRUSH));
+	EndPaint(hwnd, &ps);
+	return 0;
+}
+
+LRESULT CALLBACK
+MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    switch (message)
+    {
+		case WM_CREATE:
+			return MainWnd_OnCreate(hwnd);
+
+		case WM_PAINT:
+			return MainWnd_OnPaint(hwnd);
+
+		case WM_SIZE:
+			return MainWnd_OnSize(hwnd);
+
+		case WM_COMMAND:
+			switch(LOWORD(wParam))
+			{
+				case IDC_QUIT:
+					PostQuitMessage (0);	/* send a WM_QUIT to the message queue */
+					break;
+
+				case IDC_PRINT:
+					MessageBox(hwnd, TEXT("This function is unimplemented"), TEXT("Unimplemented"), MB_OK);
+					break;
+			}
+			break;
+
+        case WM_DESTROY:
+            PostQuitMessage (0);	/* send a WM_QUIT to the message queue */
+            break;
+
+        default:					/* for messages that we don't deal with */
+            return DefWindowProc (hwnd, message, wParam, lParam);
+    }
+
+    return 0;
+}
+
+/* EOF */

Added: trunk/rosapps/fontview/fontview.h
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/fontview.h?rev=26834&view=auto
==============================================================================
--- trunk/rosapps/fontview/fontview.h (added)
+++ trunk/rosapps/fontview/fontview.h Sat May 19 05:33:27 2007
@@ -1,0 +1,21 @@
+#include <windows.h>
+
+#include "resource.h"
+#include "display.h"
+
+#define MAX_LOADSTRING 50
+#define MAX_BUTTONNAME 30
+
+#define HEADER_SIZE 37
+#define BUTTON_POS_X 6
+#define BUTTON_POS_Y 8
+#define BUTTON_WIDTH 72
+#define BUTTON_HEIGHT 21
+
+#define IDC_QUIT 1001
+#define IDC_PRINT 1002
+#define IDC_DISPLAY 1003
+
+LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
+
+BOOL LoadFont(LPWSTR lpCmdLine);

Added: trunk/rosapps/fontview/fontview.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/fontview.rbuild?rev=26834&view=auto
==============================================================================
--- trunk/rosapps/fontview/fontview.rbuild (added)
+++ trunk/rosapps/fontview/fontview.rbuild Sat May 19 05:33:27 2007
@@ -1,0 +1,11 @@
+<module name="fontview" type="win32gui" installbase="system32" installname="fontview.exe">
+	<include base="fontview">.</include>
+	<define name="__USE_W32API" />
+	<library>gdi32</library>
+	<library>user32</library>
+	<library>shell32</library>
+	<library>kernel32</library>
+	<file>fontview.c</file>
+	<file>display.c</file>
+	<file>fontview.rc</file>
+</module>

Added: trunk/rosapps/fontview/fontview.rc
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/fontview.rc?rev=26834&view=auto
==============================================================================
--- trunk/rosapps/fontview/fontview.rc (added)
+++ trunk/rosapps/fontview/fontview.rc Sat May 19 05:33:27 2007
@@ -1,0 +1,10 @@
+
+
+#include "lang/de-DE.rc"
+
+STRINGTABLE DISCARDABLE
+{
+	IDS_CHARSLOWER, "abcdefghijklmnopqrstuvmxyz"
+	IDS_CHARSUPPER, "ABCDEFGHIJKLMNOPQRSTUVMXYZ"
+	IDS_SPECIALCHARS, "0123456789.:,;(*!?')"
+}

Added: trunk/rosapps/fontview/lang/de-DE.rc
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/lang/de-DE.rc?rev=26834&view=auto
==============================================================================
--- trunk/rosapps/fontview/lang/de-DE.rc (added)
+++ trunk/rosapps/fontview/lang/de-DE.rc Sat May 19 05:33:27 2007
@@ -1,0 +1,18 @@
+
+#include "windows.h"
+#include "../resource.h"
+
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+
+STRINGTABLE DISCARDABLE
+{
+	IDS_QUIT, "Fertig"
+	IDS_PRINT, "Drucken"
+	IDS_STRING, "Franz jagt im komplett verwahrlosten Taxi quer durch Bayern. 1234567890"
+	IDS_ERROR, "Fehler"
+	IDS_ERROR_NOMEM, "Es steht nicht genügend Speicher zur Verfügung."
+	IDS_ERROR_NOFONT, "Die angegebene Datei %1 ist keine gültige Schriftartendatei."
+	IDS_ERROR_NOCLASS, "Fehler beim initialisieren der Fensterklasse."
+	IDS_ERROR_BADCMD, "Keine Schriftartendatei angegeben.\nSyntax:\n  fontview.exe <Schriftdatei>"
+}
+

Added: trunk/rosapps/fontview/lang/en-US.rc
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/lang/en-US.rc?rev=26834&view=auto
==============================================================================
--- trunk/rosapps/fontview/lang/en-US.rc (added)
+++ trunk/rosapps/fontview/lang/en-US.rc Sat May 19 05:33:27 2007
@@ -1,0 +1,18 @@
+
+#include "windows.h"
+#include "../resource.h"
+
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+
+STRINGTABLE DISCARDABLE
+{
+	IDS_QUIT, "Quit"
+	IDS_PRINT, "Print"
+	IDS_STRING, "Jackdaws love my big sphinx of quartz. 123456890"
+	IDS_ERROR, "Error"
+	IDS_ERROR_NOMEM, "There's not enough memory to complete the operation."
+	IDS_ERROR_NOFONT, "The file %1 ist not a valid font file."
+	IDS_ERROR_NOCLASS, "Could not initialize window class."
+	IDS_ERROR_BADCMD, "No font file given.\nSyntax:\n  fontview.exe <font file>"
+}
+

Added: trunk/rosapps/fontview/resource.h
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/resource.h?rev=26834&view=auto
==============================================================================
--- trunk/rosapps/fontview/resource.h (added)
+++ trunk/rosapps/fontview/resource.h Sat May 19 05:33:27 2007
@@ -1,0 +1,15 @@
+
+#define IDS_ERROR 100
+#define IDS_ERROR_NOMEM 101
+#define IDS_ERROR_NOFONT 102
+#define IDS_ERROR_NOCLASS 103
+#define IDS_ERROR_BADCMD 104
+
+#define IDS_QUIT 500
+#define IDS_PRINT 501
+#define IDS_STRING 502
+
+#define IDS_CHARSLOWER 700
+#define IDS_CHARSUPPER 701
+#define IDS_SPECIALCHARS 702
+




More information about the Ros-diffs mailing list