コード例 #1
0
ファイル: yatlcclc_win32.cpp プロジェクト: mennowo/yatlcclc
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	int tbh, sbh;
	RECT rect;
	INITCOMMONCONTROLSEX InitCtrlEx;
	char strtime[128];

	switch (message)
	{
	case WM_SIZE:
		SendMessage(hWndStatusbar, WM_SIZE, wParam, lParam);
		GetWindowRect(hWndStatusbar, &rect);
		sbh = rect.bottom - rect.top;
		GetWindowRect(hWndToolbar, &rect);
		tbh = rect.bottom - rect.top;
		iBitmapY = tbh;
		iBitmapH = HIWORD(lParam) - sbh - tbh;
		SendMessage(hWndBitmapper, WM_SIZE, wParam, MAKELPARAM(LOWORD(lParam), iBitmapH));
		break;

	case WM_CREATE:


		InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
		InitCtrlEx.dwICC = ICC_BAR_CLASSES;
		InitCommonControlsEx(&InitCtrlEx);
		InitCommonControls();

		hWndToolbar = CreateCoolToolbar(hWnd, hInst);
		CreateAllResources(CGBrushes);

		applicatieprogramma(CIF_INIT);

		CIF_WPS[CIF_PROG_STATUS] = CIF_STAT_REG;
		CIF_KLOK[CIF_DAG] = 1;
		CIF_KLOK[CIF_MAAND] = 1;
		CIF_KLOK[CIF_JAAR] = 2000;

		DisplayParameters();

		BitmapperSetFilename("test.bmp");
		BitmapperControlRegister();


		if (!(hBitmap = (HBITMAP)LoadImage(NULL, "test.bmp"/*(LPCSTR)lpcsPicturePath*/, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)))
		{
			MessageBox(hWnd, TEXT("Bitmap was not found"), TEXT("Bitmap not found"), MB_OK);
			SendMessage(hWnd, WM_CLOSE, NULL, NULL);
		}
		GetObject(hBitmap, sizeof(BITMAP), (LPVOID)&Bitmap);

		hWndStatusbar = CreateStatusBar(hWnd, ID_STATUSBAR, hInst, 4);

		CreateThread(NULL, 0, ApplProc, 0, 0, NULL);

		//		ClientResize(hWnd, Bitmap.bmWidth, Bitmap.bmHeight);

		{
			RECT rcClient, rcWindow;
			POINT ptDiff;
			GetWindowRect(hWndStatusbar, &rect);
			int sbh = rect.bottom - rect.top;
			GetWindowRect(hWndToolbar, &rect);
			int tbh = rect.bottom - rect.top;

			GetWindowRect(hWnd, &rcWindow);
			GetClientRect(hWnd, &rcClient);
			ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
			ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
			MoveWindow(hWnd, rcWindow.left, rcWindow.top, Bitmap.bmWidth + ptDiff.x, Bitmap.bmHeight + ptDiff.y + tbh + sbh, FALSE);
		}
		hWndBitmapper = CreateWindow(BITMAPPER_WC, NULL, WS_CHILD | WS_VISIBLE,
			0, iBitmapY, Bitmap.bmWidth, Bitmap.bmHeight, hWnd, NULL, hInst, NULL);

		/* Get the sizes of the system font, for formatting */
		hdc = GetDC(hWnd);
		memHdc = CreateCompatibleDC(hdc);
		bufBMP = CreateCompatibleBitmap(hdc, Bitmap.bmWidth, Bitmap.bmHeight);

		mainTimer = SetTimer(hWnd, NULL, 5, &TimerProc);

		snprintf(strtime, 128, "Mon %02d-%02d-%04d %02d:%02d:%02d", CIF_KLOK[CIF_DAG], CIF_KLOK[CIF_MAAND], CIF_KLOK[CIF_JAAR], CIF_KLOK[CIF_UUR], CIF_KLOK[CIF_MINUUT], CIF_KLOK[CIF_SECONDE]);
		SendMessage(hWndStatusbar, SB_SETTEXT, MAKEWPARAM(0, SBT_NOBORDERS), (LPARAM)strtime);

		break;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		case IDM_TIME_REALTIME:
		case IDM_TIME_LOWSPEED:
		case IDM_TIME_MIDSPEED:
		case IDM_TIME_HIGHSPEED:
			if (wmId == IDM_TIME_REALTIME) iSpeed = SPEED_RT;
			if (wmId == IDM_TIME_LOWSPEED) iSpeed = SPEED_LO;
			if (wmId == IDM_TIME_MIDSPEED) iSpeed = SPEED_MI;
			if (wmId == IDM_TIME_HIGHSPEED) iSpeed = SPEED_HI;
			SendMessage(hWndToolbar, TB_CHECKBUTTON, (WPARAM)IDM_TIME_REALTIME, MAKELPARAM(iSpeed == SPEED_RT, 0));
			SendMessage(hWndToolbar, TB_CHECKBUTTON, (WPARAM)IDM_TIME_LOWSPEED, MAKELPARAM(iSpeed == SPEED_LO, 0));
			SendMessage(hWndToolbar, TB_CHECKBUTTON, (WPARAM)IDM_TIME_MIDSPEED, MAKELPARAM(iSpeed == SPEED_MI, 0));
			SendMessage(hWndToolbar, TB_CHECKBUTTON, (WPARAM)IDM_TIME_HIGHSPEED, MAKELPARAM(iSpeed == SPEED_HI, 0));
			CheckMenuItem(GetMenu(hWnd), IDM_TIME_REALTIME, iSpeed == SPEED_RT ? MF_CHECKED : MF_UNCHECKED);
			CheckMenuItem(GetMenu(hWnd), IDM_TIME_LOWSPEED, iSpeed == SPEED_LO ? MF_CHECKED : MF_UNCHECKED);
			CheckMenuItem(GetMenu(hWnd), IDM_TIME_MIDSPEED, iSpeed == SPEED_MI ? MF_CHECKED : MF_UNCHECKED);
			CheckMenuItem(GetMenu(hWnd), IDM_TIME_HIGHSPEED, iSpeed == SPEED_HI ? MF_CHECKED : MF_UNCHECKED);
			break;
		//case IDM_SIMULATION:
		//	bSimulating = !bSimulating;
		//	SendMessage(hWndToolbar, TB_CHECKBUTTON, (WPARAM)IDM_SIMULATION, MAKELPARAM(bSimulating, 0));
		//	CheckMenuItem(GetMenu(hWnd), IDM_SIMULATION, bSimulating ? MF_CHECKED : MF_UNCHECKED);
		//	break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
//	case WM_PAINT:
//		hdc = BeginPaint(hWnd, &ps);
//		// TODO: Add any drawing code here...
//		EndPaint(hWnd, &ps);
//		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
コード例 #2
0
ファイル: simple_tui.cpp プロジェクト: AdaCompNUS/despot
int SimpleTUI::run(int argc, char *argv[]) {

  clock_t main_clock_start = clock();
  EvalLog::curr_inst_start_time = get_time_second();

  const char *program = (argc > 0) ? argv[0] : "despot";

  argc -= (argc > 0);
  argv += (argc > 0); // skip program name argv[0] if present

  option::Stats stats(usage, argc, argv);
  option::Option *options = new option::Option[stats.options_max];
  option::Option *buffer = new option::Option[stats.buffer_max];
  option::Parser parse(usage, argc, argv, options, buffer);

  string solver_type = "DESPOT";
  bool search_solver;

  /* =========================
   * Parse required parameters
   * =========================*/
  int num_runs = 1;
  string simulator_type = "pomdp";
  string belief_type = "DEFAULT";
  int time_limit = -1;

  /* =========================================
   * Problem specific default parameter values
*=========================================*/
  InitializeDefaultParameters();

  /* =========================
   * Parse optional parameters
   * =========================*/
  if (options[E_HELP]) {
    cout << "Usage: " << program << " [options]" << endl;
    option::printUsage(std::cout, usage);
    return 0;
  }
  OptionParse(options, num_runs, simulator_type, belief_type, time_limit,
              solver_type, search_solver);

  /* =========================
   * Global random generator
   * =========================*/
  Seeds::root_seed(Globals::config.root_seed);
  unsigned world_seed = Seeds::Next();
  unsigned seed = Seeds::Next();
  Random::RANDOM = Random(seed);

  /* =========================
   * initialize model
   * =========================*/
  DSPOMDP *model = InitializeModel(options);

  /* =========================
   * initialize solver
   * =========================*/
  Solver *solver = InitializeSolver(model, solver_type, options);
  assert(solver != NULL);

  /* =========================
   * initialize simulator
   * =========================*/
  Evaluator *simulator = NULL;
  InitializeEvaluator(simulator, options, model, solver, num_runs,
                      main_clock_start, simulator_type, belief_type, time_limit,
                      solver_type);
  simulator->world_seed(world_seed);

  int start_run = 0;

  /* =========================
   * Display parameters
   * =========================*/
  DisplayParameters(options, model);

  /* =========================
   * run simulator
   * =========================*/
  RunEvaluator(model, simulator, options, num_runs, search_solver, solver,
               simulator_type, main_clock_start, start_run);

  simulator->End();

  PrintResult(num_runs, simulator, main_clock_start);

  return 0;
}
コード例 #3
0
ファイル: hh.cpp プロジェクト: jonmarinello/hammerhead
int main( int argc, char* argv[] )
{
    DisplayCopyrightNotice();

    std::string configFile = "hh.cfg";
    std::string batchBuildId = "";

    CTimeSpan totalTimeSpan;

    enum RunOption
    {
        ApproveUnitTest,
        ExecuteUnitTests,
        ExecuteUnitTestsInBatchBuildMode,
        GenerateConfigFile,
        ViewUnitTestFailures,
        EditUnitTest
    };

    RunOption runOption = ExecuteUnitTests;
    bool verbose = false;

    try
    {
        for ( ;; )
        {
            int c = getopt( argc, argv, "ac:b:gefv?" );
            if (c == -1)
            {
                break;
            }
     
            switch ( c )
            {
                case 'a':
                    runOption = ApproveUnitTest;
                    break;

                case 'c':
                    configFile = optarg;
                    break;

                case 'b':
                    runOption = ExecuteUnitTestsInBatchBuildMode;
                    batchBuildId = optarg;
                    break;

                case 'g':
                    runOption = GenerateConfigFile;
                    break;

                case 'e':
                    runOption = EditUnitTest;
                    break;

                case 'f':
                    runOption = ViewUnitTestFailures;
                    break;

                case 'v':
                    verbose = true;
                    break;

                case '?':
                    DisplayUsage( argv[0] );
                    return RESULT_SUCCESS;
            }
        }
    }
    catch ( HH_CommandLineError& ex )
    {
        std::cout << ex.AsString() << std::endl;
        std::cout << std::endl;
        DisplayUsage( argv[0] );
        return RESULT_ERROR;
    }

    try
    {
        HH_CommandLineNotifier  commandLineNotifier( verbose );

        switch( runOption )
        {
        case ExecuteUnitTests:
            {
                HH_Runtime  runtime( GetIniFile( verbose ), configFile, commandLineNotifier );
                DisplayParameters( runtime, verbose );
                totalTimeSpan = runtime.ExecuteUnitTest( batchBuildId );
                DisplayElapsedTime( totalTimeSpan, verbose );
            }
            break;

        case ExecuteUnitTestsInBatchBuildMode:
            {
                HH_Runtime  runtime( GetIniFile( verbose ), configFile, commandLineNotifier );
                DisplayParameters( runtime, verbose );
                totalTimeSpan = runtime.ExecuteUnitTest( batchBuildId );
                DisplayElapsedTime( totalTimeSpan, verbose );
            }
            break;

        case ApproveUnitTest:
            {
                HH_Runtime  runtime( GetIniFile( verbose ), configFile, commandLineNotifier );
                DisplayParameters( runtime, verbose );
                runtime.ApproveUnitTest();
            }
            break;

        case GenerateConfigFile:
            HH_Runtime::GenerateConfigFile( commandLineNotifier );
            break;

        case ViewUnitTestFailures:
            {
                HH_Runtime  runtime( GetIniFile( verbose ), configFile, commandLineNotifier );
                DisplayParameters( runtime, verbose );
                runtime.ViewUnitTestFailures();
            }
            break;

        case EditUnitTest:
            {
                HH_Runtime  runtime( GetIniFile( verbose ), configFile, commandLineNotifier );
                DisplayParameters( runtime, verbose );
                runtime.EditDotInFile();
            }
            break;
        }
    }
    catch ( HH_Exception& ex )
    {
        HH_UnitTest::LogException( ex );
        DisplayElapsedTime( totalTimeSpan, verbose );
        return RESULT_ERROR;
    }

    return RESULT_SUCCESS;
}