Back to index

plt-scheme  4.2.1
Classes | Functions
AppMain.h File Reference

Go to the source code of this file.

Classes

class  wxApp

Functions

void wxInitNewToplevel (void)
void wxDoNextEvent ()
int wxEventReady ()
void wxDoEvents ()
int wxEntry (int argc, char *argv[])
int wxGetPreference (const char *name, int *res)
int wxGetBoolPreference (const char *name, int *res)

Function Documentation

Definition at line 1613 of file mred.cxx.

{
  /* When we get here, we are in the main dispatcher thread */
  if (!TheMrEdApp->initialized) {
    MrEdContext *c;

    /* Create the user's main thread: */

    c = (MrEdContext *)MrEdMakeEventspace();

    wxREGGLOB(user_main_context);
    user_main_context = c;

    {
      Scheme_Object *cp;
      cp = scheme_make_closed_prim(CAST_SCP handle_events, c);
      wxREGGLOB(user_main_thread);
      user_main_thread = (Scheme_Thread *)scheme_thread_w_details(cp, 
                                                          c->main_config,
                                                          c->main_cells,
                                                          c->main_break_cell,
                                                          NULL, 0);
      scheme_set_break_main_target(user_main_thread);
      cp = scheme_intern_symbol("mred");
      user_main_thread->name = cp;
    }

    /* Block until the user's main thread is initialized: */
    scheme_block_until(CAST_BLKCHK check_initialized, NULL, NULL, 0.0);
  }

  if (!try_dispatch(scheme_true)) {
    do {
      Scheme_Thread *thread;
      thread = scheme_get_current_thread();
      thread->block_descriptor = -1;
      thread->blocker = NULL;
      thread->block_check = CAST_BLKCHK try_dispatch;
      thread->block_needs_wakeup = CAST_WU wakeup_on_dispatch;

      scheme_thread_block(0);

      thread = scheme_get_current_thread();
      thread->block_descriptor = 0;
      /* Sets ran_some if it succeeds: */
      if (try_dispatch(scheme_false))
       break;
    } while (KEEP_GOING);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1323 of file mred.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

int wxEntry ( int  argc,
char *  argv[] 
)

Definition at line 175 of file AppMain.cc.

{
  int xargc, ate;
  char *x_display_str = NULL;

  if (!wxTheApp) {
    wxFatalError("You have to define an instance of wxApp!");
  }

  // init private and public data
  /* Set if not set... */
  if (!wxAPP_CLASS) {
    wxREGGLOB(wxAPP_CLASS);
    wxAPP_CLASS = wxFileNameFromPath(argv[0]);
  }
  if (!wxAPP_NAME) {
    wxREGGLOB(wxAPP_NAME);
    wxAPP_NAME  = wxFileNameFromPath(argv[0]);
  }

  xargc = filter_x_readable(argv, argc, &x_display_str);
  ate = xargc - 1;

  if (!x_display_str)
    x_display_str = getenv("DISPLAY");
  
  /* Remember -display or DISPLAY, in case someone needs it: */
  wxsRememberDisplay(x_display_str);

  XtToolkitInitialize();
  wxAPP_CONTEXT = XtCreateApplicationContext();
  wxAPP_DISPLAY = XtOpenDisplay(wxAPP_CONTEXT, NULL, NULL,NULL,
                            NULL, 0,
                            &xargc, argv); // command line arguments

  if (!wxAPP_DISPLAY) {
    if (!x_display_str) {
      printf("DISPLAY environment variable not set and no -display argument\n");
    } else {
      printf("Cannot open display: %s\n", x_display_str);
    }
    exit(1);
  }


  if ((xargc > 1) && !strcmp("-singleInstance", argv[1])) {
    wx_single_instance = 1;
    --xargc;
    if (xargc > 1) {
      argv[1] = argv[2];
    }
  }

  if (xargc != 1) {
    printf("%s: standard X Window System flag \"%s\" was rejected\n",
          argv[0], argv[1]);
    exit(1);
  }
  
  wxAPP_SCREEN = DefaultScreenOfDisplay(wxAPP_DISPLAY);
  wxAPP_VISUAL = DefaultVisualOfScreen(wxAPP_SCREEN);
  wx_default_colormap = DefaultColormapOfScreen(wxAPP_SCREEN);
  wx_black_pixel = BlackPixel(wxAPP_DISPLAY, DefaultScreen(wxAPP_DISPLAY));
  wx_white_pixel = WhitePixel(wxAPP_DISPLAY, DefaultScreen(wxAPP_DISPLAY));

  /* Use 24-bit TrueColor visual, if possible */
  {
    XVisualInfo *vi, vi_tmpl, vi2;
    int n;
    
    vi_tmpl.visualid = XVisualIDFromVisual(wxAPP_VISUAL);
    vi = XGetVisualInfo(wxAPP_DISPLAY, VisualIDMask, &vi_tmpl, &n);
    wx_visual_depth = vi->depth;

    if ((vi->c_class != TrueColor) || (vi->depth < 24)) {
      if (XMatchVisualInfo(wxAPP_DISPLAY, DefaultScreen(wxAPP_DISPLAY), 
                        24, TrueColor, &vi2)) {
       wxAPP_VISUAL = vi2.visual;
       wx_visual_depth = 24;
       wx_default_colormap = XCreateColormap(wxAPP_DISPLAY, 
                                         RootWindow(wxAPP_DISPLAY,
                                                  DefaultScreen(wxAPP_DISPLAY)),
                                         wxAPP_VISUAL, 
                                         AllocNone);

       {
         XColor xcol;
         xcol.red = xcol.blue = xcol.green = 0;
         wxAllocColor(wxAPP_DISPLAY, wx_default_colormap, &xcol);
         wx_black_pixel = xcol.pixel;
         xcol.red = xcol.blue = xcol.green = 0xFFFF;
         wxAllocColor(wxAPP_DISPLAY, wx_default_colormap, &xcol);
         wx_white_pixel = xcol.pixel;
       }
      }
    }

    XFree(vi);
  }

  wxInitNewToplevel();

  for (int i = ate + 1; i < argc; i++) {
    argv[i - ate] = argv[i];
  }
  argc -= ate;
  
  wxTheApp->argc = argc;
  wxTheApp->argv = argv;

  // initialize global data
  wxCommonInit();
  
  wxTheApp->OnInit();
  
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1353 of file mred.cxx.

{
  MrEdContext *c;
  Scheme_Thread *thread;
  c = MrEdGetContext();
  thread = scheme_get_current_thread();

  return (!c->ready_to_go
         && (c->handler_running == thread)
         && MrEdEventReady(c));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int wxGetBoolPreference ( const char *  name,
int res 
)

Definition at line 2969 of file wxscheme.cxx.

{
  char buf[20];

  if (wxGetPreference(name, buf, 20)) {    
    if (!strcmp(buf, "#f"))
      *res = 0;
    else
      *res = 1;
    return 1;
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int wxGetPreference ( const char *  name,
int res 
)

Definition at line 2952 of file wxscheme.cxx.

{
  char buf[20];

  if (wxGetPreference(name, buf, 20)) {    
    long v;
    char *p;
    v = strtol(buf, &p, 10);
    if (p == (buf + strlen(buf))) {
      *res = v;
      return 1;
    }
  }

  return 0;
}

Here is the call graph for this function:

Definition at line 101 of file AppMain.cc.

{
  Widget tl;

  tl = XtVaAppCreateShell(wxAPP_NAME, wxAPP_CLASS,
                       applicationShellWidgetClass,
                       wxAPP_DISPLAY,
                       XtNvisual, wxAPP_VISUAL,
                       XtNdepth, wx_visual_depth,
                       XtNcolormap, wx_default_colormap,
                       NULL);

  wxPutAppToplevel(tl);
}

Here is the call graph for this function:

Here is the caller graph for this function: