Exemplo n.º 1
0
bool EViacamApp::OnInit()
{     	
	// Call default behaviour
	if (!wxApp::OnInit()) return false;

/* ////@begin EViacamApp initialisation */
	// Remove the comment markers above and below this block
	// to make permanent changes to the code.

#if wxUSE_XPM
	wxImage::AddHandler(new wxXPMHandler);
#endif
#if wxUSE_LIBPNG
	wxImage::AddHandler(new wxPNGHandler);
#endif
#if wxUSE_LIBJPEG
	wxImage::AddHandler(new wxJPEGHandler);
#endif
#if wxUSE_GIF
	wxImage::AddHandler(new wxGIFHandler);
#endif		
/* ////@end EViacamApp initialisation */

// Set up globals
#ifndef NDEBUG
	// Assume project runs from src/ 
	eviacam::SetDataDir(wxGetCwd() + _T("/../doc/"));
#else
	eviacam::SetDataDir(wxStandardPaths::Get().GetDataDir());
#endif
	
	// Initialize sockets support
	// Note: (Workaround for implementation limitation for wxWidgets up to 2.5.x) 
	// If you want to use sockets or derived classes such as wxFTP in a secondary 
	// thread, call wxSocketBase::Initialize() (undocumented) from the main thread 
	// before creating any sockets - in wxApp::OnInit for example. 
	// See http://wiki.wxwidgets.org/wiki.pl?WxSocket or 
	// http://www.litwindow.com/knowhow/knowhow.html for more details.
	wxSocketBase::Initialize();

	m_pController= new CViacamController();
	assert (m_pController);
	if (!m_pController->Initialize()) 
	{
		OnExit();
		return false;
	}
	else return true;
}
Exemplo n.º 2
0
BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
    switch (dwReason)
    {
        case DLL_PROCESS_ATTACH:
            OnStartup();
            break;

        case DLL_PROCESS_DETACH:
            OnExit();
            break;
    }

    return TRUE;
}
Exemplo n.º 3
0
/// Handles an entity leaving the Trigger area.
void RPG_Trigger::ProcessExit(VisBaseEntity_cl* entity)
{
  // check if this entity is in inside the trigger.
  int foundIndex = m_insideEntities.Find(entity);

  if(foundIndex > -1)
  {
    m_insideEntities.RemoveAt(foundIndex);

    OnExit(entity);
    if(m_onExitSource)
      m_onExitSource->TriggerAllTargets();
    TriggerScriptEvent("OnExit", "*o", entity);
  }
}
Exemplo n.º 4
0
void KG3DAnimationTagContainer::Clear()
{
	OnExit();

	SAFE_RELEASE(m_pClip);
    for (size_t i = 0; i < m_vecTags.size(); i++)
    {
        SAFE_DELETE(m_vecTags[i].pTag)
    }

	m_vecTags.clear();
    m_szAnimationName[0] = '\0';
    m_bModifyFlag = FALSE;
	m_IsLoaded = FALSE;
}
Exemplo n.º 5
0
// Handles left click in main menu
void CApp::MenuClick(int mX, int mY)
{
    if(mY > 157 && mY < 213 && mX > 204 && mX < 398)
    {
        AIenabled = true;
        GameState = GAME_STATE_RUNNING;
    }
    if(mY > 273 && mY < 329 && mX > 204 && mX < 398)
    {
        AIenabled = false;
        GameState = GAME_STATE_RUNNING;
    }
    if(mY > 410 && mY < 466 && mX > 204 && mX < 398)
        OnExit();
}
Exemplo n.º 6
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;
}
Exemplo n.º 7
0
void CThread::Action()
{
  try
  {
    OnStartup();
  }
  catch (const XbmcCommons::UncheckedException &e)
  {
    e.LogThrowMessage("OnStartup");
    if (IsAutoDelete())
      return;
  }
  catch (...)
  {
    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 (...)
  {
    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 (...)
  {
    LOG(LOGERROR, "%s - thread %s, Unhandled exception caught in thread OnExit, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete());
  }
}
Exemplo n.º 8
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;
  }
}
Exemplo n.º 9
0
void wxEventLoop::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, we do *not* use PostQuitMessage() here because we're not
    // sure that WM_QUIT is going to be processed by the correct event loop: it
    // is possible that another one is started before this one has a chance to
    // process WM_QUIT
    ::PostMessage(NULL, WM_NULL, 0, 0);
}
Exemplo n.º 10
0
int wxQtEventLoopBase::DoRun()
{
    int ret;

    // This is placed inside of a loop to take into account nested event loops
    while ( !m_shouldExit )
    {
        // This will print Qt warnins if app already started:
        // "QCoreApplication::exec: The event loop is already running"
        // TODO: check the loopLevel (nested) like in wxGTK
        ret = QCoreApplication::exec();
        // process pending events (if exec was started previously)
        // TODO: use a real new QEventLoop() ?
        QCoreApplication::processEvents();
    }
    OnExit();
    return ret;
}
Exemplo n.º 11
0
void wxThread::Exit(ExitCode status)
{
    wxASSERT_MSG( This() == this,
                  _T("wxThread::Exit() can only be called in the context of the same thread") );

    if ( m_isDetached )
    {
        // from the moment we call OnExit(), the main program may terminate at
        // any moment, so mark this thread as being already in process of being
        // deleted or wxThreadModule::OnExit() will try to delete it again
        ScheduleThreadForDeletion();
    }

    // don't enter m_critsect before calling OnExit() because the user code
    // might deadlock if, for example, it signals a condition in OnExit() (a
    // common case) while the main thread calls any of functions entering
    // m_critsect on us (almost all of them do)
    OnExit();

    // delete C++ thread object if this is a detached thread - user is
    // responsible for doing this for joinable ones
    if ( m_isDetached )
    {
        // FIXME I'm feeling bad about it - what if another thread function is
        //       called (in another thread context) now? It will try to access
        //       half destroyed object which will probably result in something
        //       very bad - but we can't protect this by a crit section unless
        //       we make it a global object, but this would mean that we can
        //       only call one thread function at a time :-(
        DeleteThread(this);
        pthread_setspecific(gs_keySelf, 0);
    }
    else
    {
        m_critsect.Enter();
        m_internal->SetState(STATE_EXITED);
        m_critsect.Leave();
    }

    // terminate the thread (pthread_exit() never returns)
    pthread_exit(status);

    wxFAIL_MSG(_T("pthread_exit() failed"));
}
Exemplo n.º 12
0
void cEvent::OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode)
{
    switch (sym)
    {
        case SDLK_ESCAPE:
        {
            OnExit();
            break;
        }
        case SDLK_RETURN:
        {
            if ((SDLK_RETURN) && ((mod & KMOD_ALT)))
            {
                sysToggleFullScreen();
            }
            break;
        }
    }
}
Exemplo n.º 13
0
    // sets the "should exit" flag and wakes up the loop so that it terminates
    // soon
    void ScheduleExit( int rc = 0 )
    {
        wxCHECK_RET( IsInsideRun(), wxT("can't call ScheduleExit() 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();
    }
Exemplo n.º 14
0
void CreditsWnd::Render() {
    if (!m_render)
        return;
    GG::Pt ul = UpperLeft(), lr = LowerRight();
    if (m_display_list_id == 0) {
        // compile credits
        m_display_list_id = glGenLists(1);
        glNewList(m_display_list_id, GL_COMPILE);
        DrawCredits(ul.x + m_cx, ul.y + m_cy, ul.x + m_cx + m_cw, ul.y + m_cy + m_ch, 255);
        glEndList();
    }
    //time passed
    int ticks_delta = GG::GUI::GetGUI()->Ticks() - m_start_time + m_scroll_offset;

    //draw background
    GG::FlatRectangle(ul, lr, GG::FloatClr(0.0f, 0.0f, 0.0f, 0.5f), GG::CLR_ZERO, 0);

    glPushAttrib(GL_ALL_ATTRIB_BITS);
    glPushMatrix();

    // define clip area
    glEnable(GL_SCISSOR_TEST);
    glScissor(Value(ul.x + m_cx), Value(GG::GUI::GetGUI()->AppHeight() - lr.y), m_cw, m_ch);

    // move credits
    glTranslatef(0, m_co - ticks_delta/40, 0);

    if (m_display_list_id != 0) {
        // draw credits using prepared display list
        // !!! in order for the display list to be valid, the font object (m_font) may not be destroyed !!!
        glCallList(m_display_list_id);
    } else {
        // draw credits directly
        DrawCredits(ul.x + m_cx, ul.y + m_cy, ul.x + m_cx + m_cw, ul.y + m_cy + m_ch, 255);
    }

    glPopMatrix();
    glPopAttrib();

    //check if we are done
    if (m_credits_height + m_ch < m_co + ticks_delta/40)
        OnExit();
}
Exemplo n.º 15
0
//---------------------------------------------------------------------------
void CApp::OnEvent(SDL_Event *Event) {

    switch(Event->type) {

        case SDL_QUIT: {
            OnExit();
            break;
        }

        case SDL_KEYDOWN: {
            Snake->onEvent(Event);
            break;
        }

        default: {
            break;
        }
    }
}
Exemplo n.º 16
0
bool CamuleGuiApp::OnInit()
{
	amuledlg = NULL;

	if ( !CamuleApp::OnInit() ) {
		return false;
	}

	// Create the Core timer
	core_timer = new CTimer(this,ID_CORE_TIMER_EVENT);
	if (!core_timer) {
		AddLogLineCS(_("Fatal Error: Failed to create Core Timer"));
		OnExit();
	}

	// Start the Core and Gui timers

	// Note: wxTimer can be off by more than 10% !!!
	// In addition to the systematic error introduced by wxTimer, we are losing
	// timer cycles due to high CPU load.  I've observed about 0.5% random loss of cycles under
	// low load, and more than 6% lost cycles with heavy download traffic and/or other tasks
	// in the system, such as a video player or a VMware virtual machine.
	// The upload queue process loop has now been rewritten to compensate for timer errors.
	// When adding functionality, assume that the timer is only approximately correct;
	// for measurements, always use the system clock [::GetTickCount()].
	core_timer->Start(CORE_TIMER_PERIOD);
	amuledlg->StartGuiTimer();

#ifdef __WXMAC__
	// This tells the OS to notice the ed2kHelperScript.app inside aMule.app.
	// ed2kHelperScript.app describes itself (Info.plist) as handling ed2k URLs.
	// So, from then on the OS will know to pass ed2k URLs to the helper app.
	CFURLRef ed2kHelperUrl = CFBundleCopyAuxiliaryExecutableURL(
		CFBundleGetMainBundle(), CFSTR("ed2kHelperScript.app"));
	if (ed2kHelperUrl) {
		LSRegisterURL(ed2kHelperUrl, true);
		CFRelease(ed2kHelperUrl);
	}
#endif

	return true;
}
Exemplo n.º 17
0
Arquivo: Game.cpp Projeto: Fahv/Snake
void Game::events(SDL_Event* event)
{
     switch(event->type)
     {
        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_QUIT:{
            OnExit();
            break;

        }
     }
}
Exemplo n.º 18
0
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();
}
Exemplo n.º 19
0
void cEvent::OnEvent(SDL_Event* Event)
{
    switch (Event->type)
    {
        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_QUIT:
        {
            OnExit();
            break;
        }
    }
}
Exemplo n.º 20
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);
}
Exemplo n.º 21
0
void CDlgDriveEconomy::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:
				{
				}
				break;
			case 1:
				{
					CDlgOilConsum dlg;
					dlg.DoModal();
				}
				break;
			case 2:
				{
					CDlgDriveEconomySetting dlg;
					dlg.DoModal();
				}
				break;
			case 3: 
				OnExit();
				break;
			default:
				break;
			}
		}
	}
	
	Invalidate();
	ReleaseCapture();
	CDialogBase::OnLButtonUp(nFlags, point);
}
Exemplo n.º 22
0
	void Game::OnKeyUp(SDL_KeyboardEvent keyBoardEvent)
	{
		switch (keyBoardEvent.keysym.scancode)
		{
		case SDL_SCANCODE_W:
			up = false;
			break;
		case SDL_SCANCODE_A:
			left = false;
			break;
		case SDL_SCANCODE_D:
			right = false;
			break;
		case SDL_SCANCODE_R:
			RespawnPlayer();
			break;
		case SDL_SCANCODE_TAB:
			if (m_player)
			{
				m_player->ChangeShip();
			}
			break;
		case SDL_SCANCODE_SPACE:
			//
			if (m_player)
			{
				CreateBullet();
			}
			break;
		case SDL_SCANCODE_ESCAPE:
			OnExit();
			break;
		default:
			//DO NOTHING
			break;
		}
	}
