/* DO NOT EDIT THIS FILE. */
/* This file was generated by xctocc from "wxs_dc.xc". */


#if defined(_MSC_VER)
# include "wx.h"
#endif

#include "wx_dccan.h"
#include "wx_dcmem.h"
#include "wx_dcps.h"
#ifndef wx_mac
#include "wx_dcpan.h"
#endif
#ifdef wx_msw
#include "wx_mf.h"
#endif
#include "wx_types.h"
#ifdef wx_mac
#include "wx_dcpr.h"
#endif
#include "wx_rgn.h"




#ifdef wx_x
# define BM_SELECTED(map) ((map)->selectedTo)
#endif
#if defined(wx_mac) || defined(wx_msw)
# define BM_SELECTED(map) ((map)->selectedInto)
#endif
# define BM_IN_USE(map) ((map)->selectedIntoDC)





#include "wxscheme.h"
#include "wxs_dc.h"

#ifdef MZ_PRECISE_GC
START_XFORM_SKIP;
#endif

static Scheme_Object *textMode_wxTRANSPARENT_sym = NULL;
static Scheme_Object *textMode_wxSOLID_sym = NULL;

static void init_symset_textMode(void) {
  REMEMBER_VAR_STACK();
  wxREGGLOB(textMode_wxTRANSPARENT_sym);
  textMode_wxTRANSPARENT_sym = WITH_REMEMBERED_STACK(scheme_intern_symbol("transparent"));
  wxREGGLOB(textMode_wxSOLID_sym);
  textMode_wxSOLID_sym = WITH_REMEMBERED_STACK(scheme_intern_symbol("solid"));
}

static int unbundle_symset_textMode(Scheme_Object *v, const char *where) {
  SETUP_VAR_STACK(1);
  VAR_STACK_PUSH(0, v);
  if (!textMode_wxSOLID_sym) WITH_VAR_STACK(init_symset_textMode());
  if (0) { }
  else if (v == textMode_wxTRANSPARENT_sym) { return wxTRANSPARENT; }
  else if (v == textMode_wxSOLID_sym) { return wxSOLID; }
  if (where) WITH_VAR_STACK(scheme_wrong_type(where, "textMode symbol", -1, 0, &v));
  return 0;
}

static Scheme_Object *bundle_symset_textMode(int v) {
  if (!textMode_wxSOLID_sym) init_symset_textMode();
  switch (v) {
  case wxTRANSPARENT: return textMode_wxTRANSPARENT_sym;
  case wxSOLID: return textMode_wxSOLID_sym;
  default: return NULL;
  }
}


static Scheme_Object *bitmapDrawStyle_wxSOLID_sym = NULL;
static Scheme_Object *bitmapDrawStyle_wxSTIPPLE_sym = NULL;
static Scheme_Object *bitmapDrawStyle_wxXOR_sym = NULL;

static void init_symset_bitmapDrawStyle(void) {
  REMEMBER_VAR_STACK();
  wxREGGLOB(bitmapDrawStyle_wxSOLID_sym);
  bitmapDrawStyle_wxSOLID_sym = WITH_REMEMBERED_STACK(scheme_intern_symbol("solid"));
  wxREGGLOB(bitmapDrawStyle_wxSTIPPLE_sym);
  bitmapDrawStyle_wxSTIPPLE_sym = WITH_REMEMBERED_STACK(scheme_intern_symbol("opaque"));
  wxREGGLOB(bitmapDrawStyle_wxXOR_sym);
  bitmapDrawStyle_wxXOR_sym = WITH_REMEMBERED_STACK(scheme_intern_symbol("xor"));
}

static int unbundle_symset_bitmapDrawStyle(Scheme_Object *v, const char *where) {
  SETUP_VAR_STACK(1);
  VAR_STACK_PUSH(0, v);
  if (!bitmapDrawStyle_wxXOR_sym) WITH_VAR_STACK(init_symset_bitmapDrawStyle());
  if (0) { }
  else if (v == bitmapDrawStyle_wxSOLID_sym) { return wxSOLID; }
  else if (v == bitmapDrawStyle_wxSTIPPLE_sym) { return wxSTIPPLE; }
  else if (v == bitmapDrawStyle_wxXOR_sym) { return wxXOR; }
  if (where) WITH_VAR_STACK(scheme_wrong_type(where, "bitmapDrawStyle symbol", -1, 0, &v));
  return 0;
}



static Scheme_Object *fillKind_wxODDEVEN_RULE_sym = NULL;
static Scheme_Object *fillKind_wxWINDING_RULE_sym = NULL;

static void init_symset_fillKind(void) {
  REMEMBER_VAR_STACK();
  wxREGGLOB(fillKind_wxODDEVEN_RULE_sym);
  fillKind_wxODDEVEN_RULE_sym = WITH_REMEMBERED_STACK(scheme_intern_symbol("odd-even"));
  wxREGGLOB(fillKind_wxWINDING_RULE_sym);
  fillKind_wxWINDING_RULE_sym = WITH_REMEMBERED_STACK(scheme_intern_symbol("winding"));
}

static int unbundle_symset_fillKind(Scheme_Object *v, const char *where) {
  SETUP_VAR_STACK(1);
  VAR_STACK_PUSH(0, v);
  if (!fillKind_wxWINDING_RULE_sym) WITH_VAR_STACK(init_symset_fillKind());
  if (0) { }
  else if (v == fillKind_wxODDEVEN_RULE_sym) { return wxODDEVEN_RULE; }
  else if (v == fillKind_wxWINDING_RULE_sym) { return wxWINDING_RULE; }
  if (where) WITH_VAR_STACK(scheme_wrong_type(where, "fillKind symbol", -1, 0, &v));
  return 0;
}




static wxColour* dcGetTextBackground(wxDC *dc)
{
  wxColour *c, *bg;
  SETUP_VAR_STACK(2);
  VAR_STACK_PUSH(0, dc);
  VAR_STACK_PUSH(1, c);

  c = WITH_VAR_STACK(new wxColour());
#ifdef MZ_PRECISE_GC
  WITH_VAR_STACK(c->gcInit_wxColour());
#endif
  bg = WITH_VAR_STACK(dc->GetTextBackground());
  WITH_VAR_STACK(c->CopyFrom(bg));
  return c;
}

static wxColour* dcGetTextForeground(wxDC *dc)
{
  wxColour *c, *fg;
  SETUP_VAR_STACK(2);
  VAR_STACK_PUSH(0, dc);
  VAR_STACK_PUSH(1, c);

  c = WITH_VAR_STACK(new wxColour());
#ifdef MZ_PRECISE_GC
  WITH_VAR_STACK(c->gcInit_wxColour());
#endif
  fg = WITH_VAR_STACK(dc->GetTextForeground());
  WITH_VAR_STACK(c->CopyFrom(fg));
  return c;
}

static Bool DrawBitmap(wxDC *dc, wxBitmap *bm, float x, float y, int mode, wxColour *c)
{
  REMEMBER_VAR_STACK();
  if (bm->Ok()) {
    return WITH_REMEMBERED_STACK(dc->Blit(x, y, bm->GetWidth(), bm->GetHeight(), bm, 0, 0, mode, c));
  } else
    return FALSE;
}

