After the AppUI is constructed, I simply don't know where the code flow goes.
What I looking for, maybe, is that once the application starts the AppUI is constructed and it has an event handler that gets a application_start_event where I can easily call controller-method or any method. What I don't know is how actually this can be done!
I had a look but didn't find what I was looking for. In fact timers aren't the issue.
Switching between containers is.
Essentially I want to have the codeflow come to AppUI::controller() somehow.
I thought that I would have an event "start-app" generated from my AppUI's constructor and "start-app" would call AppUI::Controller() which could do everything I want to be doing. Is that possible? What API's Should I use?
Basically, after a AppUI has be instantiated, where does the code flow go till any event is generated. Is there a defualt first event that is generated everytime an application starts up?
should I do this in AppUi::HandleForegroundEventL()?
I have been trying to frame this question for long and failing. I hope this describes my problem better. It's basically about designing applications and such, I think.
class Menu: public CCoeControl {
...
public:
Draw();
offerkeyevents()//This handles events and calls updates display methods, also it sets variables in AppUI
...}
class Splash: public CCoeControl{
...
public:
Draw()//Draws a bitmap on screen
MyTimerL();//Runs a timer for 3secs
OfferKeyEvents();
...}
class AppUIublic CEikAppUI{
public:
TInt8 iGameState;//State Variable
ConstructL()//Instantiates Splash container.
HandleCommand();//Only handling Exit here
}
I don't want to instantiate both objects in ConstructL of AppUI. How do I manage my Menu and Splash from AppUI? Is it even the recommended way - Managing containers from AppUI (the design idea came naturally to me and I don't know abotu MVC). If not how else can i model my application, without losing all my hair?
if you don't know about MCV, then it is better not to care too much about it and handle everything as you feel best.
Anyway, I think you would be better off if you would read the first post again, since it works completely nicely. Basically in your AppUi constructL you just construct the splash add it to the stak and start the times. Then the system will nicely draw the splash and the timer will be in bakground counting its expiry time.
Meanwhile all menu commands will be handled by your AppUi command handler and keys will go to the splash container (since it is in the stack and the most upper one)
Then when your timer expires you take the splash out from the stack delete the splash (set the pointer to it to NULL also), construct your app container and add it to the stack.
Now the menu commands are still going to the AppUi command handler and keys will now go to the new container.
Hardly nicely. Nothing is drawn What am I doing wrong?
Something undesired is happening. The system blocks on WaitForRequest and nothing is drawn on the screen!!!
void CAppUi::ConstructL(){
BaseConstructL();
iSplashContainer = CSplashContainer::NewL(ApplicationRect());
AddToStackL(iSplashContainer);
iSplashContainer->MyTimer1L();
//Run Timer;
RTimer timer;// The asynchronous timer and ...
TRequestStatus timerStatus;// ... its associated request status
timer.CreateLocal();// Always created for this thread.
// issue and wait for single request
timer.After(timerStatus,5000000);// wait 3 second
User::WaitForRequest(timerStatus);// wait for request to complete
timer.Close();// close timer
//Timer Over
iMenuContainer = CMenuContainer::NewL(ApplicationRect());
if(iSplashContainer){
iEikonEnv->RemoveFromStack(iSplashContainer);
delete iSplashContainer;
iSplashContainer = NULL;
}
AddToStackL(iMenuContainer);
it would really work and also work nicely, if you just would read the posts and do accordingly .....
in case you prefer doing it your way, then I can't really be too much on assistance here and you better figure it out by your self.
Anyway, I'll explain the thing again (third time), you need to construct the timer in a way that it will call callback function when it expires, not as you have made it currently, since it will block and no drawing can be done while it is blocking, so please read the eralier posts and try again.
I made a new Timer of type CPeriodic, which as you would know is a non-blocking timer. Everything is working, nicely
My initial problem of calling CAppUI:GameController() is also, solved. The timer registers gamecontroller as it's callback. So I have the control in gamecontroller from where I can "rule the world".
Many Thanks. This has been, for whatever it's worth, a big break through.