Exemplo n.º 23
0
void CThread::Stop(int exitCode)
{
	if ( !IsAlive() )
		return;

	if ( GetCurrentCThread() == this )
	{
		m_result = exitCode;
		if ( !( m_flags & SUPPORT_STOP_PROTOCOL ) )
		{
			OnExit();
			g_pCurThread = NULL;

#ifdef _WIN32
			CloseHandle( m_hThread );
			m_hThread = NULL;
#endif
			m_threadId = 0;
		}
		throw exitCode;
	}
	else
		AssertMsg( 0, "Only thread can stop self: Use a higher-level protocol");
}
Exemplo n.º 24
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;
}
Exemplo n.º 25
0
void wxExecuteData::OnStart(int pid_)
{
    wxCHECK_RET( wxTheApp,
                 wxS("Ensure wxTheApp is set before calling wxExecute()") );

    // Setup the signal handler for SIGCHLD to be able to detect the child
    // termination.
    //
    // Notice that SetSignalHandler() is idempotent, so it's fine to call
    // it more than once with the same handler.
    wxTheApp->SetSignalHandler(SIGCHLD, OnSomeChildExited);


    // Remember the child PID to be able to wait for it later.
    pid = pid_;

    // Also save it in wxProcess where it will be accessible to the user code.
    if ( process )
        process->SetPid(pid);

    // Add this object itself to the list of child processes so that
    // we can check for its termination the next time we get SIGCHLD.
    ms_childProcesses[pid] = this;

    // However, if the child exited before we finished setting up above,
    // we may have already missed its SIGCHLD.  So we also do an explicit
    // check here before returning.
    int exitcode;
    if ( CheckForChildExit(pid, &exitcode) )
    {
        // Handle its termination if it did.
        // This call will implicitly remove it from ms_childProcesses
        // and, if running asynchronously, it will delete itself.
        OnExit(exitcode);
    }
}
Exemplo n.º 26
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;
		}
	}
}
Exemplo n.º 27
0
LRESULT
CCPApp::OnCplMsg(HWND hWndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
{
	LRESULT lResult = 1;

	switch ( uMsg )
	{
		case CPL_INIT:
		{
			lResult = OnInit();
		}
		break;

		case CPL_EXIT:
		{
			lResult = OnExit();
		}
		break;

		case CPL_GETCOUNT:
		{      
    		lResult = m_applets.GetCount();
  		}
		break;

		default:
  		{
    		POSITION pos = m_applets.FindIndex( lParam1 );
			check( pos );

			CCPApplet * applet = m_applets.GetAt( pos );  
			check( applet );

    		switch (uMsg)
    		{
      			case CPL_INQUIRE:
      			{
					LPCPLINFO pInfo = reinterpret_cast<LPCPLINFO>(lParam2);
        			lResult = applet->OnInquire(pInfo);
				}  
        		break;

				case CPL_NEWINQUIRE:
      			{
        			LPNEWCPLINFO pInfo = reinterpret_cast<LPNEWCPLINFO>(lParam2);
					lResult = applet->OnNewInquire(pInfo);
				}  
        		break;

				case CPL_STARTWPARMS:
      			{
        			CWnd * pParentWnd = CWnd::FromHandle(hWndCPl);
        			LPCTSTR lpszExtra = reinterpret_cast<LPCTSTR>(lParam2);
        			lResult = applet->OnStartParms(pParentWnd, lpszExtra);
				}
				break;

				case CPL_DBLCLK:
				{
        			CWnd* pParentWnd = CWnd::FromHandle(hWndCPl);
        			lResult = applet->OnRun(pParentWnd);
				}
        		break;

				case CPL_SELECT:
				{
        			lResult = applet->OnSelect();
				}
				break;

				case CPL_STOP:
				{
					lResult = applet->OnStop();
				}
				break;

				default:
				{
					// TRACE(_T("Warning, Received an unknown control panel message:%d\n"), uMsg);
					lResult = 1;
				}
				break;
    		}
  		}
		break;
	}

	return lResult;
}
Exemplo n.º 28
0
/* The SM does not know anything about the system. This way it can be tested on a
 * different C compiler very easily.
 */
void TrafficLightSM(int event) {
	int NextState = State;
	switch (State) {
	case R_RY:
		switch (event) {
		case TICK:
			NextState = R_G;
			break;
		default:
			break;
		}
		break;
	case R_G:
		switch (event) {
		case TICK:
			NextState = R_Y;
			break;
		default:
			break;
		}
		break;
	case R_Y:
		switch (event) {
		case TICK:
			NextState = RY_R;
			break;
		default:
			break;
		}
		break;
	case RY_R:
		switch (event) {
		case TICK:
			NextState = G_R;
			break;
		default:
			break;
		}
		break;
	case G_R:
		switch (event) {
		case TICK:
			NextState = Y_R;
			break;
		default:
			break;
		}
		break;
	case Y_R:
		switch (event) {
		case TICK:
			NextState = R_RY;
			break;
		default:
			break;
		}
		break;
	default:
		break;
		// The program should never get here !
	}

	if (NextState != State) {
		OnExit(State);
		OnEnter(NextState);
		State = NextState;
	}

	Do(State);
}
Exemplo n.º 29
0
XUILife::~XUILife(void)
{
	OnExit();
}
Exemplo n.º 30
0
void CMobileOpalDlg::OnCancel()
{
  CString msg(MAKEINTRESOURCE(IDS_ASK_EXIT));
  if (MessageBox(msg, NULL, MB_YESNO|MB_ICONQUESTION) == IDYES)
    OnExit();
}