static Bool DrawBitmapRegion(wxDC *dc, wxBitmap *bm, float x, float y, float dx, float dy, float dw, float dh, int mode, wxColour *c)
{
  REMEMBER_VAR_STACK();
  if (bm->Ok()) {
    return WITH_REMEMBERED_STACK(dc->Blit(x, y, dw, dh, bm, dx, dy, mode, c));
  } else
    return FALSE;
}

static void* MyTextExtent(wxDC *dc, char *s, wxFont *f, Bool big, int offset)
{
  float w, h, d, asc;
  Scheme_Object *a[4];
  SETUP_VAR_STACK(3);
  VAR_STACK_PUSH_ARRAY(0, a, 4);

  if (!dc->Ok()) {
    a[0] = a[1] = a[2] = a[3] = WITH_VAR_STACK(scheme_make_double(0.0));
  } else {
    WITH_VAR_STACK(dc->GetTextExtent(s, &w, &h, &d, &asc, f, big, offset));
    
    a[0] = WITH_VAR_STACK(scheme_make_double(w));
    a[1] = WITH_VAR_STACK(scheme_make_double(h));
    a[2] = WITH_VAR_STACK(scheme_make_double(d));
    a[3] = WITH_VAR_STACK(scheme_make_double(asc));
  }

  return WITH_VAR_STACK(scheme_values(4, a));
}

static void* MyGetSize(wxDC *dc)
{
  float w, h;
  Scheme_Object *a[2];
  SETUP_VAR_STACK(3);
  VAR_STACK_PUSH_ARRAY(0, a, 2);

  dc->GetSize(&w, &h);

  a[0] = WITH_VAR_STACK(scheme_make_double(w));
  a[1] = WITH_VAR_STACK(scheme_make_double(h));

  return WITH_VAR_STACK(scheme_values(2, a));
}





#undef DO_OK_CHECK
#ifdef DrawsForCanvas
#define DO_OK_CHECK(v)
#else
#define DO_OK_CHECK(v) if (!((wxDC *)((Scheme_Class_Object *)obj)->primdata)->Ok()) return v;
#endif


extern Scheme_Object *objscheme_bundle_wxPoint(wxPoint *);
extern wxPoint *objscheme_unbundle_wxPoint(Scheme_Object *, const char *, int);

#undef l_ADDRESS
#undef l_DEREF
#undef l_TEST
#undef l_POINT
#undef l_TYPE
#undef l_LIST_ITEM_BUNDLE
#undef l_LIST_ITEM_UNBUNDLE
#undef l_MAKE_LIST
#undef l_MAKE_ARRAY
#undef l_EXTRA
#undef l_TERMINATE
#undef l_COPY
#undef l_OKTEST
#undef l_INTTYPE

#define l_ADDRESS &
#define l_DEREF *
#define l_NEWATOMIC (AtomicGC)
#define l_NULLOK 0
#define l_TEST , l_NULLOK
#define l_POINT 
#define l_EXTRA 0
#define l_TERMINATE 
#define l_COPY l_COPYDEST.x=l_COPYSRC.x; l_COPYDEST.y=l_COPYSRC.y;
#define l_OKTEST 
#define l_INTTYPE int
#define l_DIRECTMALLOC 1

#define l_TYPE wxPoint
#define l_LIST_ITEM_BUNDLE objscheme_bundle_wxPoint
#define l_LIST_ITEM_UNBUNDLE objscheme_unbundle_wxPoint
#define l_MAKE_LIST __MakewxPointList
#define l_MAKE_ARRAY __MakewxPointArray





static Scheme_Object *l_MAKE_LIST(l_TYPE l_POINT *f, l_INTTYPE c)
{
  Scheme_Object *cdr = scheme_null, *obj;
  SETUP_VAR_STACK(1);
  VAR_STACK_PUSH(0, cdr);

  while (c--) {
    obj = WITH_VAR_STACK(l_LIST_ITEM_BUNDLE(l_ADDRESS f[c]));
    cdr = WITH_VAR_STACK(scheme_make_pair(obj, cdr));
  }
  
  return cdr;
}

static l_TYPE l_POINT *l_MAKE_ARRAY(Scheme_Object *l, l_INTTYPE *c, char *who)
{
  Scheme_Object *orig_l = l;
  int i = 0;
  long len;
  l_TYPE l_POINT *f = NULL;

  SETUP_VAR_STACK(3);
  VAR_STACK_PUSH(0, l);
  VAR_STACK_PUSH(1, orig_l);
  VAR_STACK_PUSH(2, f);

  len = WITH_VAR_STACK(scheme_proper_list_length(l));
  if (len < 0) WITH_VAR_STACK(scheme_wrong_type(who, "proper-list", -1, 0, &l));
  if (c) *c = len;

  if (!(len + l_EXTRA))
    return NULL;

#if l_DIRECTMALLOC
  f = (l_TYPE l_POINT *)WITH_VAR_STACK(GC_malloc_atomic(sizeof(l_TYPE l_POINT) * (len + l_EXTRA)));
#else
  f = WITH_VAR_STACK(new l_NEWATOMIC l_TYPE l_POINT[len + l_EXTRA]);
#endif

  while (!SCHEME_NULLP(l)) {
    if (!SCHEME_LISTP(l)) {
      WITH_VAR_STACK(scheme_arg_mismatch(who, "expected a proper list: ", orig_l));
      return NULL;
    }

#define l_COPYDEST f[i]
#define l_COPYSRC (l_DEREF WITH_VAR_STACK(l_LIST_ITEM_UNBUNDLE(SCHEME_CAR(l), who l_TEST)))

    l_COPY

    l_OKTEST

    i++;

    l = SCHEME_CDR(l);
  }
  l_TERMINATE

  return f;
}


/* The methods are here: */



// @ q "begin-drawing" : void BeginDrawing(); : : /CheckOk
// @ q "end-drawing" : void EndDrawing(); : : /CheckOk







// Also in wxWindow:


#ifndef wx_mac
#define HIDETHISSTATEMENT(x) x
#else
#define HIDETHISSTATEMENT(x) 
#endif


#ifndef wx_mac
#define CHECKTHISONE(x) x
#else
#define CHECKTHISONE(x) 1
#endif








class os_wxDC : public wxDC {
 public:

  ~os_wxDC();
#ifdef MZ_PRECISE_GC
  void gcMark();
  void gcFixup();
#endif
};

#ifdef MZ_PRECISE_GC
void os_wxDC::gcMark() {
  wxDC::gcMark();
}
void os_wxDC::gcFixup() {
  wxDC::gcFixup();
}
#endif

static Scheme_Object *os_wxDC_class;
static Scheme_Object *os_wxDC_interface;

os_wxDC::~os_wxDC()
{
    objscheme_destroy(this, (Scheme_Object *)__gc_external);
}

static Scheme_Object *os_wxDCEndPage(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->EndPage());

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCEndDoc(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->EndDoc());

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCStartPage(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->StartPage());

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCStartDoc(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  Bool r;
  objscheme_check_valid(obj);
  string x0 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);

  
  x0 = (string)WITH_VAR_STACK(objscheme_unbundle_string(p[0], "start-doc in dc<%>"));

  
  r = WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->StartDoc(x0));

  
  
  return (r ? scheme_true : scheme_false);
}

