Пример #1
0
int ustrcat(wchar *dest, char *src)
{
	int dest_len, src_len;
	wchar *uni;

	dest_len=ustrlen(dest);
	src_len=(int)strlen(src);

	uni=new wchar[src_len+1];
	ustrcpy(uni,src);
	ustrcat(dest,uni);
	delete[] uni;
	return dest_len+src_len;
}
Пример #2
0
/* Builds a string corresponding to the options set in 'opt'
 * and writes in the config file
 */
static void build_settings(int opt, char *section, char *name) {
	char buf[2048];

	usetc(buf, 0);

	if (opt & AGL_ALLEGRO_FORMAT)
		ustrcat(buf, "allegro_format ");
	if (opt & AGL_RED_DEPTH)
		ustrcat(buf, "red_depth ");
	if (opt & AGL_GREEN_DEPTH)
		ustrcat(buf, "green_depth ");
	if (opt & AGL_BLUE_DEPTH)
		ustrcat(buf, "blue_depth ");
	if (opt & AGL_ALPHA_DEPTH)
		ustrcat(buf, "alpha_depth ");
	if (opt & AGL_COLOR_DEPTH)
		ustrcat(buf, "color_depth ");
	if (opt & AGL_ACC_RED_DEPTH)
		ustrcat(buf, "accum_red_depth ");
	if (opt & AGL_ACC_GREEN_DEPTH)
		ustrcat(buf, "accum_green_depth ");
	if (opt & AGL_ACC_BLUE_DEPTH)
		ustrcat(buf, "accum_blue_depth ");
	if (opt & AGL_ACC_ALPHA_DEPTH)
		ustrcat(buf, "accum_alpha_depth ");
	if (opt & AGL_DOUBLEBUFFER)
		ustrcat(buf, "double_buffer ");
	if (opt & AGL_STEREO)
		ustrcat(buf, "stereo_display ");
	if (opt & AGL_AUX_BUFFERS)
		ustrcat(buf, "aux_buffers ");
	if (opt & AGL_Z_DEPTH)
		ustrcat(buf, "z_depth ");
	if (opt & AGL_STENCIL_DEPTH)
		ustrcat(buf, "stencil_depth ");
	if (opt & AGL_WINDOW_X)
		ustrcat(buf, "window_x ");
	if (opt & AGL_WINDOW_Y)
		ustrcat(buf, "window_y ");
	if (opt & AGL_FULLSCREEN)
		ustrcat(buf, "fullscreen ");
	if (opt & AGL_WINDOWED)
		ustrcat(buf, "windowed ");
	if (opt & AGL_VIDEO_MEMORY_POLICY)
		ustrcat(buf, "video_memory_policy ");
	if (opt & AGL_SAMPLE_BUFFERS)
		ustrcat(buf, "sample_buffers ");
	if (opt & AGL_SAMPLES)
		ustrcat(buf, "samples ");
	if (opt & AGL_FLOAT_COLOR)
		ustrcat(buf, "float_color ");
	if (opt & AGL_FLOAT_Z)
		ustrcat(buf, "float_depth ");
		
	set_config_string(section, name, buf);
}
Пример #3
0
std::string Accelerator::KeyCombo::toString()
{
  // Same order that Allegro scancodes
  static const char *table[] = {
    NULL,
    "A",
    "B",
    "C",
    "D",
    "E",
    "F",
    "G",
    "H",
    "I",
    "J",
    "K",
    "L",
    "M",
    "N",
    "O",
    "P",
    "Q",
    "R",
    "S",
    "T",
    "U",
    "V",
    "W",
    "X",
    "Y",
    "Z",
    "0",
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "0 Pad",
    "1 Pad",
    "2 Pad",
    "3 Pad",
    "4 Pad",
    "5 Pad",
    "6 Pad",
    "7 Pad",
    "8 Pad",
    "9 Pad",
    "F1",
    "F2",
    "F3",
    "F4",
    "F5",
    "F6",
    "F7",
    "F8",
    "F9",
    "F10",
    "F11",
    "F12",
    "Esc",
    "~",
    "-",
    "=",
    "Backspace",
    "Tab",
    "[",
    "]",
    "Enter",
    ";",
    "\'",
    "\\",
    "KEY_BACKSLASH2",
    ",",
    ".",
    "/",
    "Space",
    "Ins",
    "Del",
    "Home",
    "End",
    "PgUp",
    "PgDn",
    "Left",
    "Right",
    "Up",
    "Down",
    "/ Pad",
    "* Pad",
    "- Pad",
    "+ Pad",
    "Delete Pad",
    "Enter Pad",
    "PrtScr",
    "Pause",
    "KEY_ABNT_C1",
    "Yen",
    "Kana",
    "KEY_CONVERT",
    "KEY_NOCONVERT",
    "KEY_AT",
    "KEY_CIRCUMFLEX",
    "KEY_COLON2",
    "Kanji",
  };

  char buf[256];
  ustrcpy(buf, "");

  // Shifts
  if (this->modifiers & kKeyCtrlModifier)
    ustrcat(buf, "Ctrl+");

  if (this->modifiers & kKeyAltModifier)
    ustrcat(buf, "Alt+");

  if (this->modifiers & kKeyShiftModifier)
    ustrcat(buf, "Shift+");

  // Key
  if (this->ascii)
    usprintf(buf+ustrlen(buf), "%c", toupper(this->ascii));
  else if (this->scancode)
    ustrcat(buf, table[this->scancode]);
  else
    ustrcat(buf, "Unknown");

  return buf;
}
Пример #4
0
void makefilename(UNCH *dest, UNCH *src, UNCH *ext){
	ustrcpy(dest, src);
	UNCH * e = ustrrchr(dest, '.');
	if (e != 0) ustrcpy(e,ext);
	else ustrcat(dest, ext);
}
Пример #5
0
/* fs_edit_proc:
 *  Dialog procedure for the file selector editable string.
 */
