⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 app.c

📁 SEAL是DOS 下的32位保护模式的GUI程序
💻 C
📖 第 1 页 / 共 3 页
字号:
    /* insert button into the window */
    OBJECT(o)->insert(OBJECT(o), OBJECT(button_init(_malloc(sizeof(t_button)), t, TXT_CLOSE, MSG_CLOSE, BF_NORMAL)));

    t = rect_move(t, bw+10, 0);

  };

  if ( bflags & MB_CANCEL ) {  /* button CANCEL */

    /* move button rectangle for the right place */
    t.b.x = t.a.x+bw;

    /* insert button into the window */
    OBJECT(o)->insert(OBJECT(o), OBJECT(button_init(_malloc(sizeof(t_button)), t, TXT_CANCEL, MSG_CANCEL, BF_NORMAL)));

    t = rect_move(t, bw+10, 0);

  };

  if ( bflags & MB_HELP ) { /* button HELP */

    /* move button rectangle for the right place */
    t.b.x = t.a.x+bw;

    /* insert button into the window */
    OBJECT(o)->insert(OBJECT(o), OBJECT(button_init(_malloc(sizeof(t_button)), t, TXT_HELP, MSG_HELP, BF_NORMAL)));

    t = rect_move(t, bw+10, 0);

  };

  if ( bflags & MB_NO ) { /* button NO */

    /* move button rectangle for the right place */
    t.b.x = t.a.x+bw;

    /* insert button into the window */
    OBJECT(o)->insert(OBJECT(o), OBJECT(button_init(_malloc(sizeof(t_button)), t, TXT_NO, MSG_NO, BF_NORMAL)));

    t = rect_move(t, bw+10, 0);

  };

  if ( bflags & MB_CONTINUE ) { /* button CONTINUE */

    /* move button rectangle for the right place */
    t.b.x = t.a.x+bw;

    /* insert button into the window */
    OBJECT(o)->insert(OBJECT(o), OBJECT(button_init(_malloc(sizeof(t_button)), t, TXT_CONTINUE, MSG_CONTINUE, BF_NORMAL)));

    t = rect_move(t, bw+10, 0);

  };

  if ( bflags & MB_EXIT ) { /* button EXIT */

    /* move button rectangle for the right place */
    t.b.x = t.a.x+bw;

    /* insert button into the window */
    OBJECT(o)->insert(OBJECT(o), OBJECT(button_init(_malloc(sizeof(t_button)), t, TXT_EXIT, MSG_EXIT, BF_NORMAL)));

    t = rect_move(t, bw+10, 0);

  };

  if ( bflags & MB_YESTOALL ) { /* button YESTOALL */

    /* move button rectangle for the right place */
    t.b.x = t.a.x+bw;

    /* insert button into the window */
    OBJECT(o)->insert(OBJECT(o), OBJECT(button_init(_malloc(sizeof(t_button)), t, TXT_YESTOALL, MSG_YESTOALL, BF_NORMAL)));

    t = rect_move(t, bw+10, 0);

  };

  if ( bflags & MB_NOTOALL ) { /* button NOTOALL */

    /* move button rectangle for the right place */
    t.b.x = t.a.x+bw;

    /* insert button into the window */
    OBJECT(o)->insert(OBJECT(o), OBJECT(button_init(_malloc(sizeof(t_button)), t, TXT_NOTOALL, MSG_NOTOALL, BF_NORMAL)));

    t = rect_move(t, bw+10, 0);

  };

  return o; /* return window */

};


static void message_ev ( p_object o, t_event *e )
{
  RETVIEW(o, e);

  if ( o->phase == PH_PREPROCESS ) {

    if ( e->type == EV_MESSAGE && is_my_message(o, e) ) {

      o->end_state = e->message;

      clear_event(e);

    };

  };

};

l_dword  msgbox_arg ( l_dword wflags, l_dword  bflags, l_text in_text, va_list args )
{

  p_appwin w = (p_appwin)_malloc(sizeof(t_appwin));

  l_dword  msg = MSG_NOTHING;

  if ( w ) {

    t_rect  r = rect_assign(0, 0, 300, 200);
    l_text  capt = NULL;
    l_char  iflag = 0;

    MSG_FLAGS_SETUP;

    w = message_init_ex(OBJECT(desktop), w, r, capt, 0, iflag, bflags, &message_ev, in_text, args);

    msg = desktop->execute_view(desktop, VIEW(w));

    dispose(OBJECT(w));

  };

  return msg;

};


l_dword  msgbox ( l_dword wflags, l_dword  bflags, l_text in_text, ... )
{
   va_list arg;
   l_dword msg;

   va_start(arg, in_text);

   msg = msgbox_arg(wflags, bflags, in_text, arg);

   va_end(arg);

   return msg;
};


/* same as msgbox, but it sets minimum width of window */

l_dword  msgboxsize_arg ( l_rect minx, l_dword wflags, l_dword  bflags, l_text in_text, va_list args )
{
  p_appwin w = (p_appwin)_malloc(sizeof(t_appwin));

  l_dword  msg = MSG_NOTHING;

  if ( w ) {

    t_rect  r = rect_assign(0, 0, minx, 200);
    l_text  capt = NULL;
    l_char  iflag = 0;

    MSG_FLAGS_SETUP;

    w = message_init_ex(OBJECT(desktop), w, r, capt, WF_MINSIZE, iflag, bflags, &message_ev, in_text, args);

    msg = desktop->execute_view(desktop, VIEW(w));

    dispose(OBJECT(w));

  };

  return msg;

};


