home *** CD-ROM | disk | FTP | other *** search
/ Phoenix Heaven Sunny 2 / APPARE2.BIN / oh_towns / art2 / src.lzh / ALERT.C < prev    next >
C/C++ Source or Header  |  1995-06-19  |  6KB  |  226 lines

  1. /*===========================================
  2.           DolphMorph(ドルフモーフ)
  3.  
  4.       モーフィング&変形アニメ作成ソフト
  5.  
  6.   モーフィングアルゴリズム: EAST 1994
  7.   インターフェース作成:     松内 良介 1994
  8. ===========================================*/
  9. #if 0
  10.  
  11.     alert.c
  12.         警告メッセージ、確認メッセージの表示
  13.  
  14.     static    void    setTitleAndMessage(int idTitleMsg, char *title,
  15.                                        int *idDispMsg, int msgNum, char *msg)
  16.  
  17.             void    dispAlertMessage(char *title, char *msg)
  18.             void    alert_noMemory(char *title)
  19.             int        dispCheckMessage(char *title, char *msg, char *okmsg)
  20.  
  21.             int        AlertOkDBtnFunc(kobj, messId, argc, pev, trigger)
  22.             int        CheckAlertOkDBtnFunc(kobj, messId, argc, pev, trigger)
  23.             int        CheckAlertCancelDBtnFunc(kobj, messId, argc, pev, trigger)
  24. #endif
  25.  
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #include <winb.h>
  30. #include <te.h>
  31. #include <fntb.h>
  32. #include <gui.h>
  33. #include <ctype.h>
  34.  
  35. #include "art.h"
  36. #include "guisub.h"
  37. #include "desktop.h"
  38.  
  39. #define    _iskanji(c)    (((c)&0xff) >= 0x81 && ((c)&0xff)<=0x9f || \
  40.                      ((c)&0xff) >= 0xe0 && ((c)&0xff)<=0xfc)
  41. #define    _iskanji1(kcode)    ((((kcode)>>8)&0xff) <= 0x97)
  42.  
  43. /*--------------------------------------------------------*/
  44. /*                        部品ID                        */
  45. /*--------------------------------------------------------*/
  46.  
  47.     int    idAlertDlg = -1 ;
  48.     int    idAlertTitleMsg = -1 ;
  49.     int    idAlertOkDBtn = -1 ;
  50.     int    idAlertMsg[3] = -1 ;
  51.     int    idCheckAlertDlg = -1 ;
  52.     int    idCheckAlertTitleMsg = -1 ;
  53.     int    idCheckAlertMsg[3] = -1 ;
  54.     int    idCheckAlertOkDBtn = -1 ;
  55.     int    idCheckAlertOkMsg = -1 ;
  56.     int    idCheckAlertCancelDBtn = -1 ;
  57.     int    idCheckAlertCancelMsg = -1 ;
  58.     int    idBigAlertDlg = -1 ;
  59.     int    idBigAlertTitleMsg = -1 ;
  60.     int    idBigAlertOkDBtn = -1 ;
  61.     int    idBigAlertMsg[3] = -1 ;
  62.  
  63. /*--------------------------------------------------------*/
  64. /*               タイトル、表示文字列の設定               */
  65. /*--------------------------------------------------------*/
  66.  
  67.     static char msgbuf[3][100];    // [3] で決め打ちはよくない…
  68.     static char titlebuf[100];
  69.  
  70.     static void setTitleAndMessage(int idTitleMsg, char *title,
  71.                                     int *idDispMsg, int msgNum, char *msg)
  72.     {
  73.         int idx;
  74.       /* タイトル文字列の設定 */
  75.         titlebuf[0] = 0;
  76.         if (title != NULL)
  77.             strncpy(titlebuf, title, 63);
  78.         MMI_SendMessage(idTitleMsg, MM_SETMSG, 1, title);
  79.       /* 表示文字列の設定 */
  80.         int width;
  81.         FRAME fr;
  82.         RM_getFrame(idDispMsg[0], &fr);
  83.         width = (fr.rdwx - fr.lupx + 1) / 6;
  84.         for (idx=0; idx<msgNum; idx++)
  85.         {
  86.             memset(msgbuf[idx], ' ', width);
  87.             msgbuf[idx][width] = '\0';
  88.         }
  89.         if (msg == NULL)
  90.             goto NOMSG;
  91.         int clm;
  92.         idx = 0;
  93.         clm = 0;
  94.         char *sp;
  95.         sp = msg;
  96.         while (*sp != '\0' && idx < msgNum)
  97.         {
  98.             if (*sp == '\n' || clm >= width-1)
  99.             {
  100.                 idx++;
  101.                 clm = 0;
  102.                 if (*sp == '\n')
  103.                     sp++;
  104.             }
  105.             else if (!_iskanji(*sp))
  106.                 msgbuf[idx][clm++] = *sp++;
  107.             else
  108.             {
  109.                 msgbuf[idx][clm++] = *sp++;
  110.                 msgbuf[idx][clm++] = *sp++;
  111.             }
  112.         }
  113.        NOMSG:;
  114.         for (idx=0; idx<msgNum; idx++)
  115.             MMI_SendMessage(idDispMsg[idx], MM_SETMSG, 1, msgbuf[idx]);
  116.     }
  117.  
  118. /*--------------------------------------------------------*/
  119. /*                   警告メッセージ表示                   */
  120. /*--------------------------------------------------------*/
  121.  
  122.     static void dispAlertMessageSub(int idAlert)
  123.     {
  124.         int moscsr;
  125.         MG_PushPtr(MOSICON_ARROW, &moscsr);
  126.         EXECDIALOG(idAlert);
  127.         MG_PopPtr(moscsr);
  128.     }
  129.  
  130.     void dispAlertMessage(char *title, char *msg)
  131.     {
  132.         setTitleAndMessage(idAlertTitleMsg, title,
  133.                            idAlertMsg, INTNUM(idAlertMsg), msg);
  134.         dispAlertMessageSub(idAlertDlg);
  135.     }
  136.  
  137.     void dispBigAlertMessage(char *title, char *msg)
  138.     {
  139.         setTitleAndMessage(idBigAlertTitleMsg, title,
  140.                            idBigAlertMsg, INTNUM(idBigAlertMsg), msg);
  141.         dispAlertMessageSub(idBigAlertDlg);
  142.     }
  143.  
  144.     void alert_noMemory(char *title)
  145.     {
  146.         dispAlertMessage(title, "メモリ容量不足です");
  147.     }
  148.  
  149. /*--------------------------------------------------------*/
  150. /*                   確認メッセージ表示                   */
  151. /*--------------------------------------------------------*/
  152.  
  153.     static int nCheck;
  154.  
  155.     int dispCheckMessage(char *title, char *msg, char *okmsg)
  156.     {
  157.         int idx;
  158.         static char OkMsg[20];
  159.         if (okmsg != NULL)
  160.             strncpy(OkMsg, okmsg, 19);
  161.         else
  162.             strcpy(OkMsg, "続行");
  163.         int moscsr;
  164.         MG_PushPtr(MOSICON_ARROW, &moscsr);
  165.         MMI_SendMessage(idCheckAlertOkMsg, MM_SETMSG, 1, OkMsg);
  166.         setTitleAndMessage(idCheckAlertTitleMsg, title,
  167.                            idCheckAlertMsg, INTNUM(idCheckAlertMsg), msg);
  168.         EXECDIALOG(idCheckAlertDlg);
  169.         MG_PopPtr(moscsr);
  170.         return nCheck;
  171.     }
  172.  
  173. /*--------------------------------------------------------*/
  174. /*                   部品の呼び出し関数                   */
  175. /*--------------------------------------------------------*/
  176.  
  177.     /*    initDataZALERT:idAlertOkDBtn:MJ_DBUTTONL40の呼び出し関数    */
  178.     int    AlertOkDBtnFunc(kobj, messId, argc, pev, trigger)
  179.     int        kobj ;
  180.     int        messId ;
  181.     int        argc ;
  182.     EVENT    *pev ;
  183.     int        trigger ;
  184.     {
  185.         MMI_SetHaltFlag(TRUE);
  186.         return NOERR ;
  187.     }
  188.  
  189.     /*    initDataZALERT:idBigAlertOkDBtn:MJ_DBUTTONL40の呼び出し関数    */
  190.     int    BigAlertOkDBtnFunc(kobj, messId, argc, pev, trigger)
  191.     int        kobj ;
  192.     int        messId ;
  193.     int        argc ;
  194.     EVENT    *pev ;
  195.     int        trigger ;
  196.     {
  197.         MMI_SetHaltFlag(TRUE);
  198.         return NOERR ;
  199.     }
  200.  
  201.     /*    initDataZALERT:idCheckAlertOkDBtn:MJ_DBUTTONL40の呼び出し関数    */
  202.     int    CheckAlertOkDBtnFunc(kobj, messId, argc, pev, trigger)
  203.     int        kobj ;
  204.     int        messId ;
  205.     int        argc ;
  206.     EVENT    *pev ;
  207.     int        trigger ;
  208.     {
  209.         nCheck = 0;
  210.         MMI_SetHaltFlag(TRUE);
  211.         return NOERR ;
  212.     }
  213.  
  214.     /*    initDataZALERT:idCheckAlertCancelDBtn:MJ_DBUTTONL40の呼び出し関数    */
  215.     int    CheckAlertCancelDBtnFunc(kobj, messId, argc, pev, trigger)
  216.     int        kobj ;
  217.     int        messId ;
  218.     int        argc ;
  219.     EVENT    *pev ;
  220.     int        trigger ;
  221.     {
  222.         nCheck = -1;
  223.         MMI_SetHaltFlag(TRUE);
  224.         return NOERR ;
  225.     }
  226.