static Scheme_Object *os_wxDCOk(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  Bool r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->Ok());

  
  
  return (r ? scheme_true : scheme_false);
}

static Scheme_Object *os_wxDCMyGetSize(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  void* r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(MyGetSize(((wxDC *)((Scheme_Class_Object *)obj)->primdata)));

  
  
  return (Scheme_Object*)r;
}

static Scheme_Object *os_wxDCdcGetTextForeground(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  class wxColour* r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(dcGetTextForeground(((wxDC *)((Scheme_Class_Object *)obj)->primdata)));

  
  
  return WITH_REMEMBERED_STACK(objscheme_bundle_wxColour(r));
}

static Scheme_Object *os_wxDCdcGetTextBackground(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  class wxColour* r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(dcGetTextBackground(((wxDC *)((Scheme_Class_Object *)obj)->primdata)));

  
  
  return WITH_REMEMBERED_STACK(objscheme_bundle_wxColour(r));
}

static Scheme_Object *os_wxDCGetPen(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  class wxPen* r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->GetPen());

  
  
  return WITH_REMEMBERED_STACK(objscheme_bundle_wxPen(r));
}

static Scheme_Object *os_wxDCGetFont(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  class wxFont* r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->GetFont());

  
  
  return WITH_REMEMBERED_STACK(objscheme_bundle_wxFont(r));
}

static Scheme_Object *os_wxDCGetBrush(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  class wxBrush* r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->GetBrush());

  
  
  return WITH_REMEMBERED_STACK(objscheme_bundle_wxBrush(r));
}

static Scheme_Object *os_wxDCGetBackgroundMode(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  int r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->GetBackgroundMode());

  
  
  return WITH_REMEMBERED_STACK(bundle_symset_textMode(r));
}

static Scheme_Object *os_wxDCGetBackground(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  class wxColour* r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->GetBackground());

  
  
  return WITH_REMEMBERED_STACK(objscheme_bundle_wxColour(r));
}

static Scheme_Object *os_wxDCSetDeviceOrigin(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  float x0;
  float x1;

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_float(p[0], "set-origin in dc<%>"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "set-origin in dc<%>"));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->SetDeviceOrigin(x0, x1));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCSetUserScale(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  nnfloat x0;
  nnfloat x1;

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[0], "set-scale in dc<%>"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[1], "set-scale in dc<%>"));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->SetUserScale(x0, x1));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCSetBackgroundMode(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  int x0;

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  
  x0 = WITH_VAR_STACK(unbundle_symset_textMode(p[0], "set-text-mode in dc<%>"));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->SetBackgroundMode(x0));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCTryColour(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  class wxColour* x0 INIT_NULLED_OUT;
  class wxColour* x1 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(4);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);
  VAR_STACK_PUSH(3, x1);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_wxColour(p[0], "try-color in dc<%>", 0));
  x1 = WITH_VAR_STACK(objscheme_unbundle_wxColour(p[1], "try-color in dc<%>", 0));

  
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->TryColour(x0, x1));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCDrawBitmap(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  Bool r;
  objscheme_check_valid(obj);
  class wxBitmap* x0 INIT_NULLED_OUT;
  float x1;
  float x2;
  int x3;
  class wxColour* x4 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(4);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);
  VAR_STACK_PUSH(3, x4);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_wxBitmap(p[0], "draw-bitmap in dc<%>", 0));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-bitmap in dc<%>"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_float(p[2], "draw-bitmap in dc<%>"));
  if (n > 3) {
    x3 = WITH_VAR_STACK(unbundle_symset_bitmapDrawStyle(p[3], "draw-bitmap in dc<%>"));
  } else
    x3 = wxSOLID;
  if (n > 4) {
    x4 = WITH_VAR_STACK(objscheme_unbundle_wxColour(p[4], "draw-bitmap in dc<%>", 0));
  } else
    x4 = NULL;

  
  r = WITH_VAR_STACK(DrawBitmap(((wxDC *)((Scheme_Class_Object *)obj)->primdata), x0, x1, x2, x3, x4));

  
  
  return (r ? scheme_true : scheme_false);
}

static Scheme_Object *os_wxDCDrawBitmapRegion(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  Bool r;
  objscheme_check_valid(obj);
  class wxBitmap* x0 INIT_NULLED_OUT;
  float x1;
  float x2;
  float x3;
  float x4;
  nnfloat x5;
  nnfloat x6;
  int x7;
  class wxColour* x8 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(4);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);
  VAR_STACK_PUSH(3, x8);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_wxBitmap(p[0], "draw-bitmap-section in dc<%>", 0));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-bitmap-section in dc<%>"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_float(p[2], "draw-bitmap-section in dc<%>"));
  x3 = WITH_VAR_STACK(objscheme_unbundle_float(p[3], "draw-bitmap-section in dc<%>"));
  x4 = WITH_VAR_STACK(objscheme_unbundle_float(p[4], "draw-bitmap-section in dc<%>"));
  x5 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[5], "draw-bitmap-section in dc<%>"));
  x6 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[6], "draw-bitmap-section in dc<%>"));
  if (n > 7) {
    x7 = WITH_VAR_STACK(unbundle_symset_bitmapDrawStyle(p[7], "draw-bitmap-section in dc<%>"));
  } else
    x7 = wxSOLID;
  if (n > 8) {
    x8 = WITH_VAR_STACK(objscheme_unbundle_wxColour(p[8], "draw-bitmap-section in dc<%>", 0));
  } else
    x8 = NULL;

  DO_OK_CHECK(scheme_false)if (!x0->Ok()) return scheme_false;
  r = WITH_VAR_STACK(DrawBitmapRegion(((wxDC *)((Scheme_Class_Object *)obj)->primdata), x0, x1, x2, x3, x4, x5, x6, x7, x8));

  
  
  return (r ? scheme_true : scheme_false);
}

static Scheme_Object *os_wxDCGetCharWidth(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  float r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->GetCharWidth());

  
  
  return WITH_REMEMBERED_STACK(scheme_make_double(r));
}

static Scheme_Object *os_wxDCGetCharHeight(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  float r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->GetCharHeight());

  
  
  return WITH_REMEMBERED_STACK(scheme_make_double(r));
}

static Scheme_Object *os_wxDCMyTextExtent(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  void* r;
  objscheme_check_valid(obj);
  string x0 INIT_NULLED_OUT;
  class wxFont* x1 INIT_NULLED_OUT;
  Bool x2;
  nnint x3;

  SETUP_VAR_STACK_REMEMBERED(4);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);
  VAR_STACK_PUSH(3, x1);

  
  x0 = (string)WITH_VAR_STACK(objscheme_unbundle_string(p[0], "get-text-extent in dc<%>"));
  if (n > 1) {
    x1 = WITH_VAR_STACK(objscheme_unbundle_wxFont(p[1], "get-text-extent in dc<%>", 1));
  } else
    x1 = NULL;
  if (n > 2) {
    x2 = WITH_VAR_STACK(objscheme_unbundle_bool(p[2], "get-text-extent in dc<%>"));
  } else
    x2 = FALSE;
  if (n > 3) {
    x3 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_integer(p[3], "get-text-extent in dc<%>"));
  } else
    x3 = 0;

  if (x3 > SCHEME_STRLEN_VAL(p[0])) WITH_VAR_STACK(scheme_arg_mismatch(METHODNAME("dc<%>","get-text-extent"), "string index too large: ", p[3]));
  r = WITH_VAR_STACK(MyTextExtent(((wxDC *)((Scheme_Class_Object *)obj)->primdata), x0, x1, x2, x3));

  
  
  return (Scheme_Object*)r;
}

