Example #1
0
void DialogPacket::closeEvent(QCloseEvent* event)
{
    if (OnExit())
        event->accept();
    else
        event->ignore();
}
void Designer::OnKeyDown(SDL_Keycode sym, SDL_Keymod mod)
{
	WombatEngine::OnKeyDown(sym, mod);

	switch(sym)
	{
	case SDLK_ESCAPE:
		if(MainMap != nullptr)
		{
			SaveGame("");
		}

		OnExit();

		break;

	case SDLK_RIGHT:
		MainCamera->CameraRotation = (Rotation)((MainCamera->CameraRotation + 1)%4);
		TileSelector->CameraRotation = MainCamera->CameraRotation;
		break;

	case SDLK_LEFT:
		if(MainCamera->CameraRotation == 0)
		{
			MainCamera->CameraRotation = (Rotation)(3);
		}
		else
		{
			MainCamera->CameraRotation = (Rotation)((MainCamera->CameraRotation - 1)%4);
		}
		TileSelector->CameraRotation = MainCamera->CameraRotation;
		break;
	}
};
void CDlgFailureDiagonostic::OnLButtonUp(UINT nFlags, CPoint point) 
{
	for(int i=0;i<enCtrCount;i++)
	{
		if(m_Item[i].nState==BTN_STATE_DOWN)
		{
			m_Item[i].nState = BTN_STATE_NORMAL;
			
			switch( i )
			{
			case 0:
				{
					//CDlgJ1939Diagnostic dlg;
					//dlg.DoModal();
				}
				break;
			case 1:
				break;
			case 2: 
				OnExit();
				break;
			default:
				break;
			}
		}
	}
	
	Invalidate();
	ReleaseCapture();
	CDialogBase::OnLButtonUp(nFlags, point);
}
Example #4
0
CodeLiteLLDBApp::~CodeLiteLLDBApp()
{
    wxDELETE( m_networkThread );
    wxDELETE( m_lldbProcessEventThread );
    m_replySocket.reset(NULL);
    OnExit();
}
Example #5
0
void KGWin32App::Exit()
{
    int nRetCode = false;

    OnExit();

    if (m_hWnd)
    {
        nRetCode = DestroyWindow(m_hWnd);
        KGLOG_CHECK_ERROR(nRetCode);

        m_hWnd = NULL;
    }

    ExitClass();

    for (int nIndex = 0; nIndex < EVENT_TOTAL; ++nIndex)
    {
        if (m_Events[nIndex])
        {
            CloseHandle(m_Events[nIndex]);
            m_Events[nIndex] = NULL;
        }
    }

    m_hInstance = NULL;
    m_szTitle[0] = '\0';
}
Example #6
0
// Work around a bug in wxWidgets 2.8.x which fails 
// to call OnExit() when Windows is shut down. This
// is supposed to be fixed in wxWidgets 2.9.x.
//
void CBOINCGUIApp::OnEndSession(wxCloseEvent& ) {
    s_bSkipExitConfirmation = true;

    CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
    wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, wxID_EXIT);
    // The event loop has already been stopped,
    // so we must call OnExit directly
    pFrame->OnExit(evt);
    OnExit();
}
Example #7
0
extern "C" void __cdecl mainCRTStartup()
{
    // TODO: set argc/argv
    //int argc = _ConvertCommandLineToArgcArgv( );

    OnStart();
    int ret = main(0, NULL, 0);
    OnExit();
    ExitProcess(ret);
}
Example #8
0
	void App::OnKeyUp(SDL_KeyboardEvent keyBoardEvent)
	{
		switch (keyBoardEvent.keysym.scancode)
		{
		case SDL_SCANCODE_ESCAPE:
			OnExit();
			break;
		default:
			//DO NOTHING
			break;
		}
	}
	LauncherWindow::LauncherWindow(QWidget* parent)
		: QMainWindow(parent),
		_mousePressed(false),
		_mousePosition(QPoint())
	{
		setWindowFlags(Qt::FramelessWindowHint);
		setFixedSize(WIDTH, HEIGHT);

		this->statusBar()->setSizeGripEnabled(false);

		QLabel* _version = new QLabel(QString("Launcher v%1.%2.%3")
						.arg(VixenLauncher_VERSION_MAJOR)
						.arg(VixenLauncher_VERSION_MINOR)
						.arg(VixenLauncher_VERSION_BUILD));
		_version->setAlignment(Qt::AlignLeft);

		QLabel* _copyright = new QLabel("© 2015 Matt Guerrette");
		_copyright->setAlignment(Qt::AlignRight);

		this->statusBar()->addWidget(_version, 0);
		this->statusBar()->addWidget(_copyright, 1);


		_playButton = new QPushButton(tr("Play"));
		_playButton->setObjectName(tr("PlayButton"));

		_optionsButton = new QPushButton(tr("Options"));
		_optionsButton->setObjectName(tr("OptionsButton"));

		_exitButton = new QPushButton(tr("Exit"));
		_exitButton->setObjectName(tr("ExitButton"));

		QVBoxLayout* _buttonLayout = new QVBoxLayout;
		_buttonLayout->addSpacing(50);
		_buttonLayout->addWidget(_playButton);
		_buttonLayout->addWidget(_optionsButton);
		_buttonLayout->addWidget(_exitButton);

		_mainLayout = new QHBoxLayout;
		_mainLayout->addLayout(_buttonLayout);
		_mainLayout->addSpacing(50);
		_mainLayout->setAlignment(Qt::AlignRight | Qt::AlignTop);



		QWidget* _mainWidget = new QWidget;
		_mainWidget->setLayout(_mainLayout);
		setCentralWidget(_mainWidget);


		connect(_exitButton, SIGNAL(clicked()), SLOT(OnExit()));
	}
Example #10
0
int wxGUIEventLoop::Run()
{
    // event loops are not recursive, you need to create another loop!
    wxCHECK_MSG( !IsRunning(), -1, "can't reenter a message loop" );

    wxEventLoopActivator activate(this);

    gtk_main();

    OnExit();

    return m_exitcode;
}
Example #11
0
//------------------------------------------------------------  main()
//
int main(int argc, char **argv)
{		
	
	if ( !(subject_name = Parser(argc, argv)) ) 		// Parsea la linea de comandos: 	parser.c
		exit (1);			
	
	OnInit();						//Inicializa todo lo inicializable: sdlgl_control.h	
	
	ExperimentSetup(); 				//Configura el experimento
	MainLoop();						//Lanza el experimento propiamente dicho
	ExperimentSave();				//Salva los resultados en un archivo
	
	OnExit();						//Cierra limpiamente todico: sdlgl_control.h
	
	return APPSUCCESS;
}
Example #12
0
void CThread::Action()
{
  try
  {
    OnStartup();
  }
  catch (const XbmcCommons::UncheckedException &e)
  {
    e.LogThrowMessage("OnStartup");
    if (IsAutoDelete())
      return;
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread startup, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete());
    if (IsAutoDelete())
      return;
  }

  try
  {
    Process();
  }
  catch (const XbmcCommons::UncheckedException &e)
  {
    e.LogThrowMessage("Process");
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread process, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete());
  }

  try
  {
    OnExit();
  }
  catch (const XbmcCommons::UncheckedException &e)
  {
    e.LogThrowMessage("OnExit");
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread OnExit, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete());
  }
}
Example #13
0
void CEvent::OnEvent(SDL_Event* Event)
{
  switch(Event->type) {
    case SDL_QUIT: 
      OnExit();			//funzione definita in game.h e implementata in game.cpp che setta a false la variabile running
      break;
      
    case SDL_KEYDOWN:
      if(Event->key.keysym.sym == SDLK_UP || Event->key.keysym.sym == SDLK_DOWN || Event->key.keysym.sym == SDLK_LEFT || Event->key.keysym.sym == SDLK_RIGHT )
	ArrowPressed(Event->key.keysym.sym);
      break;
    
    case SDL_KEYUP:
      if(Event->key.keysym.sym == SDLK_UP || Event->key.keysym.sym == SDLK_DOWN || Event->key.keysym.sym == SDLK_LEFT || Event->key.keysym.sym == SDLK_RIGHT )
	ArrowReleased();
      break;
  }
}
Example #14
0
void wxEventLoopManual::Exit(int rc)
{
    wxCHECK_RET( IsRunning(), _T("can't call Exit() if not running") );

    m_exitcode = rc;
    m_shouldExit = true;

    OnExit();

    // all we have to do to exit from the loop is to (maybe) wake it up so that
    // it can notice that Exit() had been called
    //
    // in particular, do *not* use here calls such as PostQuitMessage() (under
    // MSW) which terminate the current event loop here because we're not sure
    // that it is going to be processed by the correct event loop: it would be
    // possible that another one is started and terminated by mistake if we do
    // this
    WakeUp();
}
KX_BlenderMaterial::~KX_BlenderMaterial()
{
    Material *ma = mMaterial->material;
    // Restore Blender material data
    ma->r = mSavedData.r;
    ma->g = mSavedData.g;
    ma->b = mSavedData.b;
    ma->alpha = mSavedData.a;
    ma->specr = mSavedData.specr;
    ma->specg = mSavedData.specg;
    ma->specb = mSavedData.specb;
    ma->spec = mSavedData.spec;
    ma->ref = mSavedData.ref;
    ma->har = mSavedData.hardness;
    ma->emit = mSavedData.emit;

    // cleanup work
    if (mConstructed)
        // clean only if material was actually used
        OnExit();
}
Example #16
0
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
{
    // Windows will terminate the process soon after we return from
    // WM_ENDSESSION handler or when we delete our last window, so make sure we
    // at least execute our cleanup code before

    // prevent the window from being destroyed when the corresponding wxTLW is
    // destroyed: this will result in a leak of a HWND, of course, but who
    // cares when the process is being killed anyhow
    if ( !wxTopLevelWindows.empty() )
        wxTopLevelWindows[0]->SetHWND(0);

    const int rc = OnExit();

    wxEntryCleanup();

    // calling exit() instead of ExitProcess() or not doing anything at all and
    // being killed by Windows has the advantage of executing the dtors of
    // global objects
    exit(rc);
}
Example #17
0
/**
 * Main entry point for GLUT based programs
 */