static int fs_edit_proc(int msg, DIALOG *d, int c)
{
   char *s = d->dp;
   int list_size;
   int found = 0;
   char b[512];
   int ch, attr;
   int i;

   if (msg == MSG_START) {
      fix_filename_path(b, s, sizeof(b));
      ustrcpy(s, b);
   }

   if (msg == MSG_KEY) {
      if ((!ugetc(s)) || (ugetat(s, -1) == DEVICE_SEPARATOR))
	 ustrcat(s, uconvert_ascii("./", NULL));

      fix_filename_path(b, s, sizeof(b));
      ustrcpy(s, b);

      ch = ugetat(s, -1);
      if ((ch != '/') && (ch != OTHER_PATH_SEPARATOR)) {
	 if (file_exists(s, FA_RDONLY | FA_HIDDEN | FA_DIREC, &attr)) {
	    if (attr & FA_DIREC)
	       put_backslash(s);
	    else
	       return D_CLOSE;
	 }
	 else
	    return D_CLOSE;
      }

      scare_mouse();
      SEND_MESSAGE(file_selector+FS_FILES, MSG_START, 0);
      /* did we `cd ..' ? */
      if (ustrlen(updir)) {
	 /* now we have to find a directory name equal to updir */
	 for (i = 0; i<flist->size; i++) {
	    if (!ustrcmp(updir, flist->name[i])) {  /* we got it ! */
	       file_selector[FS_FILES].d1 = i;
	       /* we have to know the number of visible lines in the filelist */
	       /* -1 to avoid an off-by-one problem */
               list_size = (file_selector[FS_FILES].h-4) / text_height(font) - 1;
               if (i>list_size)
		  file_selector[FS_FILES].d2 = i-list_size;
	       else
		  file_selector[FS_FILES].d2 = 0;
               found = 1;
	       break;  /* ok, our work is done... */
	    }
	 }
	 /* by some strange reason, we didn't find the old directory... */
         if (!found) {
            file_selector[FS_FILES].d1 = 0;
            file_selector[FS_FILES].d2 = 0;
         }
      }
      /* and continue... */
      SEND_MESSAGE(file_selector+FS_FILES, MSG_DRAW, 0);
      SEND_MESSAGE(d, MSG_START, 0);
      SEND_MESSAGE(d, MSG_DRAW, 0);
      unscare_mouse();

      return D_O_K;
   }

   if (msg == MSG_UCHAR) {
      if ((c >= 'a') && (c <= 'z')) {
	 if (!ALLEGRO_LFN)
	    c = utoupper(c);
      }
      else if (c == '/') {
	 c = OTHER_PATH_SEPARATOR;
      }
      else if (ALLEGRO_LFN) {
	 if ((c > 127) || (c < 32))
	    return D_O_K;
      }
      else {
	 if ((c != OTHER_PATH_SEPARATOR) && (c != '_') &&
	     (c != DEVICE_SEPARATOR) && (c != '.') &&
	     ((c < 'A') || (c > 'Z')) && ((c < '0') || (c > '9')))
	    return D_O_K;
      }
   }

   return x_edit_proc(msg, d, c);
}
Пример #6
0
int main(int argc, char *argv[])
{
   DATAFILE *data;
   FONT *f;
   BITMAP *buffer;
   int i, j, k, height;
   char buf[256], tmp[256], tmp2[256];
   int counter = 0, drawn = 0;
   int scroll_w, scroll_h;
   int background_color;

   /* set the text encoding format BEFORE initializing the library */
   set_uformat(U_UNICODE);

   /*  past this point, every string that we pass to or retrieve
    *  from any Allegro API call must be in 16-bit Unicode format
    */

   srand(time(NULL));
   if (allegro_init() != 0)
      return 1;
   install_keyboard();
   install_timer();

   /* load the datafile containing the Unicode font */
   replace_filename(buf, uconvert_ascii(argv[0], tmp), uconvert_ascii(DATAFILE_NAME, tmp2), sizeof(buf));
   data = load_datafile(buf);
   if (!data) {
      allegro_message(uconvert_ascii("Unable to load %s\n", tmp), buf);
      return -1;
   }

   /* set the graphics mode */
   if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) {
      if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) != 0) {
	 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
	 allegro_message(uconvert_ascii("Unable to set any graphic mode\n%s\n", tmp), allegro_error);
	 return 1;
      }
   }

   /* set the window title for windowed modes */
   set_window_title(uconvert_ascii("Unicode example program", tmp));

   /* create a buffer for drawing */
   buffer = create_bitmap(SCREEN_W, SCREEN_H);

   /* get a handle to the Unicode font */
   f = data[0].dat;
   height = text_height(f);

   /* The are for the text messages. If it gets too crowded once we have more
    * languages, this can be increased.
    */
   scroll_w = SCREEN_W * 2;
   scroll_h = SCREEN_H + height;

   /* one of the bright colors in the default palette */
   background_color = 56 + AL_RAND() % 48;

   /* prepare the messages */
   for (i = 0; i < NLANGUAGES; i++) {

      /* the regular Standard C string manipulation functions don't work
       * with 16-bit Unicode, so we use the Allegro Unicode API
       */
      message[i].str = malloc(ustrsize(message[i].data) + ustrsizez(allegro_str));

      if (message[i].prefix_allegro) {
         ustrcpy(message[i].str, allegro_str);
         ustrcat(message[i].str, message[i].data);
      }
      else {
         ustrcpy(message[i].str, message[i].data);
         ustrcat(message[i].str, allegro_str);
      }

      message[i].w = text_length(f, message[i].str);
      message[i].h = text_height(f);

      /* one of the dark colors in the default palette */
      message[i].c = 104 + AL_RAND() % 144;

      message[i].dx *= 1 + AL_RAND() % 4;
      message[i].dy = AL_RAND() % 3 - 1;

      /* find not-overlapped position, try 1000 times */
      for (k = 0; k < 1000; k++) {
         message[i].x = AL_RAND() % scroll_w;
         /* make sure the message is not sliced by a screen edge */
         message[i].y = 10 + AL_RAND() % (SCREEN_H - height - 20);
         for (j = 0; j < i; j++) {
            if (overlap(i, j, 10))
               break;
         }
         if (j == i)
            break;
      }
   }

   install_int_ex(ticker, BPS_TO_TIMER(30));
   /* do the scrolling */
   while (!keypressed()) {
      /* Animation. */
      while (counter <= ticks) {
         for (i = 0; i < NLANGUAGES; i++) {
            message[i].x += message[i].dx;
            if (message[i].x >= scroll_w)
               message[i].x -= scroll_w;
            if (message[i].x < 0)
               message[i].x += scroll_w;
            message[i].y += message[i].dy;
            if (message[i].y >= scroll_h)
               message[i].y -= scroll_h;
            if (message[i].y < 0)
               message[i].y += scroll_h;
         }
         counter++;
      }

      /* Draw current frame. */
      if (drawn < counter) {
         clear_to_color(buffer, background_color);
         for (i = 0; i < NLANGUAGES; i++) {
            char *str = message[i].str;
            int x = message[i].x;
            int y = message[i].y;
            int c = message[i].c;
            /* draw it 4 times to get the wrap-around effect */
            textout_ex(buffer, f, str, x, y, c, -1);
            textout_ex(buffer, f, str, x - scroll_w, y, c, -1);
            textout_ex(buffer, f, str, x, y - scroll_h, c, -1);
            textout_ex(buffer, f, str, x - scroll_w, y - scroll_h, c, -1);
         }
         blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
         drawn = counter;
      }
      else {
         rest(10); /* We are too fast, give time to the OS. */
      }
   }

   destroy_bitmap(buffer);

   unload_datafile(data);

   return 0;
}
Пример #7
0
/*----------------------------------------------------------------------
  CallbackExtPrintmenu
  analyse les retours des extensions du formulaire d'impression. 
  ----------------------------------------------------------------------*/
