Added RFC 2190 H.263 code as created by Guilhem Tardy and AliceStreet
[pwlib.git] / include / pwlib / applicat.h
blob3a8c45375a3c5708d76635491a7f0fec13229a49
1 /*
2 * applicat.h
4 * GUI application class.
6 * Portable Windows Library
8 * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25 * All Rights Reserved.
27 * Contributor(s): ______________________________________.
29 * $Log$
30 * Revision 1.35 2001/05/22 12:49:32 robertj
31 * Did some seriously wierd rewrite of platform headers to eliminate the
32 * stupid GNU compiler warning about braces not matching.
34 * Revision 1.34 2000/01/10 02:25:01 craigs
35 * Added macro to allow multiple ancestors
37 * Revision 1.33 1999/08/07 07:13:22 robertj
38 * Fixed problems with "balloon help" text popup.
40 * Revision 1.32 1999/03/10 03:49:50 robertj
41 * More documentation adjustments.
43 * Revision 1.31 1999/03/09 08:01:47 robertj
44 * Changed comments for doc++ support (more to come).
46 * Revision 1.30 1999/02/16 08:08:45 robertj
47 * MSVC 6.0 compatibility changes.
49 * Revision 1.29 1998/09/23 06:22:49 robertj
50 * Added open source copyright license.
52 * Revision 1.28 1998/04/07 13:33:22 robertj
53 * Changed startup code to support PApplication class.
55 * Revision 1.27 1997/04/27 05:50:17 robertj
56 * DLL support.
58 * Revision 1.26 1995/12/23 03:43:40 robertj
59 * Changed version numbers.
61 * Revision 1.25 1995/12/10 11:28:21 robertj
62 * Added extra user information to processes and applications.
63 * Changed default default OnAbout() function to have user specified dialog.
65 * Revision 1.24 1995/10/14 14:51:16 robertj
66 * Changed return values to references for efficency.
68 * Revision 1.23 1995/08/24 12:58:57 robertj
69 * Added standard colours for balloon help windows.
71 * Revision 1.22 1995/07/31 12:15:40 robertj
72 * Removed PContainer from PChannel ancestor.
74 * Revision 1.21 1995/04/02 09:27:17 robertj
75 * Added "balloon" help.
77 * Revision 1.20 1995/03/14 12:40:57 robertj
78 * Updated documentation to use HTML codes.
80 * Revision 1.19 1995/02/22 10:50:25 robertj
81 * Changes required for compiling release (optimised) version.
83 * Revision 1.18 1995/02/19 04:08:41 robertj
84 * Added dynamically linked command processing.
86 * Revision 1.17 1994/12/13 12:01:18 robertj
87 * Fixed documentation error.
89 * Revision 1.16 1994/12/05 11:16:43 robertj
90 * Documentation.
91 * Normalised some variable types.
93 * Revision 1.15 1994/11/26 03:41:17 robertj
94 * Added DoContextHelp versions using default help file (MSC bug).
96 * Revision 1.14 1994/11/24 11:48:25 robertj
97 * Documentation.
99 * Revision 1.13 1994/08/23 11:32:52 robertj
100 * Oops
102 * Revision 1.12 1994/08/22 00:46:48 robertj
103 * Added pragma fro GNU C++ compiler.
105 * Revision 1.11 1994/08/21 23:43:02 robertj
106 * Added delayed close of interactors to avoid the "delete this" problem.
108 * Revision 1.10 1994/07/17 10:46:06 robertj
109 * Moved help menu function from application to toplevelwindow.
111 * Revision 1.9 1994/06/25 11:55:15 robertj
112 * Unix version synchronisation.
114 * Revision 1.8 1994/04/03 08:34:18 robertj
115 * Added help and focus functionality.
117 * Revision 1.7 1994/03/07 07:38:19 robertj
118 * Major enhancementsacross the board.
120 * Revision 1.6 1994/01/03 04:42:23 robertj
121 * Mass changes to common container classes and interactors etc etc etc.
123 * Revision 1.5 1993/12/31 06:38:11 robertj
124 * Made inlines optional for debugging purposes.
126 * Revision 1.4 1993/08/27 18:17:47 robertj
127 * Added timer support functions.
129 * Revision 1.3 1993/08/21 01:50:33 robertj
130 * Made Clone() function optional, default will assert if called.
132 * Revision 1.2 1993/07/14 12:49:16 robertj
133 * Fixed RCS keywords.
138 #define _PAPPLICATION
140 #ifdef __GNUC__
141 #pragma interface
142 #endif
145 class PTopLevelWindow;
147 #ifndef PAPPLICATION_ANCESTOR
148 #define PAPPLICATION_ANCESTOR public PProcess
149 #endif
152 ///////////////////////////////////////////////////////////////////////////////
153 // PApplication
155 /**A class to embody a GUI application. There is always exactly one instance
156 of a descendednt of this class in an application. It should be possible to
157 write the application so that this is the only global variable present. All
158 other data is contained within this instance or its member variables or
159 their member variables etc.
161 class PApplication : PAPPLICATION_ANCESTOR
163 PCLASSINFO(PApplication, PProcess);
165 public:
166 /**Create a new application instance.
168 PApplication(
169 const char * manuf = "", /// Name of manufacturer
170 const char * name = "", /// Name of product
171 WORD majorVersion = 1, /// Major version number of the product
172 WORD minorVersion = 0, /// Minor version number of the product
173 CodeStatus status = ReleaseCode, /// Development status of the product
174 WORD buildNumber = 1 /// Build number of the product
177 /** Destroy the application
179 ~PApplication();
182 /**@name Overrides from class PProcess */
183 /**This is the windows application main event loop. A typical application
184 would override this function to perform all application initialisation
185 and then call the ancestor function to execute the event loop.
187 virtual void Main();
189 /**Terminate the application. This will destroy the main window and exit
190 the event loop in Main(). This is usually only used in abnormal abort
191 situations.
193 virtual void Terminate();
196 /**@name New functions for class */
197 /**Get the current processes application object. Note that there can only
198 be one instance of an application class in a program image.
200 @return
201 Pointer to the current application.
203 static PApplication & Current();
205 /**This function is called in the main program execution loop for
206 handling events. This may be overridden to allow operations to be
207 handled after each event that is handled by the system.
209 virtual void PassMainLoop();
211 /**Get the top level window for the application. This will be the first
212 instance of a descendent from \Ref{PTopLevelWindow}.
214 @return
215 pointer to the top level window for the application.
217 PTopLevelWindow * GetWindow() const;
220 /**This enum describes the possible parameter list types that may be passed
221 to the application. The mechanism by which these are passed is platform
222 dependent.
224 enum ParameterTypes {
225 /// The parameters are a list of files to be opened
226 OpenFiles,
227 /// The parameters are a list of files to be printed
228 PrintFiles,
229 /// The parameters are arbitrary strings
230 GeneralParameters
233 /**Get the type of the parameter list. The ParameterTypes values indicate
234 that the parameter list should be parsed as a set of files to be opened
235 or printed, or in the GeneralParameters case it leaves it entirely up
236 to the application to decide what to do. In this case they may be parsed
237 by the \Ref{PArgList} class.
239 @return
240 type of the application arguments
242 ParameterTypes GetParameterType() const;
245 /**Set the menu item string to be used in the system standard "About" menu
246 item. This string is used whenever the SetMenu() function is executed
247 on a \Ref{PTopLevelWindow} class.
249 void SetAboutMenuItemString(
250 const PString & newName /// New menu item title for the "About" function
253 /**Get the menu item string to be used in the system standard "About" menu
254 item. This string is used whenever the SetMenu() function is executed
255 on a \Ref{PTopLevelWindow} class.
257 @return
258 string used for "About" menus.
260 PString GetAboutMenuItemString() const;
262 /**Set the resource ID to be used in the \Ref{OnAbout()} function.
264 void SetAboutDialogID(
265 PRESOURCE_ID newID /// New resource ID for the "About" dialog.
268 /**Get the resource ID to be used in the \Ref{OnAbout()} function.
270 @return
271 Resource ID for "About" dialog.
273 PRESOURCE_ID GetAboutDialogID() const;
275 /**Function which gets called when the about menu item is selected. An
276 application could override this function to display a fancy "About"
277 dialog.
279 The default behaviour is to display the dialog specified by the
280 \Ref{SetAboutDialogID()} function. If this dialog has not been set
281 then a \Ref{PSimpleDialog} with the manufacturer, program name
282 and version is displayed.
284 virtual void OnAbout();
287 /**Set the default help file for the application. This file is used by the
288 DoContextHelp() function in this class.
290 void SetDefaultHelpFile(
291 const PFilePath & name /// Name of help file to be used by application.
294 /**Set the default help file for the application. This file is used by the
295 DoContextHelp() function in this class.
297 @return
298 Name of help file to be used by application.
300 PFilePath GetDefaultHelpFile() const;
302 /**Execute context sensitive help with the specified context key and
303 help file. This will start the platform standard help system to display
304 the help information for the context.
306 void DoContextHelp(
307 const PString & context /// Context string index into the help file
309 void DoContextHelp(
310 PINDEX contextId /// Context numerical index into the help file
312 void DoContextHelp(
313 const PString & context, /// Context string index into the help file
314 const PFilePath & file /// File to search for the context in.
316 void DoContextHelp(
317 PINDEX contextId, /// Context numerical index into the help file
318 const PFilePath & file /// File to search for the context in.
321 /**Do all logic regarding the inflation and deflation of balloon help. The
322 #action# parameter indicates the action to take in the
323 balloon help system.
325 A zero value for #action# indicates that the mouse was moved
326 over the indicated interactor and if it stops moving, a balloon popup
327 is to be displayed.
329 A value for #action# of one indicates that current balloon
330 is to be set to the #interactor# parameter.
332 A value for #action# of two indicates that current balloon
333 is to be returned and no other action taken.
335 This is an internal function and is not normally called by the
336 application.
338 @return
339 The balloon window displayed.
341 PBalloon * DoBalloonHelp(
342 PInteractor * interactor, /// Interactor in which cursor is over.
343 int action = 0 /// Action to take in the balloon help system.
347 /**Find the interactor that is at the specified absolute screen
348 coordinates. The interactor must be owned by the application.
350 @return
351 pointer to interactor at point or NULL if no interactor there.
353 PInteractor * FindInteractor(
354 const PPoint & pt /// Point to check.
355 ) const;
358 /**Get the size of the screen in pixels. Note that on some platforms the
359 "screen" may be made up of smaller screens next to each other, and is
360 not actually rectangular. In this case it returns the largest bounding
361 rectangle of all sub-screens.
363 @return
364 the coordiantes of the screen in pixels.
366 const PRect & GetScreenRect() const;
368 /**Get the size of the primary screen in pixels. This is always the screen
369 that has its origin at 0,0 in multi screen systems.
371 @return
372 the coordiantes of the screen in pixels.
374 const PDim & GetPrimaryScreenSize() const;
376 /**Get the resolution for the screen.
378 @return
379 dots per meter (or inch) in x and y for the screen.
381 const PDim & GetScreenResolution(
382 BOOL imperial = FALSE
383 /// Indicate that the return value is in imperial (TRUE) or metric (FALSE)
384 ) const;
386 /**Get the number of colours that can be simultaneously be displayed on
387 the screen.
389 @return
390 number of colours.
392 long GetScreenColours() const;
394 /**Get the number of bits per pixel that the screen is capable of.
396 @return
397 the depth or number of bits per pixel.
399 PDIMENSION GetScreenDepth() const;
401 /**Get the maximum size of a cursor pixmap in screen pixels.
403 @return
404 width & height of a cursor.
406 const PDim & GetCursorSize() const;
408 /**Get the maximum size of an icon pixmap in screen pixels.
410 @return
411 width & height of an icon.
413 const PDim & GetIconSize() const;
415 /**Get the height of the caption part of a titled window or descendent.
416 This may also be used on \Ref{PDialog} descendents on some platforms.
418 @return
419 height in pixels of caption.
421 PDIMENSION GetTitleHeight() const;
423 /**Get the height of the menu bar in \Ref{PTopLevelWindow} descendent
424 classes.
426 @return
427 height in pixels of the menu bar.
429 PDIMENSION GetMenuHeight() const;
431 /**Get the size of the border for a titled window ie one that may be
432 moved & resized.
434 @return
435 width & height in pixels of the border.
437 const PDim & GetTitledBorderSize() const;
439 /**Get the size of the border for a modal dialog box.
441 @return
442 width & height in pixels of the border.
444 const PDim & GetDlgBorderSize() const;
446 /**Get the size of the border for interactors with borders other than modal
447 dialogs and resizable windows.
449 @return
450 width & height in pixels of the border.
452 const PDim & GetBorderSize() const;
454 /**Get the default size of a main (top level) window.
456 @return
457 width & height in pixels of the window.
459 const PDim & GetMainWindowSize() const;
461 /**Get the default size of all titled windows other than top level windows.
463 @return
464 width & height in pixels of the window.
466 const PDim & GetTitledWindowSize() const;
468 /**Get the size of the horizontal scroll bar.
470 @return
471 height in pixels of the scroll bar.
473 PDIMENSION GetHScrollHeight() const;
475 /**Get the size of the vertical scroll bar.
477 @return
478 width in pixels of the scroll bar.
480 PDIMENSION GetVScrollWidth() const;
482 /**Get the system font which is the default basis for interactor
483 coordinate systems. This is also the initial font used in interactors
484 which will be active when drawing into canvases.
486 @return
487 specification of the system font.
489 const PFont & GetSystemFont() const;
491 /**Get the font which is the default basis for balloon help windows.
493 @return
494 specification of the font.
496 const PFont & GetBalloonFont() const;
498 /**Get the rectangle around a mouse click point that the second click must
499 be within to be detected as a double click. Typically you would do a
500 PtInRect of the second click position within this rectangle that has
501 been offset by the position of the first click.
503 @return
504 rectangle for double click bounds.
506 const PRect & GetDoubleClickRect() const;
508 /**Get the amount of milliseconds that must not have elapsed for the two
509 mouse clicks to called a double click.
511 @return
512 time interval for double click.
514 const PTimeInterval & GetDoubleClickTime() const;
516 /**Get the default colour of all foreground items in interactors.
518 @return
519 colour specification.
521 const PColour & GetWindowFgColour() const;
523 /**Get the default colour of all background items in interactors.
525 @return
526 colour specification.
528 const PColour & GetWindowBkColour() const;
530 /**Get the default colour of active titled window border.
532 @return
533 colour specification.
535 const PColour & GetActiveBorderColour() const;
537 /**Get the default colour of inactive titled window border.
539 @return
540 colour specification.
542 const PColour & GetInactiveBorderColour() const;
544 /**Get the default colour of the window title text in an active window.
546 @return
547 colour specification.
549 const PColour & GetActiveTitleFgColour() const;
551 /**Get the default colour of the window title bar in an active window.
553 @return
554 colour specification.
556 const PColour & GetActiveTitleBkColour() const;
558 /**Get the default colour of the window title text in an inactive window.
560 @return
561 colour specification.
563 const PColour & GetInactiveTitleFgColour() const;
565 /**Get the default colour of the window title bar in an inactive window.
567 @return
568 colour specification.
570 const PColour & GetInactiveTitleBkColour() const;
572 /**Get the default colour of the text in menus or menu bar.
574 @return
575 colour specification.
577 const PColour & GetMenuFgColour() const;
579 /**Get the default colour of the background in menus or menu bar.
581 @return
582 colour specification.
584 const PColour & GetMenuBkColour() const;
586 /**Get the default colour of the text in balloon help windows.
588 @return
589 colour specification.
591 const PColour & GetBalloonFgColour() const;
593 /**Get the default colour of the background in balloon help windows.
595 @return
596 colour specification.
598 const PColour & GetBalloonBkColour() const;
600 /**Get the default colour of the foreground (text) in a standard
601 3 dimensional push button.
603 @return
604 colour specification.
606 const PColour & GetButtonFgColour() const;
608 /**Get the default colour of the background (face) in a standard
609 3 dimensional push button.
611 @return
612 colour specification.
614 const PColour & GetButtonBkColour() const;
616 /**Get the default colour of the lighted edge in a standard 3 dimensional
617 push button.
619 @return
620 colour specification.
622 const PColour & GetButtonLightingColour() const;
624 /**Get the default colour of the shadowed edge in a standard 3 dimensional
625 push button.
627 @return
628 colour specification.
630 const PColour & GetButtonShadowColour() const;
632 /**Get the default colour of the slider section of a scroll bar. The
633 arrows and thumb use the colours of the standard pushbutton.
635 @return
636 colour specification.
638 const PColour & GetScrollBarColour() const;
640 /**Get the default colour of text that is highlighted. Used in the menus
641 menu bars and edit text controls.
643 @return
644 colour specification.
646 const PColour & GetHighlightFgColour() const;
648 /**Get the default colour of the background for text that is highlighted.
649 Used in the menus, menu bars and edit text controls.
651 @return
652 colour specification.
654 const PColour & GetHighlightBkColour() const;
656 /**Get the default colour of text that is disabled ("dimmed" or "grayed
657 out"). Used in the menus, menu bars and all controls.
659 @return
660 colour specification.
662 const PColour & GetGrayTextColour() const;
665 /**Add the interactor to the list for delayed delete operation on close
666 of interactor from within a callback member function. This avoids the
667 problem of an interactor object having its memory freed (via delete)
668 while executing member functions of that object. The actual delete
669 operation is delayed until the system returns to the main event loop.
671 This function is primarily for internal use by PWLib and is used by
672 the Close() function in the PTitledWindow and PDialog classes.
674 void DelayedCloseInteractor(
675 PInteractor * interactor /// Interactor to close
678 /*Internal initialisation function called directly from
679 #main()#. The user should never call this function.
681 virtual int _main(void * arg = NULL);
684 protected:
685 /** The main, top level window for the application. */
686 PTopLevelWindow * mainWindow;
688 /** The type of the parameter list. */
689 ParameterTypes parameterType;
691 private:
692 void Construct();
694 // System values
695 PString aboutMenuItemString;
696 PRESOURCE_ID aboutDialogID;
697 PFilePath defaultHelpFile;
698 PDim primaryScreenSize, screenResImperial, screenResMetric, cursorSize, iconSize;
699 PDim titledBorder, dlgBorder, border, defMainWindow, defTitledWindow;
700 long screenColours;
701 PDIMENSION screenDepth, heightTitle, heightMenu;
702 PDIMENSION heightHScroll, widthVScroll;
703 PRect screenRect, dblClkRect;
704 PFont systemFont, balloonFont;
705 PTimeInterval doubleClick;
706 PColour windowFg, windowBk, highlightFg, highlightBk;
707 PColour menuFg, menuBk, balloonFg, balloonBk;
708 PColour grayText, buttonFg, buttonBk, buttonLighting, buttonShadow;
709 PColour scrollBar, activeTitleFg, activeTitleBk, inactiveTitleFg;
710 PColour inactiveTitleBk, activeBorder, inactiveBorder;
712 PInteractorList delayedCloseInteractors;
713 // List of interactors that require deletion at end of main loop.
715 PCommandManager commandManager;
716 // Manager for the command communication mechanism.
718 PInteractor * balloonee;
719 PBalloon * balloon;
720 PTimer blowUpTimer;
721 PTimeInterval blowUpTimeout;
722 PDECLARE_NOTIFIER(PTimer, PApplication, BlowUpBalloon);
724 friend class PTopLevelWindow;
725 friend PCommandSink::PCommandSink(const char *, const char *);
726 friend void PCommandSource::Call(PObject &, INT) const;
729 // Include platform dependent part of class
730 #include <pwlib/applicat.h>
734 // End Of File ///////////////////////////////////////////////////////////////