/* fs_dlist_getter: * Listbox data getter routine for the file selector disk list. */ static const char *fs_dlist_getter(int index, int *list_size) { static char d[8]; int pos, c; if(index < 0) { if(list_size) *list_size = count_disks(); return NULL; } c = 'A' + get_x_drive(index+1); if((c < 'A') || (c > 'Z')) c = 'C'; pos = usetc(d, c); pos += usetc(d+pos, DEVICE_SEPARATOR); pos += usetc(d+pos, OTHER_PATH_SEPARATOR); usetc(d+pos, 0); return d; }
static void gtk_draw_menu_item(MENU *m, int x, int y, int w, int h, int bar, int sel) { BITMAP *bmp = gui_get_screen(); int fg, bg; int i, j; char buf[256], *tok; if (m->flags & D_DISABLED) { fg = nshadow; bg = normal; } else { fg = black; bg = (sel) ? highlight : normal; } rectfill(bmp, x+1, y+1, x+w-3, y+h-4, bg); if (ugetc(m->text)) { i = 0; j = ugetc(m->text); while ((j) && (j != '\t')) { i += usetc(buf+i, j); j = ugetc(m->text+i); } usetc(buf+i, 0); gui_textout_ex(bmp, buf, x+8, y+1, fg, bg, FALSE); if (j == '\t') { tok = m->text+i + uwidth(m->text+i); gui_textout_ex(bmp, tok, x+w-gui_strlen(tok)-10, y+1, fg, bg, FALSE); } if ((m->child) && (!bar)) draw_sprite(bmp, menu_arrow_bmp, x+w-12, y+(h-menu_arrow_bmp->h)/2); } else { hline(bmp, x+4, y+text_height(font)/2+2, x+w-4, nshadow); hline(bmp, x+4, y+text_height(font)/2+3, x+w-4, highlight); } if (m->flags & D_SELECTED) { line(bmp, x+1, y+text_height(font)/2+1, x+3, y+text_height(font)+1, fg); line(bmp, x+3, y+text_height(font)+1, x+6, y+2, fg); } }
std::string make_utf8_seq(int codepoint) { int num_bytes = ucwidth(codepoint); char byte_sequence[num_bytes + 1]; // +1 for terminating 0 usetc(byte_sequence, codepoint); byte_sequence[num_bytes] = 0; return std::string(byte_sequence); }
/* _al_getdcwd: * Returns the current directory on the specified drive. */ void _al_getdcwd(int drive, char *buf, int size) { char tmp[1024]; if (get_filename_encoding() != U_UNICODE) { if (_getdcwd(drive+1, tmp, sizeof(tmp))) do_uconvert(tmp, U_ASCII, buf, U_CURRENT, size); else usetc(buf, 0); } else { if (_wgetdcwd(drive+1, (wchar_t*)tmp, sizeof(tmp)/sizeof(wchar_t))) do_uconvert(tmp, U_UNICODE, buf, U_CURRENT, size); else usetc(buf, 0); } }
/* fs_dlist_proc: * Dialog procedure for the file selector disk list. */ int fs_dlist_proc(int msg, DIALOG *d, int c) { DIALOG *parent = (DIALOG *)d->dp3; char *s = (char *)parent[FS_EDIT].dp; int ret, i, temp; if(msg == MSG_START) { d->d1 = d->d2 = 0; temp = utoupper(ugetc(s)); if(((temp >= 'A') && (temp <= 'Z')) && (ugetat(s, 1) == DEVICE_SEPARATOR)) { temp -= 'A'; for(i=0; i<temp; i++) if(_al_drive_exists(i)) d->d1++; } } ret = jwin_droplist_proc(msg, d, c); if(ret & D_CLOSE) { temp = 'A' + get_x_drive(d->d1+1); if((temp < 'A') || (temp > 'Z')) temp = 'C'; s += usetc(s, temp); s += usetc(s, DEVICE_SEPARATOR); s += usetc(s, OTHER_PATH_SEPARATOR); usetc(s, 0); object_message(parent +FS_FILES, MSG_START, 0); object_message(parent +FS_FILES, MSG_DRAW, 0); object_message(parent +FS_EDIT, MSG_START, 0); object_message(parent +FS_EDIT, MSG_DRAW, 0); return ret - D_CLOSE + D_O_K; } return ret; }
/* _al_getdcwd: * Returns the current directory on the specified drive. */ void _al_getdcwd(int drive, char *buf, int size) { char tmp[1024]; if (getcwd(tmp, sizeof(tmp))) do_uconvert(tmp, U_UTF8, buf, U_CURRENT, size); else usetc(buf, 0); }
static void test_unicode_acs(const FONT *f, int c, int c0, int x) { char s[4] = ""; s[0] = c; x += 8*(c-c0); puttext(f, s, x, 10); if (usetc(s, acs_to_unicode(c)) > 0) puttext(f, s, x, 12+text_height(f)); }
/* 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); }
/* sys_directx_get_executable_name: * Returns full path to the current executable. */ static void sys_directx_get_executable_name(char *output, int size) { char *temp = _AL_MALLOC_ATOMIC(size); if (GetModuleFileName(allegro_inst, temp, size)) do_uconvert(temp, U_ASCII, output, U_CURRENT, size); else usetc(output, 0); _AL_FREE(temp); }
/* create_directx_window: * Creates the Allegro window. */ static HWND create_directx_window(void) { static int first = 1; WNDCLASS wnd_class; char fname[1024]; HWND wnd; if (first) { /* setup the window class */ wnd_class.style = CS_HREDRAW | CS_VREDRAW; wnd_class.lpfnWndProc = directx_wnd_proc; wnd_class.cbClsExtra = 0; wnd_class.cbWndExtra = 0; wnd_class.hInstance = allegro_inst; wnd_class.hIcon = LoadIcon(allegro_inst, "allegro_icon"); if (!wnd_class.hIcon) wnd_class.hIcon = LoadIcon(NULL, IDI_APPLICATION); wnd_class.hCursor = LoadCursor(NULL, IDC_ARROW); wnd_class.hbrBackground = NULL; wnd_class.lpszMenuName = NULL; wnd_class.lpszClassName = ALLEGRO_WND_CLASS; RegisterClass(&wnd_class); /* what are we called? */ get_executable_name(fname, sizeof(fname)); ustrlwr(fname); usetc(get_extension(fname), 0); if (ugetat(fname, -1) == '.') usetat(fname, -1, 0); do_uconvert(get_filename(fname), U_CURRENT, wnd_title, U_ASCII, WND_TITLE_SIZE); first = 0; } /* create the window now */ wnd = CreateWindowEx(WS_EX_APPWINDOW, ALLEGRO_WND_CLASS, wnd_title, WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX, -100, -100, 0, 0, NULL, NULL, allegro_inst, NULL); if (!wnd) { _TRACE(PREFIX_E "CreateWindowEx() failed (%s)\n", win_err_str(GetLastError())); return NULL; } ShowWindow(wnd, SW_SHOWNORMAL); SetForegroundWindow(wnd); UpdateWindow(wnd); return wnd; }
/* fs_dlist_proc: * Dialog procedure for the file selector disk list. */ static int fs_dlist_proc(int msg, DIALOG *d, int c) { char *s = file_selector[FS_EDIT].dp; int ret, i, temp; if (msg == MSG_START) { d->d1 = d->d2 = 0; temp = utoupper(ugetc(s)); if (((temp >= 'A') && (temp <= 'Z')) && (ugetat(s, 1) == DEVICE_SEPARATOR)) { temp -= 'A'; for (i=0; i<temp; i++) if (drive_exists(i)) d->d1++; } } ret = d_text_list_proc(msg, d, c); if (ret == D_CLOSE) { temp = 'A' + get_x_drive(d->d1+1); if ((temp < 'A') || (temp > 'Z')) temp = 'C'; s += usetc(s, temp); s += usetc(s, DEVICE_SEPARATOR); s += usetc(s, OTHER_PATH_SEPARATOR); usetc(s, 0); scare_mouse(); SEND_MESSAGE(file_selector+FS_FILES, MSG_START, 0); SEND_MESSAGE(file_selector+FS_FILES, MSG_DRAW, 0); SEND_MESSAGE(file_selector+FS_EDIT, MSG_START, 0); SEND_MESSAGE(file_selector+FS_EDIT, MSG_DRAW, 0); unscare_mouse(); return D_O_K; } return ret; }
static int test_utf8_enc() { char s1[4]; char s2[4]; int c, n; for (c=0; c <= 0xffff; c++) { n = usetc(s1, c); s1[n] = '\0'; n = setc_utf8(s2, c); s2[n] = '\0'; if (strcmp(s1, s2)) return 0; } return 1; }
/** \ingroup core * * Installs the AllegroGL addon to Allegro. * Allegro should already be initialized with allegro_init() * or install_allegro(). * * \return 0 on success; -1 on failure. * * \see remove_allegro_gl() */ int install_allegro_gl(void) { if (!system_driver) return -1; if (atexit(remove_allegro_gl)) return -1; if (system_driver->gfx_drivers) saved_gfx_drivers = system_driver->gfx_drivers; else saved_gfx_drivers = list_saved_gfx_drivers; system_driver->gfx_drivers = our_gfx_drivers; allegro_gl_clear_settings(); /* Save and replace old blit_between_formats methods */ #ifdef ALLEGRO_COLOR8 __blit_between_formats8 = __linear_vtable8.blit_between_formats; __linear_vtable8.blit_between_formats = allegro_gl_memory_blit_between_formats; #endif #ifdef ALLEGRO_COLOR16 __blit_between_formats15 = __linear_vtable15.blit_between_formats; __linear_vtable15.blit_between_formats = allegro_gl_memory_blit_between_formats; __blit_between_formats16 = __linear_vtable16.blit_between_formats; __linear_vtable16.blit_between_formats = allegro_gl_memory_blit_between_formats; #endif #ifdef ALLEGRO_COLOR24 __blit_between_formats24 = __linear_vtable24.blit_between_formats; __linear_vtable24.blit_between_formats = allegro_gl_memory_blit_between_formats; #endif #ifdef ALLEGRO_COLOR32 __blit_between_formats32 = __linear_vtable32.blit_between_formats; __linear_vtable32.blit_between_formats = allegro_gl_memory_blit_between_formats; #endif usetc(allegro_gl_error, 0); return 0; }
/* _set_gfx_mode: * Called by set_gfx_mode(). Separated to make a clear difference between * the virtual GFX_SAFE driver and the rest. The allow_config parameter, * if true, allows the configuration to override the graphics card/driver * when using GFX_AUTODETECT. */ static int _set_gfx_mode(int card, int w, int h, int v_w, int v_h, int allow_config) { _DRIVER_INFO *driver_list; GFX_DRIVER *drv; char tmp1[64], tmp2[64]; AL_CONST char *dv; int flags = 0; int c; ASSERT(system_driver); ASSERT(card != GFX_SAFE); /* remember the current console state */ if (gfx_virgin) { TRACE(PREFIX_I "First call, remembering console state.\n"); LOCK_FUNCTION(_stub_bank_switch); LOCK_FUNCTION(blit); if (system_driver->save_console_state) system_driver->save_console_state(); _add_exit_func(shutdown_gfx, "shutdown_gfx"); gfx_virgin = FALSE; } timer_simulate_retrace(FALSE); _screen_split_position = 0; /* close down any existing graphics driver */ if (gfx_driver) { TRACE(PREFIX_I "Closing graphics driver (%p) ", gfx_driver); TRACE("%s.\n", gfx_driver->ascii_name); if (_al_linker_mouse) _al_linker_mouse->show_mouse(NULL); while (vram_bitmap_list) destroy_bitmap(vram_bitmap_list->bmp); bmp_read_line(screen, 0); bmp_write_line(screen, 0); bmp_unwrite_line(screen); if (gfx_driver->scroll) gfx_driver->scroll(0, 0); if (gfx_driver->exit) gfx_driver->exit(screen); destroy_bitmap(screen); gfx_driver = NULL; screen = NULL; gfx_capabilities = 0; } /* We probably don't want to do this because it makes * Allegro "forget" the color layout of previously set * graphics modes. But it should be retained if bitmaps * created in those modes are to be used in the new mode. */ #if 0 /* restore default truecolor pixel format */ _rgb_r_shift_15 = 0; _rgb_g_shift_15 = 5; _rgb_b_shift_15 = 10; _rgb_r_shift_16 = 0; _rgb_g_shift_16 = 5; _rgb_b_shift_16 = 11; _rgb_r_shift_24 = 0; _rgb_g_shift_24 = 8; _rgb_b_shift_24 = 16; _rgb_r_shift_32 = 0; _rgb_g_shift_32 = 8; _rgb_b_shift_32 = 16; _rgb_a_shift_32 = 24; #endif gfx_capabilities = 0; _set_current_refresh_rate(0); /* return to text mode? */ if (card == GFX_TEXT) { TRACE(PREFIX_I "Closing, restoring original console state.\n"); if (system_driver->restore_console_state) system_driver->restore_console_state(); if (_gfx_bank) { _AL_FREE(_gfx_bank); _gfx_bank = NULL; } TRACE(PREFIX_I "Graphic mode closed.\n"); return 0; } /* now to the interesting part: let's try to find a graphics driver */ usetc(allegro_error, 0); /* ask the system driver for a list of graphics hardware drivers */ if (system_driver->gfx_drivers) driver_list = system_driver->gfx_drivers(); else driver_list = _gfx_driver_list; /* filter specific fullscreen/windowed driver requests */ if (card == GFX_AUTODETECT_FULLSCREEN) { flags |= GFX_DRIVER_FULLSCREEN_FLAG; card = GFX_AUTODETECT; } else if (card == GFX_AUTODETECT_WINDOWED) { flags |= GFX_DRIVER_WINDOWED_FLAG; card = GFX_AUTODETECT; } if (card == GFX_AUTODETECT) { /* autodetect the driver */ int found = FALSE; tmp1[0] = '\0'; /* first try the config variables */ if (allow_config) { /* try the gfx_card variable if GFX_AUTODETECT or GFX_AUTODETECT_FULLSCREEN was selected */ if (!(flags & GFX_DRIVER_WINDOWED_FLAG)) found = get_config_gfx_driver(uconvert_ascii("gfx_card", tmp1), w, h, v_w, v_h, flags, driver_list); /* try the gfx_cardw variable if GFX_AUTODETECT or GFX_AUTODETECT_WINDOWED was selected */ if (!(flags & GFX_DRIVER_FULLSCREEN_FLAG) && !found) found = get_config_gfx_driver(uconvert_ascii("gfx_cardw", tmp1), w, h, v_w, v_h, flags, driver_list); } /* go through the list of autodetected drivers if none was previously found */ if (!found) { TRACE(PREFIX_I "Autodetecting graphic driver.\n"); for (c=0; driver_list[c].driver; c++) { if (driver_list[c].autodetect) { drv = driver_list[c].driver; if (gfx_driver_is_valid(drv, flags)) { screen = init_gfx_driver(drv, w, h, v_w, v_h); if (screen) break; } } } } else { TRACE(PREFIX_I "GFX_AUTODETECT overridden through configuration:" " %s.\n", tmp1); } } else { /* search the list for the requested driver */ drv = get_gfx_driver_from_id(card, driver_list); if (drv) screen = init_gfx_driver(drv, w, h, v_w, v_h); } /* gracefully handle failure */ if (!screen) { gfx_driver = NULL; /* set by init_gfx_driver() */ if (!ugetc(allegro_error)) ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Unable to find a suitable graphics driver")); TRACE(PREFIX_E "Failed setting graphic driver %d.\n", card); return -1; } /* set the basic capabilities of the driver */ if ((VIRTUAL_W > SCREEN_W) || (VIRTUAL_H > SCREEN_H)) { if (gfx_driver->scroll) gfx_capabilities |= GFX_CAN_SCROLL; if ((gfx_driver->request_scroll) || (gfx_driver->request_video_bitmap)) gfx_capabilities |= GFX_CAN_TRIPLE_BUFFER; } /* check whether we are instructed to disable vsync */ dv = get_config_string(uconvert_ascii("graphics", tmp1), uconvert_ascii("disable_vsync", tmp2), NULL); if ((dv) && ((c = ugetc(dv)) != 0) && ((c == 'y') || (c == 'Y') || (c == '1'))) _wait_for_vsync = FALSE; else _wait_for_vsync = TRUE; TRACE(PREFIX_I "The driver %s wait for vsync.\n", (_wait_for_vsync) ? "will" : "won't"); /* Give the gfx driver an opportunity to set the drawing mode */ if ((gfx_driver->drawing_mode) && (!_dispsw_status)) gfx_driver->drawing_mode(); clear_bitmap(screen); /* set up the default colors */ for (c=0; c<256; c++) _palette_color8[c] = c; set_palette(default_palette); if (_al_linker_mouse) _al_linker_mouse->set_mouse_etc(); LOCK_DATA(gfx_driver, sizeof(GFX_DRIVER)); _register_switch_bitmap(screen, NULL); TRACE(PREFIX_I "set_gfx_card success for %dx%dx%d.\n", screen->w, screen->h, bitmap_color_depth(screen)); return 0; }
int d_aase_edit_proc(int msg, DIALOG *d, int c) { int ret; if (msg == MSG_START) { /* this is mainly for `file_select', because the size that it put to the `gui_edit_proc' is very small */ d->h = MAX(d->h, 3 + text_height(font) + 3); } else if (msg == MSG_DRAW) { int f, l, p, w, x, fg, b, scroll; char buf[16]; char *s; int rtm; agup_edit_adjust_position (d); if (!(d->flags & D_INTERNAL)) d->w -= 6; s = (char *)d->dp; l = ustrlen(s); if (d->d2 > l) d->d2 = l; /* calculate maximal number of displayable characters */ if (d->d2 == l) { usetc(buf+usetc(buf, ' '), 0); x = text_length(font, buf); } else x = 0; b = 0; for (p=d->d2; p>=0; p--) { usetc(buf+usetc(buf, ugetat(s, p)), 0); x += text_length(font, buf); b++; if (x > d->w) break; } if (x <= d->w) { b = l; scroll = FALSE; } else { b--; scroll = TRUE; } d->w += 6; ase_rectedge(screen, d->x, d->y, d->x+d->w-1, d->y+d->h-1, makecol(0, 0, 0), makecol(255, 255, 255)); ase_rectedge(screen, d->x+1, d->y+1, d->x+d->w-2, d->y+d->h-2, makecol(128, 128, 128), makecol(192, 192, 192)); ase_rectgouraud(screen, d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3, (d->flags & D_DISABLED)? 128: 224, 255); fg = (d->flags & D_DISABLED) ? aase_mg_color : d->fg; x = 3; if (scroll) { p = d->d2-b+1; b = d->d2; } else p = 0; for (; p<=b; p++) { f = ugetat(s, p); usetc(buf+usetc(buf, (f) ? f : ' '), 0); w = text_length(font, buf); if (x+w > d->w-2) break; f = ((p == d->d2) && (d->flags & D_GOTFOCUS)); rtm = text_mode((f) ? fg : -1); textout(screen, font, buf, d->x+x, d->y+d->h/2-text_height(font)/2, (f) ? d->bg : fg); text_mode(rtm); x += w; } if (d->flags & D_INTERNAL) d->w -= 6; agup_edit_restore_position (d); return D_O_K; } d->w -= 6; d->flags |= D_INTERNAL; ret = d_agup_adjusted_edit_proc(msg, d, c); d->flags &= ~D_INTERNAL; d->w += 6; return ret; }
static void abitmap_draw_menu_item (MENU * m, int x, int y, int w, int h, int bar, int sel) { BITMAP *bmp = gui_get_screen(); int i, j; char buf[256], *tok; int c; int fg; int x2 = x, y2 = y, w2 = w, h2 = h; if (m->flags & D_DISABLED) c = 2; else c = 0; if (sel) c = 1; if (bar) { fg = theme->bitmaps[B_MENUBAR_ITEM][c].color; y2 -= 1; h2 += 3; } else { fg = theme->bitmaps[B_MENU_ITEM][c].color; x2 -= 1; w2 += 3; } /* See the previous function. */ if (!menu_done) { /* Draw the menu background. */ if (bar) abitmap_draw_bmp (bmp, &theme->bitmaps[B_MENUBAR][c], last_x, last_y, last_w, last_h); else abitmap_draw_bmp (bmp, &theme->bitmaps[B_MENU][c], last_x, last_y, last_w, last_h); menu_done = TRUE; } abitmap_draw_bmp (bmp, &theme->bitmaps[bar ? B_MENUBAR_ITEM : B_MENU_ITEM][c], x2, y2, w2, h2); if (m->flags & D_SELECTED) { /* checked menu item */ abitmap_draw_bmp (bmp, &theme->bitmaps[B_MENU_CHECK][c], x, y, 12, h); } if (ugetc (m->text)) { i = 0; j = ugetc (m->text); while ((j) && (j != '\t')) { i += usetc (buf + i, j); j = ugetc (m->text + i); } usetc (buf + i, 0); gui_textout_ex (bmp, buf, x + 8, y + 1, fg, -1, FALSE); if (j == '\t') { tok = m->text + i + uwidth (m->text + i); gui_textout_ex (bmp, tok, x + w - gui_strlen (tok) - 10, y + 1, fg, -1, FALSE); } if ((m->child) && (!bar)) { abitmap_draw_bmp (bmp, &theme->bitmaps[B_MENU_SUB][c], x + w - 12, y, 12, h); } } else { /* menu separator */ abitmap_draw_bmp (bmp, &theme->bitmaps[B_MENU_SEP][c], x, y, w, h); } }
int d_abitmap_edit_proc (int msg, DIALOG *d, int c) { if (msg == MSG_DRAW) { BITMAP *bmp = gui_get_screen(); int l, x, b, f, p, w; char *s = (char *) d->dp; char buf[16]; /* Buffer to hold one char at a time. */ int c = 0; int fg; agup_edit_adjust_position (d); if (d->flags & D_GOTFOCUS) c = 1; if (d->flags & D_DISABLED) c = 2; abitmap_draw_area (d, B_EDIT, 0, 0, d->w, text_height (font) + 8, 0, 0); l = ustrlen (s); /* set cursor pos */ if (d->d2 >= l) { d->d2 = l; usetc (buf + usetc (buf, ' '), 0); x = text_length (font, buf) + 2; } else x = 2; b = 0; /* num of chars to be blitted */ /* get the part of the string to be blitted */ for (p = d->d2; p >= 0; p--) { usetc (buf + usetc (buf, ugetat (s, p)), 0); x += text_length (font, buf); b++; if (x > d->w - 4) break; } /* see if length of text is too wide */ if (x <= d->w - 2) { b = l; p = 0; } else { b--; p = d->d2 - b + 1; b = d->d2; } for (x = 4; p <= b; p++) { f = ugetat (s, p); usetc (buf + usetc (buf, (f) ? f : ' '), 0); w = text_length (font, buf); if (((p == d->d2) && (d->flags & D_GOTFOCUS))) { abitmap_draw_bmp (bmp, &theme->bitmaps[B_CURSOR][c], d->x + x, d->y, w, text_height (font) + 4); fg = theme->bitmaps[B_CURSOR][c].color; } else fg = theme->bitmaps[B_EDIT][c].color; textout_ex (bmp, font, buf, d->x + x, d->y + 4, fg, -1); if ((x += w) + w > d->w - 4) break; } agup_edit_restore_position (d); return D_O_K; } if (msg == MSG_LOSTFOCUS || msg == MSG_LOSTMOUSE) return D_WANTFOCUS; return d_agup_adjusted_edit_proc (msg, d, c); }
int d_agtk_edit_proc(int msg, DIALOG *d, int c) { if (msg == MSG_DRAW) { BITMAP *bmp = gui_get_screen(); int l, x, b, f, p, w; int fg = (d->flags & D_DISABLED) ? hshadow : black; char *s = (char *)d->dp; char buf[16]; int fonth; agup_edit_adjust_position (d); fonth = text_height(font); l = ustrlen(s); /* set cursor pos */ if (d->d2 >= l) { d->d2 = l; usetc(buf+usetc(buf, ' '), 0); x = text_length(font, buf) + 2; } else x = 2; b = 0; /* num of chars to be blitted */ /* get the part of the string to be blitted */ for (p = d->d2; p >= 0; p--) { usetc(buf+usetc(buf, ugetat(s, p)), 0); x += text_length(font, buf); b++; if (x > d->w-4) break; } /* see if length of text is too wide */ if (x <= d->w-2) { b = l; p = 0; } else { b--; p = d->d2-b+1; b = d->d2; } if (d->flags & D_GOTFOCUS) gtk_bevel(bmp, d->x, d->y, d->w, fonth+6, 3); else gtk_bevel(bmp, d->x, d->y, d->w, fonth+6, 2); rectfill(bmp, d->x+2, d->y+2, d->x+d->w-3, d->y+fonth+3, white); for (x = 4; p<=b; p++) { f = ugetat(s, p); usetc(buf+usetc(buf, (f) ? f : ' '), 0); w = text_length(font, buf); f = ((p == d->d2) && (d->flags & D_GOTFOCUS)); textout_ex(bmp, font, buf, d->x+x, d->y+4, fg, white); if (f) vline(bmp, d->x+x-1, d->y+3, d->y+fonth+3, black); if ((x += w) + w > d->w - 4) break; } agup_edit_restore_position (d); return D_O_K; } return d_agup_adjusted_edit_proc(msg, d, c); }
int d_agtk_list_proc(int msg, DIALOG *d, int c) { if (msg == MSG_DRAW) { BITMAP *bmp = gui_get_screen(); int height, listsize, i, len, bar, x, y, w; int fg_color, fg, bg; char *sel = (char *)d->dp2; char s[1024]; (*(getfuncptr)d->dp)(-1, &listsize); height = (d->h-4) / text_height(font); bar = (listsize > height); w = (bar ? d->w-14 : d->w-3); fg_color = (d->flags & D_DISABLED) ? agtk_mg_color : d->fg; /* draw box contents */ for (i=0; i<height; i++) { if (d->d2+i < listsize) { if (d->d2+i == d->d1) { fg = white; bg = blue; } else if ((sel) && (sel[d->d2+i])) { fg = white; bg = blue; } else { fg = black; bg = white; } usetc(s, 0); ustrncat(s, (*(getfuncptr)d->dp)(i+d->d2, NULL), sizeof(s)-ucwidth(0)); x = d->x + 2; y = d->y + 2 + i*text_height(font); rectfill(bmp, x, y, x+7, y+text_height(font)-1, bg); x += 8; len = ustrlen(s); while (text_length(font, s) >= MAX(d->w - 1 - (bar ? 22 : 10), 1)) { len--; usetat(s, len, 0); } textout_ex(bmp, font, s, x, y, fg, bg); x += text_length(font, s); if (x <= d->x+w) rectfill(bmp, x, y, d->x+w, y+text_height(font)-1, bg); #if 0 /* GTK puts a yellow box around the currently selected * item, but it's quite ugly when we emulate it, so * I'm disabling it. --pw */ if (d->d2+i == d->d1) rect(bmp, x-text_length(font, s)-8, y, d->x+w, y+text_height(font)-1, yellow); #endif } else { rectfill(bmp, d->x+2, d->y+2+i*text_height(font), d->x+w, d->y+1+(i+1)*text_height(font), white); } } if (d->y+2+i*text_height(font) <= d->y+d->h-3) rectfill(bmp, d->x+2, d->y+2+i*text_height(font), d->x+w, d->y+d->h-3, white); /* draw frame, maybe with scrollbar */ gtk_draw_scrollable_frame(d, listsize, d->d2, height); return D_O_K; } return d_list_proc(msg, d, c); }
/* jwin_file_select_ex: * Displays the JWin file selector, with the message as caption. * Allows the user to select a file, and stores the selection in the * path buffer, whose length in bytes is given by size and should have * room for at least 80 characters. The files are filtered according to * the file extensions in ext. Passing NULL includes all files, "PCX;BMP" * includes only files with .PCX or .BMP extensions. Returns zero if it * was closed with the Cancel button or non-zero if it was OK'd. */ int jwin_file_select_ex(AL_CONST char *message, char *path, AL_CONST char *ext, int size, int width, int height, FONT *title_font) { static attrb_state_t default_attrb_state[ATTRB_MAX] = DEFAULT_ATTRB_STATE; int ret; char *p; char tmp[32]; ASSERT(message); ASSERT(path); if(title_font) { file_selector[0].dp2=title_font; } if(width == OLD_FILESEL_WIDTH) width = 304; #ifdef HAVE_DIR_LIST if(height == OLD_FILESEL_HEIGHT) height = 160; #else if(height == OLD_FILESEL_HEIGHT) height = 188; #endif /* for fs_dlist_proc() */ ASSERT(size >= 4 * uwidth_max(U_CURRENT)); usetc(updir, 0); file_selector[FS_WIN].dp = (char *)message; file_selector[FS_EDIT].d1 = size/uwidth_max(U_CURRENT) - 1; file_selector[FS_EDIT].dp = path; file_selector[FS_OK].dp = (void*)get_config_text("OK"); file_selector[FS_CANCEL].dp = (void*)get_config_text("Cancel"); /* Set default attributes. */ memcpy(attrb_state, default_attrb_state, sizeof(default_attrb_state)); /* Parse extension string. */ // if (ext)// && ugetc(ext)) { parse_extension_string(ext); } if(!ugetc(path)) { #ifdef HAVE_DIR_LIST int drive = _al_getdrive(); #else int drive = 0; #endif _al_getdcwd(drive, path, size - ucwidth(OTHER_PATH_SEPARATOR)); fix_filename_case(path); fix_filename_slashes(path); put_backslash(path); } clear_keybuf(); do { } while(gui_mouse_b()); file_selector[FS_TYPES].proc = fs_dummy_proc; enlarge_file_selector(width, height); ret = popup_zqdialog(file_selector, FS_EDIT); if(fext) { zc_free(fext); fext = NULL; } if(fext_p) { _al_free(fext_p); fext_p = NULL; } if((ret == FS_CANCEL) || (ret == FS_WIN) || (!ugetc(get_filename(path)))) return FALSE; p = get_extension(path); if((!ugetc(p)) && (ext) && (!ustrpbrk(ext, uconvert_ascii(" ,;", tmp)))) { size -= ((long)(size_t)p - (long)(size_t)path + ucwidth('.')); if(size >= uwidth_max(U_CURRENT) + ucwidth(0)) /* do not end with '.' */ { p += usetc(p, '.'); ustrzcpy(p, size, ext); } } return TRUE; }
/* fs_flist_putter: * Callback routine for for_each_file() to fill the file selector listbox. */ static void fs_flist_putter(AL_CONST char *str, int attrib, int param) { char ext_tokens[32]; char *s, *ext, *tok, *name; char tmp[512], tmp2[32]; int c, c2, i, k, sign; /* attribute flags (rhsda order) * 0 = not required, 1 = must be set, -1 = must be unset */ int attr_flag[5+5] = { 0, -1, -1, 0, 0, FA_RDONLY, FA_HIDDEN, FA_SYSTEM, FA_DIREC, FA_ARCH }; c = usetc(ext_tokens, ' '); c += usetc(ext_tokens+c, ','); c += usetc(ext_tokens+c, ';'); usetc(ext_tokens+c, 0); s = get_filename(str); fix_filename_case(s); if (fext) { ustrcpy(tmp, fext); ustrtok(tmp, ext_tokens); c = (ustrtok(NULL, ext_tokens) ? 1 : 0); if (!c) { if (!ustrchr(fext, '/')) c = 1; } if (c && (!(attrib & FA_DIREC))) { ustrcpy(tmp, fext); ext = get_extension(s); tok = ustrtok(tmp, ext_tokens); while (tok) { if (ustricmp(ext, tok) == 0) break; tok = ustrtok(NULL, ext_tokens); } if (!tok) return; } c = usetc(ext_tokens, ' '); c += usetc(ext_tokens+c, ','); c += usetc(ext_tokens+c, ';'); c += usetc(ext_tokens+c, '/'); usetc(ext_tokens+c, 0); ustrcpy(tmp, fext); tok = ustrchr(tmp, '/'); if (tok) tok = ustrtok(tok, ext_tokens); if (tok) { sign = 1; c = usetc(tmp2, 'r'); c += usetc(tmp2+c, 'h'); c += usetc(tmp2+c, 's'); c += usetc(tmp2+c, 'd'); c += usetc(tmp2+c, 'a'); c += usetc(tmp2+c, '+'); c += usetc(tmp2+c, '-'); usetc(tmp2+c, 0); /* scan the string */ i = 0; while ((c = utolower(ugetat(tok, i)))) { k = 0; while ((c2 = ugetat(tmp2, k))!=0) { if (c == c2) { if (k<5) { attr_flag[k] = sign; break; } else sign = (k==5) ? 1 : -1; } k++; } i++; } } } /* check if file attributes match */ if (!(attr_flag[3+5] & attrib)) { /* if not a directory, we check all attributes except FA_DIREC */ for (c=0; c<5; c++) { if (c == 3) continue; if ((attr_flag[c] == 1) && (!(attrib & attr_flag[c+5]))) return; if ((attr_flag[c] == -1) && (attrib & attr_flag[c+5])) return; } } else { /* if a directory, we check only FA_DIREC */ if (attr_flag[3] == -1) return; } if ((flist->size < FLIST_SIZE) && ((ugetc(s) != '.') || (ugetat(s, 1)))) { name = malloc(ustrsizez(s) + ((attrib & FA_DIREC) ? ucwidth(OTHER_PATH_SEPARATOR) : 0)); if (!name) return; for (c=0; c<flist->size; c++) { if (ugetat(flist->name[c], -1) == OTHER_PATH_SEPARATOR) { if (attrib & FA_DIREC) if (ustrfilecmp(s, flist->name[c]) < 0) break; } else { if (attrib & FA_DIREC) break; if (ustrfilecmp(s, flist->name[c]) < 0) break; } } for (c2=flist->size; c2>c; c2--) flist->name[c2] = flist->name[c2-1]; flist->name[c] = name; ustrcpy(flist->name[c], s); if (attrib & FA_DIREC) put_backslash(flist->name[c]); flist->size++; } }
/* parse_extension_string: * Parses the extension string, possibly containing attribute characters. */ static void parse_extension_string(AL_CONST char *ext) { attrb_state_t state; char ext_tokens[32], attrb_char[32]; char *last, *p, *attrb_p; int c, c2, i; i = 0; fext_size = 0; fext_p = NULL; attrb_p = NULL; if(!ext) return; fext = ustrdup(ext); /* Tokenize the extension string and record the pointers to the * beginning of each token in a dynamically growing array. * ???? We rely on the implementation of ustrtok_r() which writes * null characters in the string to delimit the tokens. Yuck. */ c = usetc(ext_tokens, ' '); c += usetc(ext_tokens+c, ','); c += usetc(ext_tokens+c, ';'); usetc(ext_tokens+c, 0); p = ustrtok_r(fext, ext_tokens, &last); if(p == NULL || !ugetc(p)) return; do { /* Set of attribute characters. */ if(ugetc(p) == '/') { attrb_p = p + ucwidth('/'); continue; } /* Dynamically grow the array if needed. */ if(i >= fext_size) { fext_size = (fext_size ? fext_size*2 : 2); fext_p = (char **)_al_sane_realloc(fext_p, fext_size * sizeof(char *)); } /* Record a pointer to the beginning of the token. */ fext_p[i++] = p; } while((p = ustrtok_r(NULL, ext_tokens, &last))!=NULL); /* This is the meaningful size now. */ fext_size = i; if(attrb_p) { state = ATTRB_SET; c = usetc(attrb_char, 'r'); c += usetc(attrb_char+c, 'h'); c += usetc(attrb_char+c, 's'); c += usetc(attrb_char+c, 'd'); c += usetc(attrb_char+c, 'a'); c += usetc(attrb_char+c, '+'); c += usetc(attrb_char+c, '-'); usetc(attrb_char+c, 0); /* Scan the string. */ while((c = utolower(ugetx(&attrb_p)))!=0) { p = attrb_char; for(i = 0; (c2 = ugetx(&p))!=0; i++) { if(c == c2) { if(i < ATTRB_MAX) attrb_state[i] = state; else state = (i == ATTRB_MAX) ? ATTRB_SET : ATTRB_UNSET; break; } } } } }
static void photon_draw_menu_item(MENU *m, int x, int y, int w, int h, int bar, int sel) { int i, j, height; char buf[256], *tok; int rtm; if (!menu_done) { photon_do_draw_menu(last_x, last_y, last_w, last_h, bar); menu_done = TRUE; } if (ugetc(m->text)) { if (bar) { if (sel) { rect(screen, x+6, y, x+w-4, y+h, container_black); hline(screen, x+7, y+1, x+w-5, white); vline(screen, x+7, y+1, y+h-2, white); hline(screen, x+7, y+h-1, x+w-5, check_gray1); vline(screen, x+w-5, y, y+h-1, check_gray1); rectgouraud(screen, x+8, y+2, x+w-6, y+h-2, &scrollbar_gray_range, FALSE); } else { hline(screen, x+6, y, x+w-4, white); hline(screen, x+6, y+h-1, x+w-4, check_gray1); rectgouraud(screen, x+6, y+1, x+w-4, y+h-2, &menu_gray_range, FALSE); } } else { if (!(m->flags & D_DISABLED)) { if (sel) rectfill(screen, x+3, y+1, x+w-5, y+h-4, highlight); else rectfill(screen, x+3, y+1, x+w-5, y+h-4, menu_gray_to); } } rtm = text_mode(-1); i = 0; j = ugetc(m->text); while ((j) && (j != '\t')) { i += usetc(buf+i, j); j = ugetc(m->text+i); } usetc(buf+i, 0); if (bar) photon_textout(screen, buf, x+9, y+1, m->flags, FALSE); else photon_textout(screen, buf, x+4, y+1, m->flags, FALSE); if (j == '\t') { tok = m->text+i + uwidth(m->text+i); photon_textout(screen, tok, x+w-gui_strlen(tok)-15, y+1, m->flags, FALSE); } text_mode(rtm); if ((m->child) && (!bar)) draw_sprite(screen, menu_arrow_bmp, x+w-12, y+(h-menu_arrow_bmp->h-1)/2); } else { height = text_height(font); hline(screen, x, y+height/2-1, x+w-1, check_gray1); hline(screen, x, y+height/2, x+w-1, container_black); hline(screen, x, y+height/2+1, x+w-1, white); } if (m->flags & D_SELECTED) { height = text_height(font); line(screen, x+w-10, y+height/2, x+w-8, y+height, checked_gray); line(screen, x+w-8, y+height, x+w-5, y+1, checked_gray); } }
/* fs_flist_proc: * Dialog procedure for the file selector list. */ static int fs_flist_proc(int msg, DIALOG *d, int c) { static int recurse_flag = 0; char *s = file_selector[FS_EDIT].dp; char tmp[32]; int sel = d->d1; int i, ret; int ch, count; if (msg == MSG_START) { if (!flist) { flist = malloc(sizeof(FLIST)); if (!flist) { *allegro_errno = ENOMEM; return D_CLOSE; } } else { for (i=0; i<flist->size; i++) if (flist->name[i]) free(flist->name[i]); } flist->size = 0; replace_filename(flist->dir, s, uconvert_ascii("*.*", tmp), sizeof(flist->dir)); for_each_file(flist->dir, FA_RDONLY | FA_DIREC | FA_ARCH | FA_HIDDEN | FA_SYSTEM, fs_flist_putter, 0); if (*allegro_errno) raine_alert("", "Disk error", NULL, NULL, "OK", NULL, 13, 0); usetc(get_filename(flist->dir), 0); d->d1 = d->d2 = 0; sel = 0; } if (msg == MSG_END) { if (flist) { for (i=0; i<flist->size; i++) if (flist->name[i]) free(flist->name[i]); free(flist); flist = NULL; } } recurse_flag++; ret = d_text_list_proc(msg, d, c); /* call the parent procedure */ recurse_flag--; if (((sel != d->d1) || (ret == D_CLOSE)) && (recurse_flag == 0)) { replace_filename(s, flist->dir, flist->name[d->d1], 512); /* check if we want to `cd ..' */ if ((!ustrncmp(flist->name[d->d1], "..", 2)) && (ret == D_CLOSE)) { /* let's remember the previous directory */ ustrcpy(updir, empty_string); i = ustrlen(flist->dir); count = 0; while (i>0) { ch = ugetat(flist->dir, i); if ((ch == '/') || (ch == OTHER_PATH_SEPARATOR)) { if (++count == 2) break; } uinsert(updir, 0, ch); i--; } /* ok, we have the dirname in updir */ } else { ustrcpy(updir, empty_string); } scare_mouse(); SEND_MESSAGE(file_selector+FS_EDIT, MSG_START, 0); SEND_MESSAGE(file_selector+FS_EDIT, MSG_DRAW, 0); unscare_mouse(); if (ret == D_CLOSE) return SEND_MESSAGE(file_selector+FS_EDIT, MSG_KEY, 0); } return ret; }
/* _install_allegro: * Initialises the Allegro library, activating the system driver. */ static int _install_allegro(int system_id, int *errno_ptr, int (*atexit_ptr)(void (*func)(void))) { RGB black_rgb = {0, 0, 0, 0}; char tmp1[64], tmp2[64]; int i; #ifndef ALLEGRO_USE_CONSTRUCTOR /* call constructor functions manually */ extern void _initialize_datafile_types(); extern void _midi_constructor(); extern void _mouse_constructor(); _initialize_datafile_types(); _midi_constructor(); _mouse_constructor(); _register_bitmap_file_type_init(); _register_sample_file_type_init(); _register_font_file_type_init(); #endif if (errno_ptr) allegro_errno = errno_ptr; else allegro_errno = &errno; /* set up default palette structures */ for (i=0; i<256; i++) black_palette[i] = black_rgb; for (i=16; i<256; i++) desktop_palette[i] = desktop_palette[i & 15]; /* lock some important variables */ LOCK_VARIABLE(screen); LOCK_VARIABLE(gfx_driver); LOCK_VARIABLE(gfx_capabilities); LOCK_VARIABLE(_last_bank_1); LOCK_VARIABLE(_last_bank_2); LOCK_VARIABLE(_gfx_bank); LOCK_VARIABLE(_drawing_mode); LOCK_VARIABLE(_drawing_pattern); LOCK_VARIABLE(_drawing_x_anchor); LOCK_VARIABLE(_drawing_y_anchor); LOCK_VARIABLE(_drawing_x_mask); LOCK_VARIABLE(_drawing_y_mask); LOCK_VARIABLE(_current_palette); LOCK_VARIABLE(os_type); /* nasty stuff to set up the config system before the system driver */ system_driver = _system_driver_list[0].driver; /* needed in case set_config_file was called before allegro_init */ _reload_config(); reload_config_texts(NULL); if (system_id == SYSTEM_AUTODETECT) system_id = get_config_id(uconvert_ascii("system", tmp1), uconvert_ascii("system", tmp2), SYSTEM_AUTODETECT); system_driver = NULL; /* initialise the system driver */ usetc(allegro_error, 0); for (i=0; _system_driver_list[i].driver; i++) { if ((_system_driver_list[i].id == system_id) || ((_system_driver_list[i].autodetect) && (system_id == SYSTEM_AUTODETECT))) { system_driver = _system_driver_list[i].driver; system_driver->name = system_driver->desc = get_config_text(system_driver->ascii_name); if (system_driver->init() != 0) { system_driver = NULL; if (system_id != SYSTEM_AUTODETECT) break; } else break; } } if (!system_driver) return -1; /* disable close button */ set_close_button_callback(NULL); /* detect CPU type */ check_cpu(); #if defined(ALLEGRO_UNIX) || defined(ALLEGRO_WINDOWS) /* detect filename encoding used by libc */ /* XXX This should be done for all platforms but I'm not set up to check * that all platforms have been covered before making the 4.2.3 release. * --pw */ _al_detect_filename_encoding(); #endif /* set up screensaver policy */ _screensaver_policy = get_config_int(uconvert_ascii("system", tmp1), uconvert_ascii("disable_screensaver", tmp2), FULLSCREEN_DISABLED); /* install shutdown handler */ if (_allegro_count == 0) { if (atexit_ptr) atexit_ptr(allegro_exit_stub); } _allegro_count++; TRACE(PREFIX_I "Allegro initialised (instance %d)\n", _allegro_count); return 0; }
int raine_file_select_ex( char *message, char *path, char *ext, int size,int width, int height) { char buf[512]; int ret; char *p; if (width == -1) width = 305; #ifdef HAVE_DIR_LIST if (height == -1) height = 161; #else if (height == -1) height = 189; #endif /* for fs_dlist_proc() */ ASSERT(size >= 4 * uwidth_max(U_CURRENT)); ustrcpy(updir, empty_string); file_selector[FS_MESSAGE].dp = (char *)message; file_selector[FS_EDIT].d1 = size/uwidth_max(U_CURRENT) - 1; file_selector[FS_EDIT].dp = path; file_selector[FS_OK].dp = (void*)raine_get_config_text("OK"); file_selector[FS_CANCEL].dp = (void*)raine_get_config_text("Cancel"); fext = ext; if (!ugetc(path)) { if (!getcwd(buf, sizeof(buf))) buf[0]=0; do_uconvert(buf, U_ASCII, path, U_CURRENT, size); fix_filename_case(path); fix_filename_slashes(path); put_backslash(path); } clear_keybuf(); do { } while (gui_mouse_b()); stretch_dialog(file_selector, width, height); centre_dialog(file_selector); // Stupid correction of the allegro colors... file_selector[FS_FILES].fg = CGUI_COL_TEXT_1; file_selector[FS_FILES].bg = CGUI_BOX_COL_MIDDLE; #ifdef HAVE_DIR_LIST /* not all platforms need a directory list */ file_selector[FS_DISKS].fg = CGUI_COL_TEXT_1; file_selector[FS_DISKS].bg = CGUI_BOX_COL_MIDDLE; #endif ret = do_dialog(file_selector, FS_EDIT); if (ret == FS_CANCEL) return FALSE; p = get_extension(path); if ((!ugetc(p)) && (ext) && (!ustrpbrk(ext, uconvert_ascii(" ,;", NULL)))) { p += usetc(p, '.'); ustrcpy(p, ext); } return TRUE; }
/* fs_flist_proc: * Dialog procedure for the file selector list. */ static int fs_flist_proc(int msg, DIALOG *d, int c) { static int recurse_flag = 0; char *s = (char *) file_selector[FS_EDIT].dp; char tmp[32]; /* of s (in bytes) */ int size = (file_selector[FS_EDIT].d1 + 1) * uwidth_max(U_CURRENT); int sel = d->d1; int i, ret; int ch, count; if(msg == MSG_START) { if(!flist) { flist = (FLIST *) zc_malloc(sizeof(FLIST)); if(!flist) { *allegro_errno = ENOMEM; return D_CLOSE; } } else { for(i=0; i<flist->size; i++) if(flist->name[i]) zc_free(flist->name[i]); } flist->size = 0; replace_filename(flist->dir, s, uconvert_ascii("*.*", tmp), sizeof(flist->dir)); /* The semantics of the attributes passed to file_select_ex() is * different from that of for_each_file_ex() in one case: when * the 'd' attribute is not mentioned in the set of characters, * the other attributes are not taken into account for directories, * i.e the directories are all included. So we can't filter with * for_each_file_ex() in that case. */ if(attrb_state[ATTRB_DIREC] == ATTRB_ABSENT) /* accept all dirs */ for_each_file_ex(flist->dir, 0 , FA_LABEL, fs_flist_putter, (void *)1UL /* check */); else /* don't check */ for_each_file_ex(flist->dir, build_attrb_flag(ATTRB_SET), build_attrb_flag(ATTRB_UNSET) | FA_LABEL, fs_flist_putter, (void *)0UL); usetc(get_filename(flist->dir), 0); d->d1 = d->d2 = 0; sel = 0; } if(msg == MSG_END) { if(flist) { for(i=0; i<flist->size; i++) if(flist->name[i]) zc_free(flist->name[i]); zc_free(flist); flist = NULL; } } recurse_flag++; ret = jwin_abclist_proc(msg,d,c); /* call the parent procedure */ recurse_flag--; if(((sel != d->d1) || (ret == D_CLOSE)) && (recurse_flag == 0)) { replace_filename(s, flist->dir, flist->name[d->d1], size); /* check if we want to `cd ..' */ if((!ustrncmp(flist->name[d->d1], uconvert_ascii("..", tmp), 2)) && (ret == D_CLOSE)) { /* let's remember the previous directory */ usetc(updir, 0); i = ustrlen(flist->dir); count = 0; while(i>0) { ch = ugetat(flist->dir, i); if((ch == '/') || (ch == OTHER_PATH_SEPARATOR)) { if(++count == 2) break; } uinsert(updir, 0, ch); i--; } /* ok, we have the dirname in updir */ } else { usetc(updir, 0); } object_message(file_selector+FS_EDIT, MSG_START, 0); object_message(file_selector+FS_EDIT, MSG_DRAW, 0); if(ret == D_CLOSE) return object_message(file_selector+FS_EDIT, MSG_KEY, 0); } return ret; }
int d_aphoton_edit_proc(int msg, DIALOG *d, int c) { if (msg == MSG_DRAW) { int l, x, b, f, p, w, rtm; int fg = (d->flags & D_DISABLED) ? shadow : black; char *s = (char *)d->dp; char buf[16]; int fonth; agup_edit_adjust_position (d); fonth = text_height(font); l = ustrlen(s); /* set cursor pos */ if (d->d2 >= l) { d->d2 = l; usetc(buf+usetc(buf, ' '), 0); x = text_length(font, buf) + 2; } else x = 2; b = 0; /* num of chars to be blitted */ /* get the part of the string to be blitted */ for (p = d->d2; p >= 0; p--) { usetc(buf+usetc(buf, ugetat(s, p)), 0); x += text_length(font, buf); b++; if (x > d->w-4) break; } /* see if length of text is too wide */ if (x <= d->w-2) { b = l; p = 0; } else { b--; p = d->d2-b+1; b = d->d2; } photon_box(screen, d->x, d->y, d->w, fonth+8, edit_white); hline(screen, d->x+2, d->y+2, d->x+d->w-3, edit_gray); vline(screen, d->x+2, d->y+2, d->y+fonth+5, edit_gray); for (x = 4; p<=b; p++) { f = ugetat(s, p); usetc(buf+usetc(buf, (f) ? f : ' '), 0); w = text_length(font, buf); f = ((p == d->d2) && (d->flags & D_GOTFOCUS)); rtm = text_mode(edit_white); textout(screen, font, buf, d->x+x, d->y+4, fg); text_mode(rtm); if (f) vline(screen, d->x+x-1, d->y+3, d->y+fonth+5, black); if ((x += w) + w > d->w - 4) break; } if (d->flags & D_GOTFOCUS) hline(screen, d->x+4, d->y+fonth+4, d->x+d->w-5, highlight); agup_edit_restore_position (d); return D_O_K; } return d_agup_adjusted_edit_proc(msg, d, c); }