void                CallbackExtPrintmenu (int ref, int val, STRING txt)
{
  int      i;
  CHAR_T   BufMenu[MAX_TXT_LEN];
  ThotBool okprint;

  switch (ref)
    {
    case NumZoneFirstPage:
      NewFirstPage=val;
      break;
    case NumZoneNbOfCopies:
      NewNbCopies=val;
      break;
    case NumZoneReduction:
      if (NewReduction != val)
	NewReduction = val;
      break;
    case NumZoneLastPage:
      NewLastPage = val;
      break;
    case NumMenuNbPagesPerSheet:
      switch (val)
	{
	case 0:
	  NewPagesPerSheet  = 1;
	  break;
	case 1:
	  NewPagesPerSheet  = 2;
	  break;
	case 2:
	  NewPagesPerSheet = 4;
	  break;
	}
     break;
    case NumMenuViewsToPrint:
      LesVuesImprimables[EntreesMenuVuesAImprimer[val] - 1].VdOpen =
	        !LesVuesImprimables[EntreesMenuVuesAImprimer[val] - 1].VdOpen;
      break;
    case NumFormPrint:
      FirstPage = NewFirstPage;
      LastPage = NewLastPage;
      NbCopies = NewNbCopies;
      Reduction = NewReduction;
      PagesPerSheet = NewPagesPerSheet;
      okprint = FALSE;
      BufMenu[0] = EOS;
      for (i=0;i<NbPrintViews;i++)
	{ 
	  if( LesVuesImprimables[EntreesMenuVuesAImprimer[i]-1].VdOpen )
	    {
	      okprint=TRUE;
	      ustrcat (BufMenu, LesVuesImprimables[EntreesMenuVuesAImprimer[i]-1].VdViewName);
	      ustrcat (BufMenu, " ");
	    }
	}
      if(okprint)
	{
	  i = ustrlen (BufMenu);
	  BufMenu[i - 1] = WC_EOS;
	  TtaPrint (docPrint, BufMenu, NULL);
	}
      break;

    default:
      break;

    } 
}