Back to index

plt-scheme  4.2.1
mred.h
Go to the documentation of this file.
00001 
00002 #define BREAKING_REQUIRES_SHIFT 1
00003 
00004 #ifndef MRED_EXTERN
00005 # define MRED_EXTERN extern
00006 #endif
00007 
00008 #ifdef wx_x
00009 typedef XEvent MrEdEvent;
00010 #else
00011 #ifdef wx_msw
00012 typedef MSG MrEdEvent;
00013 #else
00014 typedef EventRecord MrEdEvent;
00015 #endif
00016 #endif
00017 
00018 class wxTimer;
00019 class MrEdContextFrames;
00020 
00021 #if defined(MZ_PRECISE_GC) || defined(SGC_STD_DEBUGGING)
00022 typedef Scheme_Object *MrEdContextFramesRef;
00023 # define MAKE_FRAMES_REF(x) scheme_make_weak_box((Scheme_Object *)x)
00024 # define FRAMES_REF(p) ((MrEdContextFrames *)SCHEME_WEAK_BOX_VAL(p))
00025 #else
00026 typedef MrEdContextFrames *MrEdContextFramesRef;
00027 # define MAKE_FRAMES_REF(x) x
00028 # define FRAMES_REF(p) p
00029 #endif
00030 
00031 class MrEdContextFrames {
00032  public:
00033   wxChildList *list;
00034   MrEdContextFramesRef next, prev;
00035 };
00036 
00037 class MrEdFinalizedContext;
00038 class MrEd_Saved_Modal;
00039 
00040 #include "wxs/mrdispatch.h"
00041 
00042 #ifdef wx_msw
00043 class LeaveEvent;
00044 #endif
00045 
00046 typedef struct MrEdContext {
00047   Scheme_Object so;
00048 
00049   Scheme_Thread *handler_running;
00050   int suspended;
00051 
00052   MrEdFinalizedContext *finalized;
00053 
00054   wxChildList *topLevelWindowList;
00055   wxWindow *modal_window;
00056   MrEd_Saved_Modal *modal_stack;
00057 
00058   Scheme_Config *main_config;
00059   Scheme_Thread_Cell_Table *main_cells;
00060   Scheme_Object *main_break_cell;
00061 
00062   short ready_to_go;
00063 
00064   short ready, waiting_for_nested, nested_avail;
00065   short q_callback;
00066   wxTimer *timer;
00067   MrEdEvent event;
00068 
00069   wxTimer *timers;
00070 
00071   /* Alternate condition for nested event loop pending some condition */
00072   wxDispatch_Check_Fun alternate;
00073   void *alt_data;
00074 
00075   /* Used to chain active contexts while reading events: */
00076   struct MrEdContext *next;
00077 
00078   int busyState;
00079   int killed;
00080 
00081 #ifdef wx_msw
00082   LeaveEvent *queued_leaves;
00083 #endif
00084 
00085   struct Context_Custodian_Hop *mr_hop;
00086   Scheme_Custodian_Reference *mref;
00087 } MrEdContext;
00088 
00089 class MrEdFinalizedContext {
00090  public:
00091 #ifdef wx_xt
00092   Widget toplevel;
00093 #endif
00094   MrEdContextFrames *frames;
00095 };
00096 
00097 extern MrEdContext *mred_contexts;
00098 
00099 MrEdContext *MrEdGetContext(wxObject *w = NULL);
00100 
00101 extern int MrEdGetNextEvent(int peek, int current_only, MrEdEvent *, MrEdContext **);
00102 void MrEdDispatchEvent(MrEdEvent *);
00103 
00104 void MrEdInitFirstContext(MrEdContext *c);
00105 void MrEdInitNewContext(MrEdContext *c);
00106 void MrEdDestroyContext(MrEdFinalizedContext *c);
00107 
00108 extern "C" {
00109   typedef void (*SLEEP_PROC_PTR)(float seconds, void *fds);
00110 }
00111 
00112 #ifdef wx_msw
00113 void MrEdMSWSleep(float secs, void *fds, SLEEP_PROC_PTR mzsleep);
00114 MRED_EXTERN void mred_clean_up_gdi_objects(void);
00115 #endif
00116 
00117 #ifdef wx_mac
00118 void MrEdMacSleep(float secs, void *fds, SLEEP_PROC_PTR mzsleep);
00119 void wxmac_reg_globs(void);
00120 #endif
00121 
00122 #if defined(wx_msw) || defined(wx_mac)
00123 # define NEED_HET_PARAM
00124 #endif
00125 
00126 #ifdef NEED_HET_PARAM
00127 # ifdef wx_msw
00128 #  define HET_TIMER_T UINT
00129 # else
00130 #  define HET_TIMER_T long
00131 # endif
00132 
00133 typedef int (*HiEventTrampProc)(void *);
00134 
00135 class HiEventTramp {
00136 public:
00137   HiEventTrampProc do_f;
00138   void *do_data;
00139   int val;
00140   int in_progress;
00141   int progress_is_resumed;
00142   int yielding;
00143   Scheme_Object *old_param;
00144   Scheme_Config *config;
00145   void *progress_base_addr;
00146   mz_jmp_buf progress_base;
00147   Scheme_Jumpup_Buf_Holder *progress_cont;
00148   int timer_on;
00149   HET_TIMER_T timer_id;
00150   double continue_until;
00151 #ifdef MZ_PRECISE_GC
00152   void *fixup_var_stack_chain;
00153 #endif
00154 };
00155 
00156 int mred_het_run_some(HiEventTrampProc do_f, void *do_data);
00157 
00158 extern Scheme_Object *mred_het_key;
00159 
00160 int wxHiEventTrampoline(HiEventTrampProc wha_f, void *wha_data);
00161 
00162 #endif // NEED_HET_PARAM
00163 
00164 typedef void *(*ForEachFrameProc)(wxObject *, void *);
00165 void *MrEdForEachFrame(ForEachFrameProc fp, void *data);
00166 
00167 /* Startup: */
00168 MRED_EXTERN void wxCreateApp(void);
00169 MRED_EXTERN void wxDoMainLoop();
00170 
00171 typedef int (*MrEd_Finish_Cmd_Line_Run_Proc)(void);
00172 typedef void (*MrEd_Run_From_Cmd_Line_Proc)(int argc, char **argv, Scheme_Env *(*mk_basic_env)(void));
00173 
00174 MRED_EXTERN MrEd_Finish_Cmd_Line_Run_Proc mred_finish_cmd_line_run;
00175 MRED_EXTERN void mred_set_finish_cmd_line_run(MrEd_Finish_Cmd_Line_Run_Proc);
00176 MRED_EXTERN MrEd_Run_From_Cmd_Line_Proc mred_run_from_cmd_line;
00177 MRED_EXTERN void mred_set_run_from_cmd_line(MrEd_Run_From_Cmd_Line_Proc);
00178 
00179 # include "../mzscheme/src/schvers.h"
00180 
00181 #ifdef MZ_PRECISE_GC
00182 # define mrVERSION_SUFFIX " [3m]"
00183 #else
00184 # ifdef USE_SENORA_GC
00185 #  define mrVERSION_SUFFIX " [cgc~]"
00186 # else
00187 #  define mrVERSION_SUFFIX " [cgc]"
00188 # endif
00189 #endif
00190 #define BANNER "MrEd v" MZSCHEME_VERSION mrVERSION_SUFFIX ", Copyright (c) 2004-2009 PLT Scheme Inc.\n"
00191 
00192 #ifndef WCONSOLE_STDIO
00193 # if defined(wx_msw)
00194 #  define WCONSOLE_STDIO 1
00195 # else
00196 #  define WCONSOLE_STDIO 0
00197 # endif
00198 #endif
00199 
00200 #ifndef REDIRECT_STDIO
00201 # if defined(wx_msw) && !WCONSOLE_STDIO
00202 #  define REDIRECT_STDIO 1
00203 # else
00204 #  define REDIRECT_STDIO 0
00205 # endif
00206 #endif
00207 
00208 #define MRED_GUID "B2261834-D535-44dd-8511-A26FC8F97DD0"
00209 
00210 #if defined(wx_mac) || defined(wx_msw)
00211 MRED_EXTERN void wxDrop_Runtime(char **argv, int argc);
00212 MRED_EXTERN void wxDrop_Quit();
00213 #endif
00214 
00215 #if defined(wx_mac)
00216 extern void WakeUpMrEd();
00217 #endif
00218 
00219 #if defined(wx_xt)
00220 extern void wxUnhideAllCursors();
00221 int wxCheckSingleInstance(Scheme_Env *global_env);
00222 #endif