diff options
author | Damien Doligez <damien.doligez-inria.fr> | 1998-10-02 13:02:32 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 1998-10-02 13:02:32 +0000 |
commit | 1785aa4ef9afce6807d5d810687b376620618cf9 (patch) | |
tree | e11f59bd40aa82a9cff2f63de8ee9e9e27a619be /maccaml/aboutbox.c | |
parent | 89074600b8f8425a829f253a27580b5548fd8193 (diff) |
portage MacOS standalone: T=0
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2111 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'maccaml/aboutbox.c')
-rw-r--r-- | maccaml/aboutbox.c | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/maccaml/aboutbox.c b/maccaml/aboutbox.c new file mode 100644 index 000000000..5aedcfe01 --- /dev/null +++ b/maccaml/aboutbox.c @@ -0,0 +1,110 @@ +/***********************************************************************/ +/* */ +/* Objective Caml */ +/* */ +/* Damien Doligez, projet Para, INRIA Rocquencourt */ +/* */ +/* Copyright 1997 Institut National de Recherche en Informatique et */ +/* en Automatique. Distributed only by permission. */ +/* */ +/***********************************************************************/ + +/* $Id$ */ + +#include "main.h" + +static WindowPtr aboutbox = NULL; +static UserItemUPP DrawAboutUPP = NULL; + +#define kItemText 2 + +static pascal void DrawAbout (DialogPtr d, short item) +{ + 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; + Handle txt = NULL; + 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; + + txt = GetResource ('TEXT', kAboutText); + err = ResError (); if (err != noErr){ err = noErr; goto failed; } + DetachResource (txt); + + err = WEUseText (txt, we); + if (err != noErr) goto failed; + err = WECalText (we); + if (err != noErr) goto failed; + + WEFeatureFlag (weFReadOnly, weBitSet, we); + + return; + + failed: + 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; +} |