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_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; }
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); }
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); }