1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
|
/* -*- mode: C++; tab-width: 4 -*- */
/* ===================================================================== *\
Copyright (c) 1998-2001 Palm, Inc. or its subsidiaries.
All rights reserved.
This file is part of the Palm OS Emulator.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
\* ===================================================================== */
#ifndef EmApplication_h
#define EmApplication_h
#include "EmAction.h" // EmActionHandler
#include "EmCommands.h" // EmCommandID
#include "EmDevice.h" // EmDevice
#include "EmFileRef.h" // EmFileRef, EmFileRefList
#include "EmTypes.h" // RAMSizeType
/*
EmApplication is an abstract class for handling Palm OS Emulator
operations that don't require a document (or session) to be open or
running. That is, it deals with the commands that create or open
documents, showing preferences and other dialogs, and quitting the
application. It is responsible for the following commands:
* About Box
* New Session
* Open Session
* Close Session
* Quitting
* Download ROM
* All Preferences dialogs
* Event Playback and Minimization
EmApplication is mostly a cross-platform "code sharing" class. It's
not a true application class in that it doesn't deal with getting
user events, menu selections, or other platform-specific operations.
But once those events and selections are made, the EmApplication
class can be used to *handle* those operations in a cross-platofrm
way. Thus, you will most likely create a sub-class of EmApplication
that deals with user interaction and translate those into cross-
platform operations.
*/
class Chunk;
class EmDocument;
struct Configuration;
class EmApplication : public EmActionHandler
{
public:
EmApplication (void);
virtual ~EmApplication (void);
public:
virtual Bool Startup (int argc, char** argv);
virtual void Shutdown (void);
public:
void HandleStartupActions(void);
Bool HandleCommand (EmCommandID);
void HandleIdle (void);
public:
Bool GetTimeToQuit (void) { return fQuit; }
virtual void SetTimeToQuit (Bool q) { fQuit = q; }
public:
/*
This ramp of functions is responsible for creating new sessions.
They all return a pointer to any document they create. Note that
fDocument could be non-NULL and these functions return NULL if
the user cancelled the closing of the current document.
HandleNewFromUser Presents the dialog asking the user for new
configuration information. Initial dialog
settings can either be provided or fetched
from preferences. HandleNewFromConfig is
called to perform the actual open.
HandleNewFromPref Creates a new session from the configuration
information stored in the "last configuration"
preference. HandleNewFromConfig is called to
perform the actual open.
HandleNewFromROM Presents the dialog asking the user for new
configuration information. Initial dialog
settings are provided from the "last config-
uration" preference and the provided ROM.
HandleNewFromConfig is called to perform the
actual open.
HandleNewFromConfig Creates a new session based on the given
configuration information. First validates
the configuration and throws an exception if
that fails. Then attempts to close any current
session, returning NULL if that operation is
cancelled by the user. Finally, creates the
actual document. This function is the bottle-
neck for all document creation.
*/
EmDocument* HandleNewFromUser (const Configuration*);
EmDocument* HandleNewFromPrefs (void);
EmDocument* HandleNewFromROM (const EmFileRef&);
EmDocument* HandleNewFromConfig (const Configuration&);
EmDocument* HandleNewBound (void);
/*
This ramp of functions is responsible for opening old sessions.
They all return a pointer to any document they open. Note that
fDocument could be non-NULL and these functions return NULL if
the user cancelled the closing of the current document.
HandleNewFromUser Asks the user for a file to open. HandleOpenFromFile
is called to perform the actual open.
HandleOpenFromPrefs Open the session file stored in the "last
session file" preference. HandleOpenFromFile
is called to perform the actual open.
HandleOpenFromFile Opens the given file. First attempts to close
any current session, returning NULL if that
operation is cancelled by the user. Then opens
the actual document. This function is the
bottleneck for all document opening.
*/
EmDocument* HandleOpenFromUser (EmFileType);
EmDocument* HandleOpenFromPrefs (void);
EmDocument* HandleOpenFromFile (const EmFileRef&);
EmDocument* HandleOpenBound (void);
/*
Deal with figuring out what to do with the given files. Parse
them up, figure out what type(s) they are, and determine whether
to open them, create new sessions with them, install them, etc.
*/
void HandleFileList (const EmFileRefList&);
/*
Open the given session/event file for minimization.
*/
void HandleMinimize (const EmFileRef&);
/*
Close a session, writing it out to the given file. If the file
is not specified, just close the file without saving it. Called
in response to ScheduleSessionClose.
*/
void HandleSessionClose (const EmFileRef&);
/*
Quit the emulator, closing any session without saving it. Called
in response to ScheduleQuit.
*/
void HandleQuit (void);
public:
// The following functions schedule actions for the application
// to take the next chance it gets (at idle time).
void ScheduleSessionClose (const EmFileRef&);
void ScheduleQuit (void); // Close Now and Quit
public:
// Command handling functions, called from HandleCommand.
//
// I'd like these to be private, but I build up a static table containing
// references to these functions, thus requiring them to be public.
void DoAbout (EmCommandID);
void DoNew (EmCommandID);
void DoOpen (EmCommandID);
void DoClose (EmCommandID);
void DoQuit (EmCommandID);
void DoDownload (EmCommandID);
void DoPreferences (EmCommandID);
void DoLogging (EmCommandID);
void DoDebugging (EmCommandID);
void DoErrorHandling (EmCommandID);
#if HAS_TRACER
void DoTracing (EmCommandID);
#endif
void DoSkins (EmCommandID);
void DoHostFS (EmCommandID);
void DoBreakpoints (EmCommandID);
void DoReplay (EmCommandID);
void DoMinimize (EmCommandID);
void DoNothing (EmCommandID);
public:
// Bound Poser facilities.
Bool IsBound (void);
Bool IsBoundPartially (void);
Bool IsBoundFully (void);
virtual void BindPoser (Bool /*fullSave*/,
const EmFileRef& /*dest*/) {}
virtual Bool ROMResourcePresent (void) { return false; }
virtual Bool GetROMResource (Chunk&) { return false; }
virtual Bool PSFResourcePresent (void) { return false; }
virtual Bool GetPSFResource (Chunk&) { return false; }
virtual Bool ConfigResourcePresent (void) { return false; }
virtual Bool GetConfigResource (Chunk&) { return false; }
virtual Bool SkinfoResourcePresent (void) { return false; }
virtual Bool GetSkinfoResource (Chunk&) { return false; }
virtual Bool Skin1xResourcePresent (void) { return false; }
virtual Bool GetSkin1xResource (Chunk&) { return false; }
virtual Bool Skin2xResourcePresent (void) { return false; }
virtual Bool GetSkin2xResource (Chunk&) { return false; }
virtual EmDevice GetBoundDevice (void) { return EmDevice (); }
virtual RAMSizeType GetBoundRAMSize (void) { return 0; }
private:
Bool CloseDocument (Bool quitting);
private:
Bool fQuit;
};
extern EmApplication* gApplication;
#endif // EmApplication_h
|