static Scheme_Object *os_wxDCSetTextForeground(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  class wxColour* x0 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_wxColour(p[0], "set-text-foreground in dc<%>", 0));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->SetTextForeground(x0));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCSetTextBackground(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  class wxColour* x0 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_wxColour(p[0], "set-text-background in dc<%>", 0));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->SetTextBackground(x0));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCSetPen(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  class wxPen* x0 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_wxPen(p[0], "set-pen in dc<%>", 0));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->SetPen(x0));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCSetFont(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  class wxFont* x0 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_wxFont(p[0], "set-font in dc<%>", 0));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->SetFont(x0));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCSetBrush(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  class wxBrush* x0 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_wxBrush(p[0], "set-brush in dc<%>", 0));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->SetBrush(x0));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCSetBackground(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  class wxColour* x0 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_wxColour(p[0], "set-background in dc<%>", 0));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->SetBackground(x0));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCGetClippingRegion(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  class wxRegion* r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->GetClippingRegion());

  
  
  return WITH_REMEMBERED_STACK(objscheme_bundle_wxRegion(r));
}

static Scheme_Object *os_wxDCSetClippingRegion(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  class wxRegion* x0 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_wxRegion(p[0], "set-clipping-region in dc<%>", 1));

  if (x0 && (x0->GetDC() != ((wxDC *)((Scheme_Class_Object *)obj)->primdata))) WITH_VAR_STACK(scheme_arg_mismatch(METHODNAME("dc<%>","set-clipping-region"), "provided a different dc's region: ", p[0]));
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->SetClippingRegion(x0));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCSetClippingRect(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  float x0;
  float x1;
  nnfloat x2;
  nnfloat x3;

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_float(p[0], "set-clipping-rect in dc<%>"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "set-clipping-rect in dc<%>"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[2], "set-clipping-rect in dc<%>"));
  x3 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[3], "set-clipping-rect in dc<%>"));

  if (x2 < 0) x2 = 0;if (x3 < 0) x3 = 0;DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->SetClippingRect(x0, x1, x2, x3));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCDrawPolygon(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  int x0;
  class wxPoint* x1 INIT_NULLED_OUT;
  float x2;
  float x3;
  int x4;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x1);

  
  x1 = NULL;
  if (n > 1) {
    x2 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-polygon in dc<%>"));
  } else
    x2 = 0;
  if (n > 2) {
    x3 = WITH_VAR_STACK(objscheme_unbundle_float(p[2], "draw-polygon in dc<%>"));
  } else
    x3 = 0;
  if (n > 3) {
    x4 = WITH_VAR_STACK(unbundle_symset_fillKind(p[3], "draw-polygon in dc<%>"));
  } else
    x4 = wxODDEVEN_RULE;

  x1 = WITH_VAR_STACK(__MakewxPointArray((0 < n) ? p[0] : scheme_null, &x0, METHODNAME("dc<%>","draw-polygon")));DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->DrawPolygon(x0, x1, x2, x3, x4));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCDrawLines(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  int x0;
  class wxPoint* x1 INIT_NULLED_OUT;
  float x2;
  float x3;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x1);

  
  x1 = NULL;
  if (n > 1) {
    x2 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-lines in dc<%>"));
  } else
    x2 = 0;
  if (n > 2) {
    x3 = WITH_VAR_STACK(objscheme_unbundle_float(p[2], "draw-lines in dc<%>"));
  } else
    x3 = 0;

  x1 = WITH_VAR_STACK(__MakewxPointArray((0 < n) ? p[0] : scheme_null, &x0, METHODNAME("dc<%>","draw-lines")));DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->DrawLines(x0, x1, x2, x3));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCDrawEllipse(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  float x0;
  float x1;
  nnfloat x2;
  nnfloat x3;

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_float(p[0], "draw-ellipse in dc<%>"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-ellipse in dc<%>"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[2], "draw-ellipse in dc<%>"));
  x3 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[3], "draw-ellipse in dc<%>"));

  if (x2 <= 0) return scheme_void;if (x3 <= 0) return scheme_void;DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->DrawEllipse(x0, x1, x2, x3));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCDrawArc(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  float x0;
  float x1;
  nnfloat x2;
  nnfloat x3;
  float x4;
  float x5;

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_float(p[0], "draw-arc in dc<%>"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-arc in dc<%>"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[2], "draw-arc in dc<%>"));
  x3 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[3], "draw-arc in dc<%>"));
  x4 = WITH_VAR_STACK(objscheme_unbundle_float(p[4], "draw-arc in dc<%>"));
  x5 = WITH_VAR_STACK(objscheme_unbundle_float(p[5], "draw-arc in dc<%>"));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->DrawArc(x0, x1, x2, x3, x4, x5));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCDrawText(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  string x0 INIT_NULLED_OUT;
  float x1;
  float x2;
  Bool x3;
  nnint x4;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);

  
  x0 = (string)WITH_VAR_STACK(objscheme_unbundle_string(p[0], "draw-text in dc<%>"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-text in dc<%>"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_float(p[2], "draw-text in dc<%>"));
  if (n > 3) {
    x3 = WITH_VAR_STACK(objscheme_unbundle_bool(p[3], "draw-text in dc<%>"));
  } else
    x3 = FALSE;
  if (n > 4) {
    x4 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_integer(p[4], "draw-text in dc<%>"));
  } else
    x4 = 0;

  if (x4 > SCHEME_STRLEN_VAL(p[0])) WITH_VAR_STACK(scheme_arg_mismatch(METHODNAME("dc<%>","draw-text"), "string index too large: ", p[4]));DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->DrawText(x0, x1, x2, x3, x4));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCDrawSpline(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  float x0;
  float x1;
  float x2;
  float x3;
  float x4;
  float x5;

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_float(p[0], "draw-spline in dc<%>"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-spline in dc<%>"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_float(p[2], "draw-spline in dc<%>"));
  x3 = WITH_VAR_STACK(objscheme_unbundle_float(p[3], "draw-spline in dc<%>"));
  x4 = WITH_VAR_STACK(objscheme_unbundle_float(p[4], "draw-spline in dc<%>"));
  x5 = WITH_VAR_STACK(objscheme_unbundle_float(p[5], "draw-spline in dc<%>"));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->DrawSpline(x0, x1, x2, x3, x4, x5));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCDrawRoundedRectangle(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  float x0;
  float x1;
  nnfloat x2;
  nnfloat x3;
  float x4;

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_float(p[0], "draw-rounded-rectangle in dc<%>"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-rounded-rectangle in dc<%>"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[2], "draw-rounded-rectangle in dc<%>"));
  x3 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[3], "draw-rounded-rectangle in dc<%>"));
  if (n > 4) {
    x4 = WITH_VAR_STACK(objscheme_unbundle_float(p[4], "draw-rounded-rectangle in dc<%>"));
  } else
    x4 = 20;

  if (x2 <= 0) return scheme_void;if (x3 <= 0) return scheme_void;DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->DrawRoundedRectangle(x0, x1, x2, x3, x4));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCDrawRectangle(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  float x0;
  float x1;
  nnfloat x2;
  nnfloat x3;

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_float(p[0], "draw-rectangle in dc<%>"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-rectangle in dc<%>"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[2], "draw-rectangle in dc<%>"));
  x3 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_float(p[3], "draw-rectangle in dc<%>"));

  if (x2 <= 0) return scheme_void;if (x3 <= 0) return scheme_void;DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->DrawRectangle(x0, x1, x2, x3));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCDrawPoint(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  float x0;
  float x1;

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_float(p[0], "draw-point in dc<%>"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-point in dc<%>"));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->DrawPoint(x0, x1));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCDrawLine(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  float x0;
  float x1;
  float x2;
  float x3;

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_float(p[0], "draw-line in dc<%>"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "draw-line in dc<%>"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_float(p[2], "draw-line in dc<%>"));
  x3 = WITH_VAR_STACK(objscheme_unbundle_float(p[3], "draw-line in dc<%>"));

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->DrawLine(x0, x1, x2, x3));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxDCClear(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  DO_OK_CHECK(scheme_void)
  WITH_VAR_STACK(((wxDC *)((Scheme_Class_Object *)obj)->primdata)->Clear());

  
  
  return scheme_void;
}

void objscheme_setup_wxDC(void *env)
{
  SETUP_VAR_STACK(1);
  VAR_STACK_PUSH(0, env);

  wxREGGLOB(os_wxDC_class);
  wxREGGLOB(os_wxDC_interface);

  os_wxDC_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "dc%", "object%", NULL, 42));

  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "end-page", os_wxDCEndPage, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "end-doc", os_wxDCEndDoc, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "start-page", os_wxDCStartPage, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "start-doc", os_wxDCStartDoc, 1, 1));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "ok?", os_wxDCOk, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-size", os_wxDCMyGetSize, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-text-foreground", os_wxDCdcGetTextForeground, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-text-background", os_wxDCdcGetTextBackground, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-pen", os_wxDCGetPen, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-font", os_wxDCGetFont, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-brush", os_wxDCGetBrush, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-text-mode", os_wxDCGetBackgroundMode, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-background", os_wxDCGetBackground, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "set-origin", os_wxDCSetDeviceOrigin, 2, 2));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "set-scale", os_wxDCSetUserScale, 2, 2));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "set-text-mode", os_wxDCSetBackgroundMode, 1, 1));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "try-color", os_wxDCTryColour, 2, 2));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-bitmap", os_wxDCDrawBitmap, 3, 5));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-bitmap-section", os_wxDCDrawBitmapRegion, 7, 9));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-char-width", os_wxDCGetCharWidth, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-char-height", os_wxDCGetCharHeight, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-text-extent", os_wxDCMyTextExtent, 1, 4));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "set-text-foreground", os_wxDCSetTextForeground, 1, 1));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "set-text-background", os_wxDCSetTextBackground, 1, 1));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "set-pen", os_wxDCSetPen, 1, 1));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "set-font", os_wxDCSetFont, 1, 1));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "set-brush", os_wxDCSetBrush, 1, 1));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "set-background", os_wxDCSetBackground, 1, 1));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "get-clipping-region", os_wxDCGetClippingRegion, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "set-clipping-region", os_wxDCSetClippingRegion, 1, 1));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "set-clipping-rect", os_wxDCSetClippingRect, 4, 4));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-polygon", os_wxDCDrawPolygon, 1, 4));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-lines", os_wxDCDrawLines, 1, 3));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-ellipse", os_wxDCDrawEllipse, 4, 4));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-arc", os_wxDCDrawArc, 6, 6));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-text", os_wxDCDrawText, 3, 5));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-spline", os_wxDCDrawSpline, 6, 6));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-rounded-rectangle", os_wxDCDrawRoundedRectangle, 4, 5));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-rectangle", os_wxDCDrawRectangle, 4, 4));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-point", os_wxDCDrawPoint, 2, 2));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "draw-line", os_wxDCDrawLine, 4, 4));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxDC_class, "clear", os_wxDCClear, 0, 0));


  WITH_VAR_STACK(scheme_made_class(os_wxDC_class));

  os_wxDC_interface = WITH_VAR_STACK(scheme_class_to_interface(os_wxDC_class, "dc" "<%>"));

  WITH_VAR_STACK(objscheme_add_global_interface(os_wxDC_interface, "dc" "<%>", env));
  WITH_VAR_STACK(objscheme_install_bundler((Objscheme_Bundler)objscheme_bundle_wxDC, wxTYPE_DC));

}

int objscheme_istype_wxDC(Scheme_Object *obj, const char *stop, int nullOK)
{
  REMEMBER_VAR_STACK();
  if (nullOK && XC_SCHEME_NULLP(obj)) return 1;
  if (SAME_TYPE(SCHEME_TYPE(obj), scheme_object_type)
      && scheme_is_subclass(((Scheme_Class_Object *)obj)->sclass,          os_wxDC_class))
    return 1;
  else {
    if (!stop)
       return 0;
    WITH_REMEMBERED_STACK(scheme_wrong_type(stop, nullOK ? "dc% object or " XC_NULL_STR: "dc% object", -1, 0, &obj));
    return 0;
  }
}

Scheme_Object *objscheme_bundle_wxDC(class wxDC *realobj)
{
  Scheme_Class_Object *obj INIT_NULLED_OUT;
  Scheme_Object *sobj INIT_NULLED_OUT;

  if (!realobj) return XC_SCHEME_NULL;

  if (realobj->__gc_external)
    return (Scheme_Object *)realobj->__gc_external;

  SETUP_VAR_STACK(2);
  VAR_STACK_PUSH(0, obj);
  VAR_STACK_PUSH(1, realobj);

  if ((realobj->__type != wxTYPE_DC) && (sobj = WITH_VAR_STACK(objscheme_bundle_by_type(realobj, realobj->__type))))
    return sobj;
  obj = (Scheme_Class_Object *)WITH_VAR_STACK(scheme_make_uninited_object(os_wxDC_class));

  obj->primdata = realobj;
  WITH_VAR_STACK(objscheme_register_primpointer(obj, &obj->primdata));
  obj->primflag = 0;

  realobj->__gc_external = (void *)obj;
  return (Scheme_Object *)obj;
}

class wxDC *objscheme_unbundle_wxDC(Scheme_Object *obj, const char *where, int nullOK)
{
  if (nullOK && XC_SCHEME_NULLP(obj)) return NULL;

  REMEMBER_VAR_STACK();

  (void)objscheme_istype_wxDC(obj, where, nullOK);
  Scheme_Class_Object *o = (Scheme_Class_Object *)obj;
  WITH_REMEMBERED_STACK(objscheme_check_valid(obj));
  if (o->primflag)
    return (os_wxDC *)o->primdata;
  else
    return (wxDC *)o->primdata;
}







class os_wxMemoryDC : public wxMemoryDC {
 public:

  os_wxMemoryDC CONSTRUCTOR_ARGS(());
  ~os_wxMemoryDC();
#ifdef MZ_PRECISE_GC
  void gcMark();
  void gcFixup();
#endif
};

#ifdef MZ_PRECISE_GC
void os_wxMemoryDC::gcMark() {
  wxMemoryDC::gcMark();
}
void os_wxMemoryDC::gcFixup() {
  wxMemoryDC::gcFixup();
}
#endif

static Scheme_Object *os_wxMemoryDC_class;

os_wxMemoryDC::os_wxMemoryDC CONSTRUCTOR_ARGS(())
CONSTRUCTOR_INIT(: wxMemoryDC())
{
}

os_wxMemoryDC::~os_wxMemoryDC()
{
    objscheme_destroy(this, (Scheme_Object *)__gc_external);
}

static Scheme_Object *os_wxMemoryDCGetObject(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  class wxBitmap* r;
  objscheme_check_valid(obj);

  SETUP_VAR_STACK_REMEMBERED(2);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);

  

  
  r = WITH_VAR_STACK(((wxMemoryDC *)((Scheme_Class_Object *)obj)->primdata)->GetObject());

  
  
  return WITH_REMEMBERED_STACK(objscheme_bundle_wxBitmap(r));
}

static Scheme_Object *os_wxMemoryDCSelectObject(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  class wxBitmap* x0 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x0);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_wxBitmap(p[0], "set-bitmap in bitmap-dc%", 1));

  if (x0) { if (!x0->Ok()) WITH_VAR_STACK(scheme_arg_mismatch(METHODNAME("memory-dc%","set-bitmap"), "bad bitmap: ", p[0])); if (BM_SELECTED(x0)) WITH_VAR_STACK(scheme_arg_mismatch(METHODNAME("memory-dc%","set-bitmap"), "bitmap is already installed into a bitmap-dc%: ", p[0])); if (BM_IN_USE(x0)) WITH_VAR_STACK(scheme_arg_mismatch(METHODNAME("memory-dc%","set-bitmap"), "bitmap is currently installed as a control label or pen/brush stipple: ", p[0])); }
  WITH_VAR_STACK(((wxMemoryDC *)((Scheme_Class_Object *)obj)->primdata)->SelectObject(x0));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxMemoryDCSetPixel(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  objscheme_check_valid(obj);
  float x0;
  float x1;
  class wxColour* x2 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x2);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_float(p[0], "set-pixel in bitmap-dc%"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "set-pixel in bitmap-dc%"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_wxColour(p[2], "set-pixel in bitmap-dc%", 1));

  
  WITH_VAR_STACK(((wxMemoryDC *)((Scheme_Class_Object *)obj)->primdata)->SetPixel(x0, x1, x2));

  
  
  return scheme_void;
}

static Scheme_Object *os_wxMemoryDCGetPixel(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
  REMEMBER_VAR_STACK();
  Bool r;
  objscheme_check_valid(obj);
  float x0;
  float x1;
  class wxColour* x2 INIT_NULLED_OUT;

  SETUP_VAR_STACK_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, x2);

  
  x0 = WITH_VAR_STACK(objscheme_unbundle_float(p[0], "get-pixel in bitmap-dc%"));
  x1 = WITH_VAR_STACK(objscheme_unbundle_float(p[1], "get-pixel in bitmap-dc%"));
  x2 = WITH_VAR_STACK(objscheme_unbundle_wxColour(p[2], "get-pixel in bitmap-dc%", 1));

  
  r = WITH_VAR_STACK(((wxMemoryDC *)((Scheme_Class_Object *)obj)->primdata)->GetPixel(x0, x1, x2));

  
  
  return (r ? scheme_true : scheme_false);
}

static Scheme_Object *os_wxMemoryDC_ConstructScheme(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  SETUP_PRE_VAR_STACK(1);
  PRE_VAR_STACK_PUSH(0, obj);
  os_wxMemoryDC *realobj INIT_NULLED_OUT;
  REMEMBER_VAR_STACK();

  SETUP_VAR_STACK_PRE_REMEMBERED(3);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, realobj);

  
  if (n != 0) 
    WITH_VAR_STACK(scheme_wrong_count("initialization in bitmap-dc%", 0, 0, n, p));

  
  realobj = WITH_VAR_STACK(new os_wxMemoryDC CONSTRUCTOR_ARGS(()));
#ifdef MZ_PRECISE_GC
  WITH_VAR_STACK(realobj->gcInit_wxMemoryDC());
#endif
  realobj->__gc_external = (void *)obj;
  objscheme_note_creation(obj);
  
  
  ((Scheme_Class_Object *)obj)->primdata = realobj;
  WITH_REMEMBERED_STACK(objscheme_register_primpointer(obj, &((Scheme_Class_Object *)obj)->primdata));
  ((Scheme_Class_Object *)obj)->primflag = 1;
  return obj;
}

void objscheme_setup_wxMemoryDC(void *env)
{
  SETUP_VAR_STACK(1);
  VAR_STACK_PUSH(0, env);

  wxREGGLOB(os_wxMemoryDC_class);

  os_wxMemoryDC_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "bitmap-dc%", "dc%", os_wxMemoryDC_ConstructScheme, 4));

  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMemoryDC_class, "get-bitmap", os_wxMemoryDCGetObject, 0, 0));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMemoryDC_class, "set-bitmap", os_wxMemoryDCSelectObject, 1, 1));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMemoryDC_class, "set-pixel", os_wxMemoryDCSetPixel, 3, 3));
  WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMemoryDC_class, "get-pixel", os_wxMemoryDCGetPixel, 3, 3));


  WITH_VAR_STACK(scheme_made_class(os_wxMemoryDC_class));

  WITH_VAR_STACK(objscheme_install_bundler((Objscheme_Bundler)objscheme_bundle_wxMemoryDC, wxTYPE_DC_MEMORY));

}

int objscheme_istype_wxMemoryDC(Scheme_Object *obj, const char *stop, int nullOK)
{
  REMEMBER_VAR_STACK();
  if (nullOK && XC_SCHEME_NULLP(obj)) return 1;
  if (SAME_TYPE(SCHEME_TYPE(obj), scheme_object_type)
      && scheme_is_subclass(((Scheme_Class_Object *)obj)->sclass,          os_wxMemoryDC_class))
    return 1;
  else {
    if (!stop)
       return 0;
    WITH_REMEMBERED_STACK(scheme_wrong_type(stop, nullOK ? "bitmap-dc% object or " XC_NULL_STR: "bitmap-dc% object", -1, 0, &obj));
    return 0;
  }
}

Scheme_Object *objscheme_bundle_wxMemoryDC(class wxMemoryDC *realobj)
{
  Scheme_Class_Object *obj INIT_NULLED_OUT;
  Scheme_Object *sobj INIT_NULLED_OUT;

  if (!realobj) return XC_SCHEME_NULL;

  if (realobj->__gc_external)
    return (Scheme_Object *)realobj->__gc_external;

  SETUP_VAR_STACK(2);
  VAR_STACK_PUSH(0, obj);
  VAR_STACK_PUSH(1, realobj);

  if ((realobj->__type != wxTYPE_DC_MEMORY) && (sobj = WITH_VAR_STACK(objscheme_bundle_by_type(realobj, realobj->__type))))
    return sobj;
  obj = (Scheme_Class_Object *)WITH_VAR_STACK(scheme_make_uninited_object(os_wxMemoryDC_class));

  obj->primdata = realobj;
  WITH_VAR_STACK(objscheme_register_primpointer(obj, &obj->primdata));
  obj->primflag = 0;

  realobj->__gc_external = (void *)obj;
  return (Scheme_Object *)obj;
}

class wxMemoryDC *objscheme_unbundle_wxMemoryDC(Scheme_Object *obj, const char *where, int nullOK)
{
  if (nullOK && XC_SCHEME_NULLP(obj)) return NULL;

  REMEMBER_VAR_STACK();

  (void)objscheme_istype_wxMemoryDC(obj, where, nullOK);
  Scheme_Class_Object *o = (Scheme_Class_Object *)obj;
  WITH_REMEMBERED_STACK(objscheme_check_valid(obj));
  if (o->primflag)
    return (os_wxMemoryDC *)o->primdata;
  else
    return (wxMemoryDC *)o->primdata;
}







class os_wxPostScriptDC : public wxPostScriptDC {
 public:

  os_wxPostScriptDC CONSTRUCTOR_ARGS((Bool x0 = TRUE, class wxWindow* x1 = NULL));
  ~os_wxPostScriptDC();
#ifdef MZ_PRECISE_GC
  void gcMark();
  void gcFixup();
#endif
};

#ifdef MZ_PRECISE_GC
void os_wxPostScriptDC::gcMark() {
  wxPostScriptDC::gcMark();
}
void os_wxPostScriptDC::gcFixup() {
  wxPostScriptDC::gcFixup();
}
#endif

static Scheme_Object *os_wxPostScriptDC_class;

os_wxPostScriptDC::os_wxPostScriptDC CONSTRUCTOR_ARGS((Bool x0, class wxWindow* x1))
CONSTRUCTOR_INIT(: wxPostScriptDC(x0, x1))
{
}

os_wxPostScriptDC::~os_wxPostScriptDC()
{
    objscheme_destroy(this, (Scheme_Object *)__gc_external);
}

static Scheme_Object *os_wxPostScriptDC_ConstructScheme(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  SETUP_PRE_VAR_STACK(1);
  PRE_VAR_STACK_PUSH(0, obj);
  os_wxPostScriptDC *realobj INIT_NULLED_OUT;
  REMEMBER_VAR_STACK();
  Bool x0;
  class wxWindow* x1 INIT_NULLED_OUT;

  SETUP_VAR_STACK_PRE_REMEMBERED(4);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, realobj);
  VAR_STACK_PUSH(3, x1);

  
  if ((n > 2)) 
    WITH_VAR_STACK(scheme_wrong_count("initialization in post-script-dc%", 0, 2, n, p));
  if (n > 0) {
    x0 = WITH_VAR_STACK(objscheme_unbundle_bool(p[0], "initialization in post-script-dc%"));
  } else
    x0 = TRUE;
  if (n > 1) {
    x1 = WITH_VAR_STACK(objscheme_unbundle_wxWindow(p[1], "initialization in post-script-dc%", 1));
  } else
    x1 = NULL;

  if (x1 && !wxSubType(((wxObject *)x1)->__type, wxTYPE_FRAME) && !wxSubType(((wxObject *)x1)->__type, wxTYPE_DIALOG_BOX)) scheme_wrong_type(METHODNAME("post-script-dc%","initialization"), "frame or dialog box", 1, n, p);
  realobj = WITH_VAR_STACK(new os_wxPostScriptDC CONSTRUCTOR_ARGS((x0, x1)));
#ifdef MZ_PRECISE_GC
  WITH_VAR_STACK(realobj->gcInit_wxPostScriptDC(x0, x1));
#endif
  realobj->__gc_external = (void *)obj;
  objscheme_note_creation(obj);
  
  
  ((Scheme_Class_Object *)obj)->primdata = realobj;
  WITH_REMEMBERED_STACK(objscheme_register_primpointer(obj, &((Scheme_Class_Object *)obj)->primdata));
  ((Scheme_Class_Object *)obj)->primflag = 1;
  return obj;
}

void objscheme_setup_wxPostScriptDC(void *env)
{
  SETUP_VAR_STACK(1);
  VAR_STACK_PUSH(0, env);

  wxREGGLOB(os_wxPostScriptDC_class);

  os_wxPostScriptDC_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "post-script-dc%", "dc%", os_wxPostScriptDC_ConstructScheme, 0));



  WITH_VAR_STACK(scheme_made_class(os_wxPostScriptDC_class));

  WITH_VAR_STACK(objscheme_install_bundler((Objscheme_Bundler)objscheme_bundle_wxPostScriptDC, wxTYPE_DC_POSTSCRIPT));

}

int objscheme_istype_wxPostScriptDC(Scheme_Object *obj, const char *stop, int nullOK)
{
  REMEMBER_VAR_STACK();
  if (nullOK && XC_SCHEME_NULLP(obj)) return 1;
  if (SAME_TYPE(SCHEME_TYPE(obj), scheme_object_type)
      && scheme_is_subclass(((Scheme_Class_Object *)obj)->sclass,          os_wxPostScriptDC_class))
    return 1;
  else {
    if (!stop)
       return 0;
    WITH_REMEMBERED_STACK(scheme_wrong_type(stop, nullOK ? "post-script-dc% object or " XC_NULL_STR: "post-script-dc% object", -1, 0, &obj));
    return 0;
  }
}

Scheme_Object *objscheme_bundle_wxPostScriptDC(class wxPostScriptDC *realobj)
{
  Scheme_Class_Object *obj INIT_NULLED_OUT;
  Scheme_Object *sobj INIT_NULLED_OUT;

  if (!realobj) return XC_SCHEME_NULL;

  if (realobj->__gc_external)
    return (Scheme_Object *)realobj->__gc_external;

  SETUP_VAR_STACK(2);
  VAR_STACK_PUSH(0, obj);
  VAR_STACK_PUSH(1, realobj);

  if ((realobj->__type != wxTYPE_DC_POSTSCRIPT) && (sobj = WITH_VAR_STACK(objscheme_bundle_by_type(realobj, realobj->__type))))
    return sobj;
  obj = (Scheme_Class_Object *)WITH_VAR_STACK(scheme_make_uninited_object(os_wxPostScriptDC_class));

  obj->primdata = realobj;
  WITH_VAR_STACK(objscheme_register_primpointer(obj, &obj->primdata));
  obj->primflag = 0;

  realobj->__gc_external = (void *)obj;
  return (Scheme_Object *)obj;
}

class wxPostScriptDC *objscheme_unbundle_wxPostScriptDC(Scheme_Object *obj, const char *where, int nullOK)
{
  if (nullOK && XC_SCHEME_NULLP(obj)) return NULL;

  REMEMBER_VAR_STACK();

