1#ifndef __cxxtest__Win32Gui_h__
2#define __cxxtest__Win32Gui_h__
79 WaitForSingleObject(
_gui, INFINITE );
111 for (
int i = 1;
i < argc; ++
i )
113 if ( !lstrcmpA( argv[
i],
"-minimized" ) )
115 else if ( !lstrcmpA( argv[
i],
"-keep" ) )
117 else if ( !lstrcmpA( argv[
i],
"-title" ) && (
i + 1 < argc) )
172 _windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
174 _windowClass.lpszClassName = TEXT(
"CxxTest Window Class");
187 HMODULE dll = LoadLibraryA(
"comctl32.dll" );
191 typedef void (WINAPI *FUNC)( void );
192 FUNC func = (FUNC)GetProcAddress( dll,
"InitCommonControls" );
220 void setRatios(
unsigned suiteNameRatio,
unsigned suiteTimeRatio,
221 unsigned testNameRatio,
unsigned testTimeRatio,
222 unsigned testsDoneRatio,
unsigned worldTimeRatio )
235 return CreateWindow( className,
NULL, style, 0, 0, 0, 0, parent,
236 (HMENU)
NULL, (HINSTANCE)
NULL, (LPVOID)
this );
249 LONG screenWidth = screen.right - screen.left;
250 LONG screenHeight = screen.bottom - screen.top;
252 LONG xCenter = (screen.right + screen.left) / 2;
253 LONG yCenter = (screen.bottom + screen.top) / 2;
255 LONG windowWidth = (screenWidth * 4) / 5;
256 LONG windowHeight = screenHeight / 10;
257 LONG minimumHeight = 2 * (GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CYFRAME ));
258 if ( windowHeight < minimumHeight )
259 windowHeight = minimumHeight;
262 xCenter - (windowWidth / 2), yCenter - (windowHeight / 2),
263 windowWidth, windowHeight, 0 );
274 return (SystemParametersInfo( SPI_GETWORKAREA,
sizeof(RECT), &area, 0 ) != 0);
279 area.left = area.top = 0;
280 area.right = GetSystemMetrics( SM_CXSCREEN );
281 area.bottom = GetSystemMetrics( SM_CYSCREEN );
307 tick = GetTickCount();
318 while ( BOOL haveMessage = GetMessage( &
message,
NULL, 0, 0 ) )
319 if ( haveMessage != -1 )
326 setUp( window, (LPCREATESTRUCT)lParam );
334 SetWindowLong( window, GWL_USERDATA, (
LONG)
create->lpCreateParams );
350 default:
return DefWindowProc( window,
message, wParam, lParam );
359 LONG width = r.right - r.left;
360 LONG height = r.bottom - r.top;
363 LONG statusHeight = r.bottom - r.top;
364 LONG resizeGripWidth = statusHeight;
365 LONG progressHeight = height - statusHeight;
367 SetWindowPos(
_progressBar, HWND_TOP, 0, 0, width, progressHeight, 0 );
368 SetWindowPos(
_statusBar, HWND_TOP, 0, progressHeight, width, statusHeight, 0 );
391#ifdef PBM_SETBARCOLOR
392 void setColor( BYTE red, BYTE green, BYTE blue )
409 return LoadIcon( (HINSTANCE)
NULL, icon );
414 setCaption( suiteName,
"::", testName,
"()" );
417 void setCaption(
const char *a =
"",
const char *
b =
"",
const char *c =
"",
const char *d =
"" )
419 unsigned length = lstrlenA(
_title ) +
sizeof(
" - " ) +
420 lstrlenA( a ) + lstrlenA(
b ) + lstrlenA( c ) + lstrlenA( d );
423 lstrcatA(
name,
" - " );
459 unsigned total = (GetTickCount() - start) / 1000;
460 unsigned hours = total / 3600;
461 unsigned minutes = (total / 60) % 60;
462 unsigned seconds = total % 60;
465 wsprintfA(
_timeString,
"%u:%02u:%02u", hours, minutes, seconds );
467 wsprintfA(
_timeString,
"%02u:%02u", minutes, seconds );
521 return (
char *)HeapAlloc( GetProcessHeap(), 0,
length );
526 HeapFree( GetProcessHeap(), 0, data );
unsigned failedTests() const
void setCaption(const char *a="", const char *b="", const char *c="", const char *d="")
static LRESULT CALLBACK windowProcedure(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
void progressBarMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
int _statusWidths[STATUS_TOTAL_PARTS]
void setSummaryStatusBar()
void statusBarMessage(UINT message, WPARAM wParam=0, const void *lParam=0)
void setStatusTime(unsigned part, DWORD start)
HWND createWindow(LPCTSTR className, DWORD style, HWND parent=(HWND) NULL)
unsigned _statusOffsets[STATUS_TOTAL_PARTS]
char _strTotalTests[WorldDescription::MAX_STRLEN_TOTAL_TESTS]
char * allocate(unsigned length)
void setStatusParts(LONG width)
void getTotalTests(const WorldDescription &wd)
void setIcon(LPCTSTR icon)
void setRatios(unsigned suiteNameRatio, unsigned suiteTimeRatio, unsigned testNameRatio, unsigned testTimeRatio, unsigned testsDoneRatio, unsigned worldTimeRatio)
void showSuiteName(const char *suiteName)
void enterWorld(const WorldDescription &wd)
void enterGui(int &argc, char **argv)
void getScreenArea(RECT &area)
static void setUp(HWND window, LPCREATESTRUCT create)
void showTestName(const char *testName)
void guiEnterSuite(const char *suiteName)
void initCommonControls()
void parseCommandLine(int argc, char **argv)
void guiEnterTest(const char *suiteName, const char *testName)
void showMainWindow(int mode)
static DWORD WINAPI guiThread(LPVOID parameter)
void getWholeScreenArea(RECT &area)
void deallocate(char *data)
LRESULT handle(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
bool getScreenAreaWithoutTaskbar(RECT &area)
void setColor(BYTE, BYTE, BYTE)
char _statusTestsDone[sizeof("1000000000 of (100%)")+WorldDescription::MAX_STRLEN_TOTAL_TESTS]
void setTestCaption(const char *suiteName, const char *testName)
char _timeString[sizeof("00:00:00")]
void registerWindowClass()
void setStatusPart(unsigned part, const char *text)
HICON loadStandardIcon(LPCTSTR icon)
char * strTotalTests(char *) const
virtual unsigned numTotalTests(void) const =0
static BOOLEAN length(leftv result, leftv arg)
void message(int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
int name
New type name for int.