l_dword  msgboxsize ( l_rect minx, l_dword wflags, l_dword  bflags, l_text in_text, ... )
{
   va_list arg;
   l_dword msg;

   va_start(arg, in_text);

   msg = msgboxsize_arg(minx, wflags, bflags, in_text, arg);

   va_end(arg);

   return msg;
};


/*
   show info window
*/

p_appwin msginfo_arg ( l_rect minx, l_dword wflags, l_text in_text, va_list args )
{
  p_appwin w = (p_appwin)_malloc(sizeof(t_appwin));

  if ( w ) {

    t_rect  r = rect_assign(0, 0, minx, 200);
    l_text  capt = NULL;
    l_char  iflag = 0;

    MSG_FLAGS_SETUP;

    w = message_init_ex(OBJECT(desktop), w, r, capt, WF_MINSIZE, iflag, 0, NULL, in_text, args);

  //  delay(500);

  };

  return w;

};


p_appwin msginfo ( l_rect minx, l_dword wflags, l_text in_text, ... )
{
   va_list  arg;
   p_appwin w;

   va_start(arg, in_text);

   w = msginfo_arg(minx, wflags, in_text, arg);

   va_end(arg);

   return w;
};


/*
   show prosess window
*/

p_appwin msgprocess_ex ( l_rect minx, l_text process_title, l_text in_text,
                         l_dword size, l_dword *ind, l_int flags, l_hdlx id,
                         void (*trans_ev)(p_object, p_event) )
{

   t_rect   r = rect_assign(0, 0, minx, 150);
   p_appwin o = appwin_init(APPWIN(_malloc(sizeof(t_appwin))), r, process_title, flags, id, trans_ev);

   if ( o ) {

       VIEW(o)->align |= TX_ALIGN_CENTER;

       OBJECT(desktop)->insert(OBJECT(desktop), OBJECT(o));

       r = VIEW(o)->size_limits(VIEW(o));

       r = rect_assign(r.a.x+10, r.a.y+10, r.b.x-10, r.a.y+30);

       OBJECT(o)->insert(OBJECT(o), OBJECT(stattext_init(
                                           STATTEXT(_malloc(sizeof(t_stattext))),
                                           r,
                                           TX_ALIGN_LEFT,
                                           in_text)
                                    ));

       r = rect_assign(r.a.x, r.b.y+10, r.b.x, r.b.y+25);

       OBJECT(o)->insert(OBJECT(o), OBJECT(process_init(
                                           PROCESS(_malloc(sizeof(t_process))),
                                           r,
                                           size, ind)
                                    ));

       r = rect_assign(r.a.x, r.b.y+20, r.a.x+100, r.b.y+50);

       OBJECT(o)->insert(OBJECT(o), OBJECT(button_init(
                                           BUTTON(_malloc(sizeof(t_button))),
                                           r,
                                           TXT_CANCEL,
                                           MSG_CLOSE,
                                           BF_DEFAULT)
                                    ));



   };

   return o;

};


p_appwin msgprocess ( l_rect minx, l_text process_title, l_text in_text, l_dword size, l_dword *ind )
{

   return msgprocess_ex ( minx, process_title, in_text, size, ind, 0, 0, NULL );
};




/* frame object */

void    frame_draw_title ( p_window o )
{
};


void    frame_draw ( p_view o )
{
  t_rect  r = o->get_local_extent(o);
  t_rect  safe = r;
  t_point p = o->get_global_point(o, r.a);


  BITMAP *out = o->begin_paint(o, &p, r);

  if ( out ) {

    o->background(o, out, rect_move(r, p.x, p.y));
    button(out, r.a.x+p.x, r.a.y+p.y, r.b.x+p.x, r.b.y+p.y, VIEW(o)->get_color(VIEW(o), 0), VIEW(o)->get_color(VIEW(o), 3));
    button(out, r.a.x+p.x+1, r.a.y+p.y+1, r.b.x+p.x-1, r.b.y+p.y-1, VIEW(o)->get_color(VIEW(o), 1), VIEW(o)->get_color(VIEW(o), 2));

  };

  o->end_of_paint(o, safe);
};


p_window  _frame_init ( p_window o, t_rect r )
{

  if ( !o ) return NULL;

  win_init(o, r, NULL, 0);

  VIEW(o)->draw = &frame_draw;
  o->draw_title = &frame_draw_title;

  return o;

};



static l_int  _seal_app_error ( l_int errtype, l_text str, ... )
{

  switch ( errtype ) {

    case ERR_NONREGULAR : {

      va_list arg;
      l_int ret = 0;

      va_start(arg, str);

      ret = (msgbox_arg(MW_ERROR, MB_EXIT|MB_CONTINUE, str, arg)==MSG_CONTINUE);

      va_end(arg);

      return ret;

    }; break;

    case ERR_INFO : {

      va_list arg;

      va_start(arg, str);

      msgbox_arg(MW_WARNING, MB_OK, str, arg);

      va_end(arg);

      return 1;

    }; break;

  };

  return 0;

};


void appsys_init ( void ) {

   seal_error = &_seal_app_error;

   apppastitle = get_skin(skin_file,"window");
   appacttitle = get_skin(skin_file,"window_passive");
   appbody = get_skin(skin_file,"window_body");

};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -