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

📄 calc.c

📁 SEAL是DOS 下的32位保护模式的GUI程序
💻 C
📖 第 1 页 / 共 2 页
字号:

                make_operation(e->message);

                clear_event(e);

             }; break;

             case MSG_MINUS : {

                make_operation(e->message);

                clear_event(e);

             }; break;

             case MSG_PERCENT : {

                make_operation(e->message);

                clear_event(e);

             }; break;

             case MSG_DELENO : {

                make_operation(e->message);

                clear_event(e);

             }; break;

             case MSG_KRAT : {

                make_operation(e->message);

                clear_event(e);

             }; break;

             case MSG_SQRT : {

                make_operation(e->message);

                clear_event(e);

             }; break;

             case MSG_SQR : {

                make_operation(e->message);

                clear_event(e);

             }; break;

             case MSG_ROVNO : {

                make_operation(e->message);

                clear_event(e);

             }; break;

             case MSG_C : {

                main_text->set_text(main_text, "0");

                main_c = true;

                main_bodka = false;

                main_minus = false;

                main_vysledok = 0.0;

                main_operacia = 0;

                clear_event(e);

             }; break;

             case MSG_PLUSMINUS : if ( !main_c ) {

                l_text text = main_minus?del_minus(main_text->text):set_format_text(NULL, "-%s", main_text->text);

                main_text->set_text(main_text, text);

                _free(text);

                main_minus = !main_minus;

                clear_event(e);

             }; break;

             case MSG_BODKA : if ( !main_bodka ) {

                l_text text = main_c?_strdup("0."):set_format_text(NULL, "%s%c", main_text->text, '.');

                main_text->set_text(main_text, text);

                _free(text);

                main_c = false;

                main_bodka = true;

                clear_event(e);

             }; break;

             case MSG_PI : {

                l_text text = set_format_text(NULL, "%f", M_PI);

                main_text->set_text(main_text, text);

                _free(text);

                main_c = false;

                main_bodka = false;

                clear_event(e);

             }; break;

             case MSG_ABOUT:
                seal2_app_about("Calculator", load_image("/system/bmp/calc.ico,32"));
                clear_event(e);
                break;
        };

    };

  };

};


/*
 * Init application window
 *
*/

void init_form ( void )
{

  // create new application window

  t_rect r = rect_assign(100, 100, 355, 330);
  t_rect s;

  p_textline t;
  p_button   b;

  main_form = new_application(r, "Calculator", WF_MINIMIZE, &form_translate_event);

  main_form->icon16 = (BITMAP*)GET_DATA(dat, 0);

  main_form->menu = standard_system_menu_items(main_form,
                new_menu_line(
                new_menu_item("About Calculator...", 0, 0, MSG_ABOUT, NULL,
   NULL)));

  // insert application window to the desktop

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

  // TODO : insert other objects to the form

  s = VIEW(main_form)->size_limits(VIEW(main_form));

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


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

  main_text = textline_init(_malloc(sizeof(t_textline)), r, 40, 1+2);

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


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

  b = button_init(_malloc(sizeof(t_button)), r, "7", MSG_7, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(main_text));

  OBJECT(main_text)->set_options(OBJECT(main_text), OB_OF_SELECTABLE, false);

  main_text->set_text(main_text, "0");


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

  b = button_init(_malloc(sizeof(t_button)), r, "4", MSG_4, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "1", MSG_1, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "0", MSG_0, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


  r = rect_assign(r.b.x+10, s.a.y, r.b.x+RECT1, s.a.y+RECT);

  b = button_init(_malloc(sizeof(t_button)), r, "8", MSG_8, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "5", MSG_5, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "2", MSG_2, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "+/-", MSG_PLUSMINUS, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


  r = rect_assign(r.b.x+10, s.a.y, r.b.x+RECT1, s.a.y+RECT);

  b = button_init(_malloc(sizeof(t_button)), r, "9", MSG_9, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "6", MSG_6, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "3", MSG_3, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, ".", MSG_BODKA, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


  r = rect_assign(r.b.x+10, s.a.y, r.b.x+RECT1, s.a.y+RECT);

  b = button_init(_malloc(sizeof(t_button)), r, "+", MSG_PLUS, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "-", MSG_MINUS, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "*", MSG_KRAT, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "/", MSG_DELENO, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


  r = rect_assign(r.b.x+10, s.a.y, r.b.x+RECT+RECT1+10, s.a.y+RECT);

  b = button_init(_malloc(sizeof(t_button)), r, "C", MSG_C, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "sqrt", MSG_SQRT, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "pi", MSG_PI, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "=", MSG_ROVNO, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


  r = rect_assign(r.b.x-RECT, s.a.y+RECT1, r.b.x, s.a.y+RECT1+RECT);

  b = button_init(_malloc(sizeof(t_button)), r, "sqr", MSG_SQR, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));


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

  b = button_init(_malloc(sizeof(t_button)), r, "%", MSG_PERCENT, BF_NORMAL);

  OBJECT(main_form)->insert(OBJECT(main_form), OBJECT(b));

};


/*
 * Application main function
 *
*/
app_begin ( void ) {

  // begin of application

  if ( ap_process == AP_INIT ) {

     // maximum number of calls

     AP_SETNUMOFCALLS(1);

     // TODO : your functions

     dat = conv_to_skipcolor_data(DLXGetFileData(ap_id), CO_SKIP_RED, CO_SKIP_GREEN, CO_SKIP_BLUE);
     init_form();

  };

  // end of application

  if ( ap_process == AP_DONE ) {

  };

} app_end;

⌨️ 快捷键说明

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