int main(int argc, char* argv[])
{
	gltSetWorkingDirectory(argv[0]);

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
	glutInitWindowSize(800, 600);
	glutCreateWindow("Triangle");

	gltShowVersionInfo();

	// Create the menu
	glutCreateMenu(ProcessMenu);
	glutAddMenuEntry("Btn1",1);
	glutAddMenuEntry("Btn2",2);
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	glutReshapeFunc(ChangeSize);
	glutDisplayFunc(RenderScene);
	glutSpecialFunc(SpecialKeys);
	glutKeyboardFunc(KeyPressFunc);

	GLenum err = glewInit();
	if (GLEW_OK != err) {
		fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
		return 1;
	}

	SetupRC();

	glutMainLoop();

	OnExit();

	return 0;
}
Example #18
0
void cEvent::OnEvent(SDL_Event* Event) {
	switch(Event->type) {
		case SDL_ACTIVEEVENT: {
			switch(Event->active.state) {
				case SDL_APPMOUSEFOCUS: {
					if (Event->active.gain)
						OnMouseFocus();
					else
						OnMouseBlur();
					break;
				}
				case SDL_APPINPUTFOCUS: {
					if (Event->active.gain)
						OnInputFocus();
					else
						OnInputBlur();
					break;
				}
				case SDL_APPACTIVE: {
					if (Event->active.gain)
						OnRestore();
					else
						OnMinimize();
					break;
				}
			}
			break;
		}
		case SDL_KEYDOWN: {
			OnKeyDown(Event->key.keysym.sym, Event->key.keysym.mod, Event->key.keysym.unicode);
			break;
		}
		case SDL_KEYUP: {
			OnKeyUp(Event->key.keysym.sym, Event->key.keysym.mod, Event->key.keysym.unicode);
			break;
		}
		case SDL_MOUSEMOTION: {
			OnMouseMove(Event->motion.x, Event->motion.y, Event->motion.xrel, Event->motion.yrel, 
						(Event->motion.state & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0,
						(Event->motion.state & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0, 
						(Event->motion.state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0);
			break;
		}
		case SDL_MOUSEBUTTONDOWN: {
			switch(Event->button.button) {
				case SDL_BUTTON_LEFT: {
					OnLButtonDown(Event->button.x, Event->button.y);
					break;
				}
				case SDL_BUTTON_RIGHT: {
					OnRButtonDown(Event->button.x, Event->button.y);
					break;
				}
				case SDL_BUTTON_MIDDLE: {
					OnMButtonDown(Event->button.x, Event->button.y);
					break;
				}
			}
			break;
		}
		case SDL_MOUSEBUTTONUP: {
			switch(Event->button.button) {
				case SDL_BUTTON_LEFT: {
					OnLButtonUp(Event->button.x, Event->button.y);
					break;
				}
				case SDL_BUTTON_RIGHT: {
					OnRButtonUp(Event->button.x, Event->button.y);
					break;
				}
				case SDL_BUTTON_MIDDLE: {
					OnMButtonUp(Event->button.x, Event->button.y);
					break;
				}
			}
			break;
		}
		case SDL_JOYAXISMOTION: {
			OnJoyAxis(Event->jaxis.which, Event->jaxis.axis, Event->jaxis.value);
			break;
		}
		case SDL_JOYBALLMOTION: {
			OnJoyBall(Event->jball.which, Event->jball.ball, Event->jball.xrel, Event->jball.yrel);
			break;
		}
		case SDL_JOYHATMOTION: {
			OnJoyHat(Event->jhat.which, Event->jhat.hat, Event->jhat.value);
			break;
		}
		case SDL_JOYBUTTONDOWN: {
			OnJoyButtonDown(Event->jbutton.which, Event->jbutton.button);
			break;
		}
		case SDL_JOYBUTTONUP: {
			OnJoyButtonUp(Event->jbutton.which, Event->jbutton.button);
			break;
		}
		case SDL_QUIT: {
			OnExit();
			break;
		}
		case SDL_SYSWMEVENT: {
			//Ignore
			break;
		}
		case SDL_VIDEORESIZE: {
			OnResize(Event->resize.w, Event->resize.h);
			break;
		}
		case SDL_VIDEOEXPOSE: {
			OnExpose();
			break;
		}
		default: {
			OnUser(Event->user.type, Event->user.code, Event->user.data1, Event->user.data2);
			break;
		}
	}
}
Example #19
0
int wxEventLoopManual::Run()
{
    // event loops are not recursive, you need to create another loop!
    wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") );

    // ProcessIdle() and Dispatch() below may throw so the code here should
    // be exception-safe, hence we must use local objects for all actions we
    // should undo
    wxEventLoopActivator activate(wx_static_cast(wxEventLoop *, this));

#if defined(__WXMSW__) && wxUSE_THREADS
    wxRunningEventLoopCounter evtLoopCounter;
#endif // __WXMSW__

    // we must ensure that OnExit() is called even if an exception is thrown
    // from inside Dispatch() but we must call it from Exit() in normal
    // situations because it is supposed to be called synchronously,
    // wxModalEventLoop depends on this (so we can't just use ON_BLOCK_EXIT or
    // something similar here)
#if wxUSE_EXCEPTIONS
    for ( ;; )
    {
        try
        {
#endif // wxUSE_EXCEPTIONS

            // this is the event loop itself
            for ( ;; )
            {
                // give them the possibility to do whatever they want
                OnNextIteration();

                // generate and process idle events for as long as we don't
                // have anything else to do
                while ( !Pending() && (wxTheApp && wxTheApp->ProcessIdle()) )
                    ;

                // if the "should exit" flag is set, the loop should terminate
                // but not before processing any remaining messages so while
                // Pending() returns true, do process them
                if ( m_shouldExit )
                {
                    while ( Pending() )
                        Dispatch();

                    break;
                }

                // a message came or no more idle processing to do, sit in
                // Dispatch() waiting for the next message
                if ( !Dispatch() )
                {
                    // we got WM_QUIT
                    break;
                }
            }

#if wxUSE_EXCEPTIONS
            // exit the outer loop as well
            break;
        }
        catch ( ... )
        {
            try
            {
                if ( !wxTheApp || !wxTheApp->OnExceptionInMainLoop() )
                {
                    OnExit();
                    break;
                }
                //else: continue running the event loop
            }
            catch ( ... )
            {
                // OnException() throwed, possibly rethrowing the same
                // exception again: very good, but we still need OnExit() to
                // be called
                OnExit();
                throw;
            }
        }
    }
#endif // wxUSE_EXCEPTIONS

    return m_exitcode;
}
	bool LynxUserInterfaceModel::OnMenuCommand( uint32_t menuCommandID )
	{
	    bool result = true;

		DoWithTerminationOnException( [&]()
		{
			DoWithFileHandlingErrorReportsToUser( "", [&] ()
			{
				switch( menuCommandID )
				{
					case ID_FILE_LOADSTATESNAPSHOT:       OnLoadStateSnapshot(); break;
					case ID_FILE_SAVESTATESNAPSHOT:       OnSaveStateSnapshot(); break;
					case ID_FILE_RUNTAPFILE:              OnRunTAPFile(); break;
					case ID_FILE_OPENTAPFILE:             OnOpenTAPFile(); break;
					case ID_FILE_INSERTBLANKTAPE:         OnNewAudioTape(); break;
					case ID_FILE_SAVETAPE:                OnSaveTAPFileAs(); break;
					case ID_FILE_REWINDTAPE:              OnRewindAudioTape(); break;
					case ID_FILE_DIRECTORY:               OnTypeTapeDirectoryIntoLynx(); break;
					case ID_FILE_EXIT:                    OnExit(); break;

					case ID_EMULATION_PAUSE:		      OnPause(); break;
					case ID_EMULATION_RESET:		      OnResetEmulation(); break;
					case ID_EMULATION_LYNX48K:		      OnEmulation48K(); break;
					case ID_EMULATION_LYNX96K:		      OnEmulation96K(); break;
					case ID_EMULATION_LYNX96KSCORPION:    OnEmulation96KScorpion(); break;
					case ID_EMULATION_PAUSEAFTERTAPOPERATION:  OnPauseAfterTapLoad(); break;

					case ID_SPEED_SPEED50:                OnSetSpeedPercentage( 50 ); break;
					case ID_SPEED_SPEED100:               OnSetSpeedPercentage( 100 ); break;
					case ID_SPEED_SPEED200:               OnSetSpeedPercentage( 200 ); break;
					case ID_SPEED_SPEED400:               OnSetSpeedPercentage( 400 ); break;
					case ID_SPEED_SPEED800:               OnSetSpeedPercentage( 800 ); break;
					case ID_SPEED_MAXSPEEDCASSETTE:       OnSpeedMaxCassette(); break;
					case ID_SPEED_MAXSPEEDCONSOLE:        OnSpeedMaxConsoleCommands(); break;
					case ID_SPEED_MAXSPEEDALWAYS:         OnSpeedMaxPermanently(); break;

					case ID_SOUND_LISTENTOTAPESOUNDS:     OnListenToTapeSounds(); break;
					case ID_SOUND_RECORDTOFILE:           OnRecordToFile(); break;
					case ID_SOUND_FINISHRECORDING:        OnFinishRecording(); break;
					case ID_SOUND_ENABLE:                 OnEnableDisableSound(); break;

					case ID_TEXT_RECORDLYNXTEXT:                 OnRecordLynxTextToFile(); break;
					case ID_TEXT_STOPRECORDINGLYNXTEXT:          OnFinishRecordingLynxText(); break;
					case ID_TEXT_TYPEINFROMFILE:                 OnTypeInTextFromFile(); break;
					case ID_TEXT_LYNXBASICREMCOMMANDEXTENSIONS:  OnLynxBasicRemCommandExtensions(); break;

					case ID_DISPLAY_FITTOWINDOW:          OnFitToWindow(); break;
					case ID_DISPLAY_SQUAREPIXELS:         OnSquarePixels(); break;
					case ID_DISPLAY_FILLWINDOW:           OnFillWindow(); break;
					case ID_DISPLAY_FULLSCREENENABLE:     OnEnableDisableFullScreen(); break;

					case ID_DISPLAY_COLOURSET_NORMALRGB:            OnChangeColourSet( Jynx::LynxColourSet::NormalRGB ); break;
					case ID_DISPLAY_COLOURSET_GREENONLY:            OnChangeColourSet( Jynx::LynxColourSet::GreenOnly ); break;
					case ID_DISPLAY_COLOURSET_LEVEL9:               OnChangeColourSet( Jynx::LynxColourSet::Level9 ); break;
					case ID_DISPLAY_COLOURSET_BLACKANDWHITETV:      OnChangeColourSet( Jynx::LynxColourSet::BlackAndWhiteTV ); break;
					case ID_DISPLAY_COLOURSET_GREENSCREENMONITOR:   OnChangeColourSet( Jynx::LynxColourSet::GreenScreenMonitor ); break;

					case ID_HELP_ABOUT:                             OnShowTheAboutBox(); break;

					default:
						result = false; // not processed
				}
			} );
		} );

		return result;
	}
void Designer::OnControlEvent(Control* control)
{
	if(control == StartPanel->NewMapButton)
	{
		NewMap();
	}
	else if(control == StartPanel->CancelButton)
	{		
		OnExit();
	}
	else if(control == StartPanel->LoadMapButton)
	{
		LoadGame("");

		MainCamera = new Camera(MainMap, Renderer, 800, 600);
		MainCamera->ShowSelectedTile = true;
		MainCamera->ControlRect.x = 0;
		MainCamera->ControlRect.y = 0;
		ChildControls.insert(ChildControls.begin(), MainCamera);

		selectedTile.Height = 0;
		selectedTile.TileID = 3;
		selectedTile.TileSubID = 0;

		StartPanel->Visible = false;
		FocusedControl = MainCamera;

		TileSelector->Visible = true;
		TabMenu->Visible = true;
		DeleteCB->Visible = true;
		PlayerCB->Visible = true;
		TickingCB->Visible = true;

		Paused = false;
	}
	else if(control == EntityList)
	{
		UpdateEditMode(ENTITY);
	}
	else if(control == TileEntityList)
	{
		UpdateEditMode(TILEENTITY);
	}
	else if(control == TabMenu)
	{
		if(TabMenu->SelectedTab == -1)
		{
			UpdateEditMode(TILE);
		}
	}
	else if(control == DeleteCB)
	{
		if(DeleteCB->Checked)
		{
			UpdateEditMode(DELETE);
		}
		else
		{
			UpdateEditMode(TILE);
		}
	}
	else if(control == PlayerCB)
	{
		if(PlayerCB->Checked)
		{
			UpdateEditMode(PLAYER);
		}
		else
		{
			UpdateEditMode(TILE);
		}
	}
};
void Gevents::OnEvent(SDL_Event* Event) {
    switch(Event->type) {
 
        case SDL_KEYDOWN: {
            OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.scancode);
            break;
        }
 
        case SDL_KEYUP: {
            OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.scancode);
            break;
        }
 
        case SDL_MOUSEMOTION: {
            OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0);
            break;
        }
 
        case SDL_MOUSEBUTTONDOWN: {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonDown(Event->button.x,Event->button.y);
                    OnLButtonDown(Event->button.x, Event->button.y, Event->key.keysym.mod);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonDown(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonDown(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }
 
        case SDL_MOUSEBUTTONUP:    {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonUp(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }
 
        case SDL_JOYAXISMOTION: {
            OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value);
            break;
        }
 
        case SDL_JOYBALLMOTION: {
            OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel);
            break;
        }
 
        case SDL_JOYHATMOTION: {
            OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value);
            break;
        }
        case SDL_JOYBUTTONDOWN: {
            OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button);
            break;
        }
 
        case SDL_JOYBUTTONUP: {
            OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button);
            break;
        }
 
        case SDL_QUIT: {
            OnExit();
            break;
        }
 
        case SDL_SYSWMEVENT: {
            //Ignore
            break;
        }
        
        default: {
            OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2);
            break;
        }
    }
}
Example #23
0
void Event::OnEvent(SDL_Event* Event) {
    switch(Event->type) {
		case SDL_TEXTINPUT:
			{
				OnTextEdit(Event->text.text);
				break;
			}
        case SDL_KEYDOWN: {
            OnKeyDown(Event->key.keysym.sym, (SDL_Keymod)Event->key.keysym.mod);
            break;
        }
 
        case SDL_KEYUP: {
            OnKeyUp(Event->key.keysym.sym, (SDL_Keymod)Event->key.keysym.mod);
            break;
        }
 
        case SDL_MOUSEMOTION: {
            OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0);
            break;
        }
 
        case SDL_MOUSEBUTTONDOWN: {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonDown(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonDown(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonDown(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }
 
        case SDL_MOUSEBUTTONUP:    {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonUp(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }

		case SDL_MOUSEWHEEL:
			{
				if(Event->wheel.y > 0)
				{
					OnMouseWheel(true, false);
				}
				else
				{
					OnMouseWheel(false, true);
				}
				break;
			}
 
        case SDL_JOYAXISMOTION: {
            OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value);
            break;
        }
 
        case SDL_JOYBALLMOTION: {
            OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel);
            break;
        }
 
        case SDL_JOYHATMOTION: {
            OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value);
            break;
        }
        case SDL_JOYBUTTONDOWN: {
            OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button);
            break;
        }
 
        case SDL_JOYBUTTONUP: {
            OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button);
            break;
        }
 
        case SDL_QUIT: {
            OnExit();
            break;
        }
 
        case SDL_SYSWMEVENT: {
            //Ignore
            break;
							 }
        default: {
            OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2);
            break;
        }
    }
}
Example #24
0
void CMobileOpalDlg::OnCancel()
{
  CString msg(MAKEINTRESOURCE(IDS_ASK_EXIT));
  if (MessageBox(msg, NULL, MB_YESNO|MB_ICONQUESTION) == IDYES)
    OnExit();
}
Example #25
0
wxThreadError wxThread::Create()
{
    p_internal->exit_status = Entry();
    OnExit();
    return wxTHREAD_NO_ERROR;
}
Example #26
0
	//! called during the update of the entity
	void MenuContext::Update()
	{
		if(!m_bTransitionInitialized)		
			InitTransition();		

		switch(m_eState)
		{
		case S_Init:
		{
			m_Timer = 0.2f;
			m_eState = S_Transition;

			if (m_bTransitionIn)
			{
				OnEnter();

				if (FadeRenderer::Instance()->GetDestColor() != Color::Zero)
					FadeRenderer::Instance()->StartFade(Color::Black, Color::Zero, m_Timer, false, false);
				else
					m_Timer = -1.0f;
			}
			else
			{
				OnExit();

				if (FadeRenderer::Instance()->GetDestColor() != Color::Black)
					FadeRenderer::Instance()->StartFade(Color::Zero, Color::Black, m_Timer, false, true);
				else
					m_Timer = -1.0f;
			}
		}			
			break;

		case S_Transition:
			if (m_Timer > 0.0f)
			{
				m_Timer -= g_fDeltaTime;
			}
			else
			{
				m_eState = S_Idle;
				if(!m_ContextToSwitchTo.empty())
				{
					auto nextContext = m_ContextToSwitchTo;
					m_ContextToSwitchTo.clear();
					m_bTransitionInitialized = false;
					super::Switch(nextContext.c_str());
					return;
				}
				else if (m_bPopRequested)
				{
					super::Pop();

					UIEvent* pEvent = snew UIEvent();
					pEvent->m_Command = "POPPED";
					EventManager::Instance()->SendEvent(pEvent);
				}
			}			
			break;

		default:
			super::Update();
		}
	}
