1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is Mozilla Communicator client code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the NPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the NPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
38
#include "nsNativeAppSupport.h"
40
#define PX_IMAGE_MODULES
41
#define PX_BMP_SUPPORT
42
#include <photon/PxImage.h>
47
class nsSplashScreenPh : public nsISplashScreen {
50
: mDialog( 0 ), mRefCnt( 0 ) {
52
/* initialize widget library and attach to Photon */
56
/* increase the draw buffer */
57
PgSetDrawBufferSize( 0x8000 );
66
// nsISupports methods
67
NS_IMETHOD_(nsrefcnt) AddRef() {
71
NS_IMETHOD_(nsrefcnt) Release() {
79
NS_IMETHOD QueryInterface( const nsIID &iid, void**p ) {
83
if ( iid.Equals( NS_GET_IID( nsISplashScreen ) ) ) {
84
nsISplashScreen *result = this;
87
} else if ( iid.Equals( NS_GET_IID( nsISupports ) ) ) {
88
nsISupports *result = NS_STATIC_CAST( nsISupports*, this );
95
rv = NS_ERROR_NULL_POINTER;
102
}; // class nsSplashScreenPh
106
nsSplashScreenPh::Show()
108
PhImage_t *img = nsnull;
111
char splash_path[256];
116
PRInt32 aWidth, aHeight;
120
/* Get the Screen Size and Depth, so I can center the splash dialog, there has to be a better way!*/
122
if( p ) inp_grp = atoi( p );
125
PhQueryRids( 0, 0, inp_grp, Ph_INPUTGROUP_REGION, 0, 0, 0, &rid, 1 );
126
PhRegionQuery( rid, ®ion, &rect, NULL, 0 );
127
inp_grp = region.input_group;
128
PhWindowQueryVisible( Ph_QUERY_INPUT_GROUP | Ph_QUERY_EXACT, 0, inp_grp, &rect );
129
aWidth = rect.lr.x - rect.ul.x + 1;
130
aHeight = rect.lr.y - rect.ul.y + 1;
132
/* Get the current console offset */
133
if (PhWindowQueryVisible( Ph_QUERY_GRAPHICS, 0, inp_grp, &console ) == 0)
137
/* Setup proper path to the splash.bmp so it loads the splash screen at start up. */
138
splash = getenv( "MOZILLA_FIVE_HOME" );
140
sprintf( splash_path, "%s/splash.bmp", splash );
141
if( ( img = PxLoadImage( splash_path, NULL ) ) != NULL )
146
img->flags = img->flags | Ph_RELEASE_IMAGE_ALL;
148
pos.x = (aWidth/2) - (img->size.w/2);
149
pos.y = (aHeight/2) - (img->size.h/2);
151
pos.x += console.ul.x;
152
pos.y += console.ul.y;
154
PtSetArg( &arg[n++], Pt_ARG_DIM, &img->size, 0 );
155
PtSetArg( &arg[n++], Pt_ARG_POS, &pos, 0 );
156
PtSetArg( &arg[n++], Pt_ARG_WINDOW_RENDER_FLAGS, 0, 0xFFFFFFFF );
157
PtSetArg( &arg[n++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0 );
158
PtSetArg( &arg[n++], Pt_ARG_WINDOW_MANAGED_FLAGS, Ph_WM_CLOSE | Ph_WM_TOFRONT | Ph_WM_TOBACK | Ph_WM_MOVE | Ph_WM_RESIZE, ~0 );
159
mDialog = PtCreateWidget( PtWindow, NULL, n, arg );
163
PtSetArg( &arg[n++], Pt_ARG_POS, &pos, 0 );
164
PtSetArg( &arg[n++], Pt_ARG_LABEL_TYPE, Pt_IMAGE, 0 );
165
PtSetArg( &arg[n++], Pt_ARG_LABEL_DATA, img, sizeof(PhImage_t) );
166
PtSetArg( &arg[n++], Pt_ARG_MARGIN_HEIGHT, 0, 0);
167
PtSetArg( &arg[n++], Pt_ARG_MARGIN_WIDTH, 0, 0);
168
PtCreateWidget( PtLabel, mDialog, n, arg );
169
PtRealizeWidget( mDialog );
175
fprintf( stderr, "Error loading splash screen image: %s\n", splash );
182
nsSplashScreenPh::Hide() {
184
PtDestroyWidget(mDialog);
190
nsresult NS_CreateSplashScreen(nsISplashScreen**aResult)
193
*aResult = new nsSplashScreenPh;
195
NS_ADDREF( *aResult );
198
return NS_ERROR_OUT_OF_MEMORY;
201
return NS_ERROR_NULL_POINTER;