1998-10-02 06:02:32 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Objective Caml */
|
|
|
|
/* */
|
|
|
|
/* Damien Doligez, projet Para, INRIA Rocquencourt */
|
|
|
|
/* */
|
|
|
|
/* Copyright 1997 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../LICENSE. */
|
1998-10-02 06:02:32 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
static WindowPtr aboutbox = NULL;
|
|
|
|
static UserItemUPP DrawAboutUPP = NULL;
|
|
|
|
|
|
|
|
#define kItemText 2
|
|
|
|
|
|
|
|
static pascal void DrawAbout (DialogPtr d, short item)
|
|
|
|
{
|
2000-03-01 05:01:44 -08:00
|
|
|
#pragma unused (item)
|
1998-10-02 06:02:32 -07:00
|
|
|
WEHandle we = WinGetWE (d);
|
|
|
|
|
|
|
|
Assert (we != NULL);
|
|
|
|
WEUpdate (d->visRgn, we);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenAboutBox (void)
|
|
|
|
{
|
|
|
|
OSErr err;
|
|
|
|
short itemtype;
|
|
|
|
Handle item;
|
|
|
|
Rect itemrect;
|
|
|
|
LongRect lr;
|
|
|
|
WEHandle we = NULL;
|
|
|
|
WStatusH st = NULL;
|
2000-04-20 06:41:23 -07:00
|
|
|
Handle txt = NULL, copr = NULL;
|
1998-10-02 06:02:32 -07:00
|
|
|
TextStyle ts;
|
|
|
|
|
|
|
|
if (DrawAboutUPP == NULL) DrawAboutUPP = NewUserItemProc (DrawAbout);
|
|
|
|
|
|
|
|
if (aboutbox != NULL){
|
|
|
|
SelectWindow (aboutbox);
|
|
|
|
}else{
|
|
|
|
aboutbox = GetNewDialog (kDialogAbout, NULL, (WindowPtr) -1L);
|
|
|
|
if (aboutbox == NULL){
|
|
|
|
err = memFullErr;
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
SetPort (aboutbox);
|
|
|
|
|
|
|
|
err = WinAllocStatus (aboutbox);
|
|
|
|
if (err != noErr) goto failed;
|
|
|
|
|
|
|
|
st = WinGetStatus (aboutbox);
|
|
|
|
Assert (st != NULL);
|
|
|
|
(*st)->kind = kWinAbout;
|
|
|
|
|
|
|
|
GetDialogItem (aboutbox, kItemText, &itemtype, &item, &itemrect);
|
|
|
|
SetDialogItem (aboutbox, kItemText, itemtype, (Handle) DrawAboutUPP, &itemrect);
|
|
|
|
WERectToLongRect (&itemrect, &lr);
|
|
|
|
err = WENew (&lr, &lr, 0, &we);
|
|
|
|
if (err != noErr) goto failed;
|
|
|
|
|
|
|
|
(*st)->we = we;
|
|
|
|
|
|
|
|
GetFNum ("\pGeneva", &ts.tsFont);
|
|
|
|
ts.tsSize = 10;
|
|
|
|
err = WESetStyle (weDoFont + weDoSize, &ts, we);
|
|
|
|
if (err != noErr) goto failed;
|
|
|
|
|
2000-04-20 06:41:23 -07:00
|
|
|
txt = GetResource ('TEXT', kAboutText1);
|
1998-10-02 06:02:32 -07:00
|
|
|
err = ResError (); if (err != noErr){ err = noErr; goto failed; }
|
|
|
|
DetachResource (txt);
|
|
|
|
|
2000-04-20 06:41:23 -07:00
|
|
|
copr = GetResource ('TEXT', kAboutText2);
|
|
|
|
err = ResError ();
|
|
|
|
if (err == noErr){
|
|
|
|
HLock (copr);
|
|
|
|
err = HandAndHand (copr, txt);
|
|
|
|
/* ignore errors */
|
|
|
|
HUnlock (copr);
|
|
|
|
ReleaseResource (copr);
|
|
|
|
copr = NULL;
|
|
|
|
}
|
|
|
|
|
1998-10-02 06:02:32 -07:00
|
|
|
err = WEUseText (txt, we);
|
|
|
|
if (err != noErr) goto failed;
|
|
|
|
err = WECalText (we);
|
|
|
|
if (err != noErr) goto failed;
|
|
|
|
|
|
|
|
WEFeatureFlag (weFReadOnly, weBitSet, we);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
failed:
|
2000-04-20 06:41:23 -07:00
|
|
|
if (copr != NULL) DisposeHandle (copr);
|
1998-10-02 06:02:32 -07:00
|
|
|
if (txt != NULL) DisposeHandle (txt);
|
|
|
|
if (we != NULL) WEDispose (we);
|
|
|
|
if (st != NULL) DisposeHandle ((Handle) st);
|
|
|
|
if (aboutbox != NULL) DisposeWindow (aboutbox);
|
|
|
|
aboutbox = NULL;
|
|
|
|
ErrorAlertGeneric (err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CloseAboutBox (WindowPtr w)
|
|
|
|
{
|
|
|
|
WStatusH st = WinGetStatus (w);
|
|
|
|
WEHandle we = WinGetWE (w);
|
|
|
|
|
|
|
|
Assert (w == aboutbox);
|
|
|
|
|
|
|
|
Assert (we != NULL);
|
|
|
|
WEDispose (we);
|
|
|
|
Assert (st != NULL);
|
|
|
|
DisposeHandle ((Handle) st);
|
|
|
|
Assert (w != NULL);
|
|
|
|
DisposeDialog (w);
|
|
|
|
aboutbox = NULL;
|
|
|
|
}
|