Example #27
0
void CPaper::Exit()
{
	// TODO: 在此添加命令处理程序代码
	OnExit();
}
Example #28
0
void CpermoDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
	// TODO:  在此添加消息处理程序代码和/或调用默认值
	CPoint p;
	//传递过来的坐标为相对于窗口左上角的坐标,WM_CONTEXTMENU传递过来的是屏幕坐标
	GetCursorPos(&p);//鼠标点的屏幕坐标
	m_Menu.CheckMenuItem(SelectedInterface + START_INDEX, MF_BYCOMMAND | MF_CHECKED); 
	int nID = m_Menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, p.x, p.y, this);
	switch (nID)
	{
	case IDM_TOPMOST:
		OnTopmost();
		break;
	case IDM_GREEN:
		OnGreen();
		break;
	case IDM_BLUE:
		OnBlue();
		break;
	case IDM_BLACK:
		OnBlack();
		break;
	case IDM_RED:
		OnRed();
		break;
	case IDM_ORANGE:
		OnOrange();
		break;
	case IDM_EXIT:
		OnExit();
		break;
	case IDM_AUTOHIDE:
		OnAutoHide();
		break;
	case IDM_SHOWBYHOVER:
		SetShowWay();
		break;
	case IDM_SHOWBYLDOWN:
		SetShowWay();
		break;
	case IDM_TRANS0:
		OnTrans0();
		break;
	case IDM_TRANS10:
		OnTrans10();
		break;
	case IDM_TRANS20:
		OnTrans20();
		break;
	case IDM_TRANS30:
		OnTrans30();
		break;
	case IDM_TRANS40:
		OnTrans40();
		break;
	case IDM_TRANS50:
		OnTrans50();
		break;
	case IDM_TRANS60:
		OnTrans60();
		break;
	case IDM_TRANS70:
		OnTrans70();
		break;
	case IDM_TRANS80:
		OnTrans80();
		break;
	case IDM_TRANS90:
		OnTrans90();
		break;
	case IDM_FONTSIZE12:
		SetFontSize(12);
		break;
	case IDM_FONTSIZE13:
		SetFontSize(13);
		break;
	case IDM_FONTSIZE14:
		SetFontSize(14);
		break;
	case IDM_FONTSIZE15:
		SetFontSize(15);
		break;
	case IDM_FONTSIZE16:
		SetFontSize(16);
		break;
	case IDM_FONTSIZE17:
		SetFontSize(17);
		break;
	case IDM_FONTSIZE18:
		SetFontSize(18);
		break;
	case IDM_AUTOSTART:
		SetAutoRun();
		break;
	case IDM_SHOWNETINFO:
		ShowNetInfo();
		break;
	case 0:
		return;
	default:
		{m_Menu.CheckMenuItem(SelectedInterface + START_INDEX, MF_BYCOMMAND | MF_UNCHECKED);
		SelectedInterface = nID - START_INDEX; }
		break;
	}

	CDialog::OnRButtonDown(nFlags, point);
}
Example #29
0
int KGWin32App::Init(HINSTANCE hInstance, LPCSTR szAppName, int nIcon)
{
    int nRetCode = false;
    int nResult = false;
    BOOL bInitClass = FALSE;
    BOOL bInitWindow = FALSE;
    BOOL bInit = FALSE;

    m_nIcon = nIcon;
    m_hInstance = hInstance;

    strncpy_s(m_szTitle, szAppName, _TRUNCATE);
    strncpy_s(m_szClass, szAppName, _TRUNCATE);
    strncat_s(m_szClass, "_Class", _TRUNCATE);

    m_Events[EVENT_TIMER] = CreateWaitableTimer(NULL, FALSE, NULL);
    m_Events[EVENT_RENDER] = CreateEvent(NULL, FALSE, FALSE, NULL);

    nRetCode = InitClass();
    KGLOG_PROCESS_ERROR(nRetCode);

    bInitClass = TRUE;

    nRetCode = InitWindow();
    KGLOG_PROCESS_ERROR(nRetCode);

    bInitWindow = TRUE;

    nRetCode = OnInit();
    KGLOG_PROCESS_ERROR(nRetCode);

    bInit = TRUE;

    nResult = true;
Exit0:
    if (!nResult)
    {
        if (bInit)
        {
            OnExit();
        }

        if (bInitWindow)
        {
            nRetCode = DestroyWindow(m_hWnd);
            KGLOG_CHECK_ERROR(nRetCode);

            m_hWnd = NULL;
        }

        if (bInitClass)
        {
            ExitClass();
        }

        for (int nIndex = 0; nIndex < EVENT_TOTAL; ++nIndex)
        {
            if (m_Events[nIndex])
            {
                CloseHandle(m_Events[nIndex]);
                m_Events[nIndex] = NULL;
            }
        }

        m_hInstance = NULL;
        m_szTitle[0] = '\0';
    }
    return nResult;
}
Example #30
0
void ChatDialog::Notify(TNotifyUI& msg)
{
	if (_tcsicmp(msg.sType, _T("windowinit")) == 0)
	{
		OnPrepare(msg);
	}
	else if (_tcsicmp(msg.sType, _T("killfocus")) == 0)
	{
	}
	else if (_tcsicmp(msg.sType, _T("click")) == 0)
	{
		if (_tcsicmp(msg.pSender->GetName(), kCloseButtonControlName) == 0)
		{
			OnExit(msg);
		}
		else if (_tcsicmp(msg.pSender->GetName(), kMinButtonControlName) == 0)
		{

			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);

		}
		else if (_tcsicmp(msg.pSender->GetName(), kMaxButtonControlName) == 0)
		{

			SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);

		}
		else if (_tcsicmp(msg.pSender->GetName(), kRestoreButtonControlName) == 0)
		{

			SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);

		}
		else if (_tcsicmp(msg.pSender->GetName(), kFontButtonControlName) == 0)
		{
			CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName));
			if (pFontbar != NULL)
				pFontbar->SetVisible(!pFontbar->IsVisible());
		}
		else if (_tcsicmp(msg.pSender->GetName(), kEmotionButtonControlName) == 0)
		{
			POINT pt = {0};
			CDuiRect rcEmotionBtn = msg.pSender->GetPos();
			CDuiRect rcWindow;
			GetWindowRect(m_hWnd, &rcWindow);

			pt.y = rcWindow.top + rcEmotionBtn.top;
			pt.x = rcWindow.left + rcEmotionBtn.left;
			//emotion_list_window_.SelectEmotion(pt);
			new CEmotion(this,pt);
		}
		else if (_tcsicmp(msg.pSender->GetName(), kSendButtonControlName) == 0)
        {
			CRichEditUI* pRichEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kInputRichEditControlName));
			CRichEditUI* pViewEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kViewRichEditControlName));
			if( pRichEdit == NULL ) return;
			pRichEdit->SetFocus();
			CDuiString sText = pRichEdit->GetTextRange(0, pRichEdit->GetTextLength());
			//CDuiString sText=pRichEdit->GetEditGifStr();
		    if( sText.IsEmpty() ) 
				return;

			int textlen = sText.GetLength();

			if (textlen > 512)
			{  
				pViewEdit->SetTextColor(RGB(255,0,0));
				pViewEdit->SetText(_T("错误!发送数据的长度不能超过512字节。")); 
			}
			else
			{
				int imNum = friend_.id;
				TCHAR sendmesg[513] = {0};


				_stprintf_s(sendmesg,512,_T("%s"),sText.GetData());
				int len = strlen(sendmesg);

				if (len !=textlen)
				{
					pViewEdit->SetTextColor(RGB(255,0,0));
					pViewEdit->SetText(_T("警告!发送数据的长度和计算的不同。")); 
				}
				frame_wnd_->m_pTcpCommunication->SendMsg(MSG_TYPE_FRIEND,imNum,sendmesg,textlen);
				//显示在
				SendMsg(g_myself_info.nick_name,sText);
				pRichEdit->SetText(_T(""));
                //test
				//CDuiString strbmp;
				//strbmp.Format("c:\\1.gif");
				//pRichEdit->InsertGif(strbmp);
			}

		}
	}
    else if( _tcsicmp(msg.sType, _T("return")) == 0 ) 
    {
        if (_tcsicmp(msg.pSender->GetName(), kInputRichEditControlName) == 0)
        {
			CRichEditUI* pRichEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kInputRichEditControlName));
			CRichEditUI* pViewEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kViewRichEditControlName));
			if( pRichEdit == NULL ) return;
			pRichEdit->SetFocus();
			CDuiString sText = pRichEdit->GetTextRange(0, pRichEdit->GetTextLength());
			if( sText.IsEmpty() ) 
				return;

			int textlen = sText.GetLength();

			if (textlen > 512)
			{  
				pViewEdit->SetTextColor(RGB(255,0,0));
				pViewEdit->SetText(_T("错误!发送数据的长度不能超过512字节。")); 
			}
			else
			{
				int imNum = friend_.id;
				TCHAR sendmesg[513] = {0};
                 
				
				_stprintf_s(sendmesg,512,_T("%s"),sText.GetData());
                int len = strlen(sendmesg);

				if (len !=textlen)
				{
					pViewEdit->SetTextColor(RGB(255,0,0));
					pViewEdit->SetText(_T("警告!发送数据的长度和计算的不同。")); 
				}
				frame_wnd_->m_pTcpCommunication->SendMsg(MSG_TYPE_FRIEND,imNum,sendmesg,textlen);
				//显示在
				SendMsg(g_myself_info.nick_name,sText);
				pRichEdit->SetText(_T(""));
			}
        }
    }
	else if (_tcsicmp(msg.sType, _T("timer")) == 0)
	{
		return OnTimer(msg);
	}
	else if (_tcsicmp(msg.sType, _T("selectchanged")) == 0)
	{
		if (_tcsicmp(msg.pSender->GetName(), kColorButtonControlName) == 0)
		{
			CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName));
			if (pFontbar != NULL)
			{
				POINT pt = {0};
				CDuiRect rcFontbar = pFontbar->GetPos();
				CDuiRect rcColorBtn = msg.pSender->GetPos();
				CDuiRect rcWindow;
				GetWindowRect(m_hWnd, &rcWindow);

				pt.y = rcWindow.top + rcFontbar.top;
				pt.x = rcWindow.left + rcColorBtn.left + static_cast<LONG>(rcColorBtn.right - rcColorBtn.left / 2);
				
			     new CColorPicker((ChatDialog*)this, pt);
			
			}
		}
		else if (_tcsicmp(msg.pSender->GetName(), kBoldButtonControlName) == 0)
		{
			COptionUI* bold_button = static_cast<COptionUI*>(msg.pSender);
			if (bold_button != NULL)
			{
				bold_ = bold_button->IsSelected();
				FontStyleChanged();
			}
		}
		else if (_tcsicmp(msg.pSender->GetName(), kItalicButtonControlName) == 0)
		{
			COptionUI* italic_button = static_cast<COptionUI*>(msg.pSender);
			if (italic_button != NULL)
			{
				italic_ = italic_button->IsSelected();
				FontStyleChanged();
			}
		}
		else if (_tcsicmp(msg.pSender->GetName(), KUnderlineButtonControlName) == 0)
		{
			COptionUI* underline_button = static_cast<COptionUI*>(msg.pSender);
			if (underline_button != NULL)
			{
				underline_ = underline_button->IsSelected();
				FontStyleChanged();
			}
		}
	}
	else if (_tcsicmp(msg.sType, _T("itemselect")) == 0)
	{
		if (_tcsicmp(msg.pSender->GetName(), kFontTypeControlName) == 0)
		{
			CComboUI* font_type = static_cast<CComboUI*>(msg.pSender);
			if (font_type != NULL)
			{
				font_face_name_ = font_type->GetText();
				FontStyleChanged();
			}
		}
		else if (_tcsicmp(msg.pSender->GetName(), kFontSizeControlName) == 0)
		{
			CComboUI* font_size = static_cast<CComboUI*>(msg.pSender);
			if (font_size != NULL)
			{
				font_size_ = _ttoi(font_size->GetText());
				FontStyleChanged();
			}
		}
	}
}