  (void)objscheme_istype_wxPostScriptDC(obj, where, nullOK);
  Scheme_Class_Object *o = (Scheme_Class_Object *)obj;
  WITH_REMEMBERED_STACK(objscheme_check_valid(obj));
  if (o->primflag)
    return (os_wxPostScriptDC *)o->primdata;
  else
    return (wxPostScriptDC *)o->primdata;
}


#ifdef MZ_PRECISE_GC
END_XFORM_SKIP;
#endif

#ifdef wx_x

class basePrinterDC : public wxObject
{
public:
  basePrinterDC(wxWindow *w);
};

basePrinterDC::basePrinterDC(wxWindow *)
{
  scheme_raise_exn(MZEXN_MISC_UNSUPPORTED,
		   "%s", 
		   METHODNAME("printer-dc%","initialization")": not supported for X Windows");
}

#else

class basePrinterDC : public wxPrinterDC
{
public:
  basePrinterDC(wxWindow *w);
};

basePrinterDC::basePrinterDC(wxWindow *w) 
: wxPrinterDC( )
{
}

#endif

#ifdef MZ_PRECISE_GC
START_XFORM_SKIP;
#endif




class os_basePrinterDC : public basePrinterDC {
 public:

  os_basePrinterDC CONSTRUCTOR_ARGS((class wxWindow* x0 = NULL));
  ~os_basePrinterDC();
#ifdef MZ_PRECISE_GC
  void gcMark();
  void gcFixup();
#endif
};

#ifdef MZ_PRECISE_GC
void os_basePrinterDC::gcMark() {
  basePrinterDC::gcMark();
}
void os_basePrinterDC::gcFixup() {
  basePrinterDC::gcFixup();
}
#endif

static Scheme_Object *os_basePrinterDC_class;

os_basePrinterDC::os_basePrinterDC CONSTRUCTOR_ARGS((class wxWindow* x0))
CONSTRUCTOR_INIT(: basePrinterDC(x0))
{
}

os_basePrinterDC::~os_basePrinterDC()
{
    objscheme_destroy(this, (Scheme_Object *)__gc_external);
}

static Scheme_Object *os_basePrinterDC_ConstructScheme(Scheme_Object *obj, int n,  Scheme_Object *p[])
{
  SETUP_PRE_VAR_STACK(1);
  PRE_VAR_STACK_PUSH(0, obj);
  os_basePrinterDC *realobj INIT_NULLED_OUT;
  REMEMBER_VAR_STACK();
  class wxWindow* x0 INIT_NULLED_OUT;

  SETUP_VAR_STACK_PRE_REMEMBERED(4);
  VAR_STACK_PUSH(0, p);
  VAR_STACK_PUSH(1, obj);
  VAR_STACK_PUSH(2, realobj);
  VAR_STACK_PUSH(3, x0);

  
  if ((n > 1)) 
    WITH_VAR_STACK(scheme_wrong_count("initialization in printer-dc%", 0, 1, n, p));
  if (n > 0) {
    x0 = WITH_VAR_STACK(objscheme_unbundle_wxWindow(p[0], "initialization in printer-dc%", 1));
  } else
    x0 = NULL;

  if (x0 && !wxSubType(((wxObject *)x0)->__type, wxTYPE_FRAME) && !wxSubType(((wxObject *)x0)->__type, wxTYPE_DIALOG_BOX)) scheme_wrong_type(METHODNAME("printer-dc%","initialization"), "frame or dialog box", 0, n, p);
  realobj = WITH_VAR_STACK(new os_basePrinterDC CONSTRUCTOR_ARGS((x0)));
#ifdef MZ_PRECISE_GC
  WITH_VAR_STACK(realobj->gcInit_basePrinterDC(x0));
#endif
  realobj->__gc_external = (void *)obj;
  objscheme_note_creation(obj);
  
  
  ((Scheme_Class_Object *)obj)->primdata = realobj;
  WITH_REMEMBERED_STACK(objscheme_register_primpointer(obj, &((Scheme_Class_Object *)obj)->primdata));
  ((Scheme_Class_Object *)obj)->primflag = 1;
  return obj;
}

void objscheme_setup_basePrinterDC(void *env)
{
  SETUP_VAR_STACK(1);
  VAR_STACK_PUSH(0, env);

  wxREGGLOB(os_basePrinterDC_class);

  os_basePrinterDC_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "printer-dc%", "dc%", os_basePrinterDC_ConstructScheme, 0));



  WITH_VAR_STACK(scheme_made_class(os_basePrinterDC_class));

  WITH_VAR_STACK(objscheme_install_bundler((Objscheme_Bundler)objscheme_bundle_basePrinterDC, wxTYPE_DC_PRINTER));

}

int objscheme_istype_basePrinterDC(Scheme_Object *obj, const char *stop, int nullOK)
{
  REMEMBER_VAR_STACK();
  if (nullOK && XC_SCHEME_NULLP(obj)) return 1;
  if (SAME_TYPE(SCHEME_TYPE(obj), scheme_object_type)
      && scheme_is_subclass(((Scheme_Class_Object *)obj)->sclass,          os_basePrinterDC_class))
    return 1;
  else {
    if (!stop)
       return 0;
    WITH_REMEMBERED_STACK(scheme_wrong_type(stop, nullOK ? "printer-dc% object or " XC_NULL_STR: "printer-dc% object", -1, 0, &obj));
    return 0;
  }
}

Scheme_Object *objscheme_bundle_basePrinterDC(class basePrinterDC *realobj)
{
  Scheme_Class_Object *obj INIT_NULLED_OUT;
  Scheme_Object *sobj INIT_NULLED_OUT;

  if (!realobj) return XC_SCHEME_NULL;

  if (realobj->__gc_external)
    return (Scheme_Object *)realobj->__gc_external;

  SETUP_VAR_STACK(2);
  VAR_STACK_PUSH(0, obj);
  VAR_STACK_PUSH(1, realobj);

  if ((realobj->__type != wxTYPE_DC_PRINTER) && (sobj = WITH_VAR_STACK(objscheme_bundle_by_type(realobj, realobj->__type))))
    return sobj;
  obj = (Scheme_Class_Object *)WITH_VAR_STACK(scheme_make_uninited_object(os_basePrinterDC_class));

  obj->primdata = realobj;
  WITH_VAR_STACK(objscheme_register_primpointer(obj, &obj->primdata));
  obj->primflag = 0;

  realobj->__gc_external = (void *)obj;
  return (Scheme_Object *)obj;
}

class basePrinterDC *objscheme_unbundle_basePrinterDC(Scheme_Object *obj, const char *where, int nullOK)
{
  if (nullOK && XC_SCHEME_NULLP(obj)) return NULL;

  REMEMBER_VAR_STACK();

  (void)objscheme_istype_basePrinterDC(obj, where, nullOK);
  Scheme_Class_Object *o = (Scheme_Class_Object *)obj;
  WITH_REMEMBERED_STACK(objscheme_check_valid(obj));
  if (o->primflag)
    return (os_basePrinterDC *)o->primdata;
  else
    return (basePrinterDC *)o->primdata;
}





#ifdef MZ_PRECISE_GC
END_XFORM_SKIP;
#endif
