Back to index

plt-scheme  4.2.1
DialogBox.cc
Go to the documentation of this file.
00001 /*                                                      -*- C++ -*-
00002  *
00003  * Purpose: dialog box
00004  *
00005  * Authors: Markus Holzem and Julian Smart
00006  *
00007  * Copyright: (C) 2004-2009 PLT Scheme Inc.
00008  * Copyright: (C) 1995, AIAI, University of Edinburgh (Julian)
00009  * Copyright: (C) 1995, GNU (Markus)
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00024  * 02110-1301 USA.
00025  */
00026 
00027 #ifdef __GNUG__
00028 #pragma implementation "DialogBox.h"
00029 #endif
00030 
00031 #define  Uses_XtIntrinsic
00032 #define  Uses_wxDialogBox
00033 #define  Uses_wxList
00034 #define  Uses_wxTypeTree
00035 #include "wx.h"
00036 
00037 wxDialogBox::wxDialogBox(void) : wxFrame()
00038 {
00039   __type = wxTYPE_DIALOG_BOX;
00040 }
00041 
00042 wxDialogBox::wxDialogBox(wxWindow *parent, char *title, Bool _modal, int x,
00043                       int y, int width, int height, long style, char *name)
00044     : wxFrame()
00045 {
00046     __type = wxTYPE_DIALOG_BOX;
00047 
00048     style |= wxTRANSIENT;
00049 
00050     Create((wxFrame *)parent, title, _modal, x, y, width, height, style, name);
00051 }
00052 
00053 Bool wxDialogBox::Create(wxFrame *parent, char *title, Bool _modal, int x,
00054                       int y, int width, int height, long style, char *name)
00055 {
00056     style |= wxTRANSIENT;
00057 
00058     (void)wxFrame::Create(parent, title, x, y, width, height, style, name);
00059 
00060     return TRUE;
00061 }
00062 
00063 extern void wxDispatchEventsUntil(int (*)(void *), void *);
00064 
00065 static int CheckDialogShowing(void *data)
00066 {
00067   return !((wxDialogBox *)data)->ModalShowing();
00068 }
00069 
00070 Bool wxDialogBox::Show(Bool show)
00071 {
00072   // handle modality
00073   if (show) {
00074     wxChildNode *cnode;
00075     wxChildList *tlf;
00076 
00077     // popup/popdown frame
00078     wxFrame::Show(show);
00079     SetShown(show);
00080       
00081     if (!restore_disabled_windows) {
00082       wxList *disabled_windows;
00083 
00084       wxPushModalWindow(this, this);
00085       
00086       disabled_windows = new wxList;
00087       
00088       tlf = wxTopLevelFrames(this);
00089       for (cnode = tlf->First(); cnode; cnode = cnode->Next()) {
00090        wxWindow *w;
00091        w = (wxWindow *)cnode->Data();
00092        if (w && w != this && cnode->IsShown()) {
00093          disabled_windows->Append(w);
00094          w->InternalEnable(FALSE);
00095        }
00096       }
00097       
00098       restore_disabled_windows = disabled_windows;
00099     }
00100 
00101     wxDispatchEventsUntil(CheckDialogShowing, (void *)this);
00102   } else {
00103     if (restore_disabled_windows) {
00104       wxList *disabled_windows = restore_disabled_windows;
00105       wxNode *node;
00106 
00107       restore_disabled_windows = NULL;
00108       
00109       for (node = disabled_windows->First(); node; node = node->Next()) {
00110        wxWindow *w;
00111        w = (wxWindow *)node->Data();
00112        w->InternalEnable(TRUE);
00113       }
00114 
00115       wxPopModalWindow(this, this);
00116 
00117       wxFrame::Show(FALSE);
00118       SetShown(FALSE);
00119       
00120       XFlush(XtDisplay(wxAPP_TOPLEVEL));
00121       XSync(XtDisplay(wxAPP_TOPLEVEL), FALSE);
00122     }
00123   } 
00124   
00125   return TRUE;
00126 }
00127