diff options
Diffstat (limited to 'src/gui/gui.cpp')
-rw-r--r-- | src/gui/gui.cpp | 164 |
1 files changed, 0 insertions, 164 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 2a59370f..1ca5dc8f 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -594,167 +594,3 @@ void gui_shutdown(void) { destroy_bitmap(gui__repository[a]); } } - -int gui_text(BITMAP *bmp, AL_CONST char *s, int x, int y, int color, int centre) { - char tmp[1024]; - int hline_pos = -1; - int len = 0; - int in_pos = 0; - int out_pos = 0; - int pix_len, c; - - while (((c = ugetc(s+in_pos)) != 0) && (out_pos<(int)(sizeof(tmp)-ucwidth(0)))) { - if (c == '&') { - in_pos += uwidth(s+in_pos); - c = ugetc(s+in_pos); - if (c == '&') { - out_pos += usetc(tmp+out_pos, '&'); - in_pos += uwidth(s+in_pos); - len++; - } else hline_pos = len; - } else { - out_pos += usetc(tmp+out_pos, c); - in_pos += uwidth(s+in_pos); - len++; - } - } - usetc(tmp+out_pos, 0); - pix_len = text_length(font, tmp); - - if (centre)x -= pix_len / 2; - if (bmp) { - textprintf_ex(bmp, font, x, y, color, -1, tmp); - if (hline_pos >= 0) { - c = ugetat(tmp, hline_pos); - usetat(tmp, hline_pos, 0); - hline_pos = text_length(font, tmp); - c = usetc(tmp, c); - usetc(tmp+c, 0); - c = text_length(font, tmp); - hline(bmp, x+hline_pos, y+text_height(font)-gui_font_baseline, x+hline_pos+c-1, color); - } - } - return pix_len; -} - -int tmw_text_proc(int msg, DIALOG *d, int c) { - if (msg == MSG_DRAW) { - gui_text(gui_bitmap, (char *)d->dp, d->x, d->y, d->fg, FALSE); - } - return D_O_K; -} - -int tmw_button_proc(int msg, DIALOG *d, int c) -{ - int col = 0; - int ofs = 0; - int ret = D_O_K; - - if (msg == MSG_DRAW) { - rectfill(gui_bitmap, d->x, d->y, d->x + d->w, d->y+d->h, makecol(255,255,255)); - - if (d->flags & D_DISABLED) { - draw_skinned_rect(gui_bitmap, &gui_skin.button.background[3], d->x, d->y, d->w, d->h); - col = gui_skin.button.textcolor[3]; - } else if (d->flags & D_SELECTED) { - draw_skinned_rect(gui_bitmap, &gui_skin.button.background[2], d->x, d->y, d->w, d->h); - col = gui_skin.button.textcolor[2]; - ofs = 1; - } else if (d->flags & D_GOTMOUSE) { - draw_skinned_rect(gui_bitmap, &gui_skin.button.background[1], d->x, d->y, d->w, d->h); - col = gui_skin.button.textcolor[1]; - } else { - draw_skinned_rect(gui_bitmap, &gui_skin.button.background[0], d->x, d->y, d->w, d->h); - col = gui_skin.button.textcolor[0]; - } - gui_text(gui_bitmap, (const char *)d->dp, d->x+d->w/2+ofs, d->y+d->h/2-text_height(font)/2+ofs, col, TRUE); - ret = D_O_K; - } else { - /* - if (msg == MSG_CLICK) { - if (d->d1 == 1) ((int)d->dp2) + 1; - else if (d->d1 == 2) ((int)d->dp2) - 1; - } - */ - - ret = d_button_proc(msg,d,c); - } - return ret; -} - - -int tmw_dialog_proc(int msg, DIALOG *d, int c) { - int x, y; - - switch (msg) { - case MSG_CLICK: - if (mouse_y<d->y + gui_skin.dialog.bg.grid[1]->h) { - d->d1 = mouse_x - d->x; - d->d2 = mouse_y - d->y; - } - break; - case MSG_DRAW: - if((mouse_b & 1) && (d->d1 >= 0) && (d->d2 >= 0)) { - x = mouse_x - d->d1; - y = mouse_y - d->d2; - if (x < 15) { - x = 0; - position_mouse(d->d1, mouse_y); - } - if (y < 15) { - y = 0; - position_mouse(mouse_x, d->d2); - } - if (x + d->w >= SCREEN_W - 15) { - x = SCREEN_W - d->w; - position_mouse(x+d->d1, mouse_y); - } - if (y + d->h >= SCREEN_H - 15) { - y = SCREEN_H - d->h; - position_mouse(mouse_x, y + d->d2); - } - position_dialog(d, x, y); - } else { - d->d1 = -1; - d->d2 = -1; - } - draw_skinned_rect(gui_bitmap, &gui_skin.dialog.bg, - d->x, d->y, d->w, d->h); - - textprintf_centre_ex(gui_bitmap, font, - d->x + d->w / 2, - d->y + (gui_skin.dialog.bg.grid[1]->h - text_height(font)) / 2, - d->fg, -1, "%s", (char*)d->dp); - - break; - } - return D_O_K; -} - -unsigned int yes_no(const char *title, const char *message) { - unsigned int ret; - DIALOG alert_dialog[] = { - /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ - { tmw_dialog_proc, 0, 0, 0, 60, 0, -1, 0, 0, 0, 0, (void *)title, NULL, NULL }, - { tmw_text_proc, 2, 22, 0, 0, 0, 0, 0, 0, 0, 0, (void *)message, NULL, NULL }, - { tmw_button_proc, 0, 40, 44, 18, 0, -1, 'o', D_EXIT, -1, 0, (char *)"&Yes", NULL, NULL }, - { tmw_button_proc, 0, 40, 44, 18, 0, -1, 'o', D_EXIT, -1, 0, (char *)"&No", NULL, NULL }, - { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } - }; - - BITMAP *temp = gui_bitmap; - gui_bitmap = screen; - show_mouse(screen); - int width = text_length(font, message) + 4; - if (width < 100) width = 100; - alert_dialog[0].w = width; - alert_dialog[1].w = text_length(font, message); - alert_dialog[1].h = text_height(font); - alert_dialog[2].x = width / 2 - 46; - alert_dialog[2].x = width / 2 + 2; - position_dialog(alert_dialog, 400 - width / 2, 270); - ret = do_dialog(alert_dialog, 3); - show_mouse(NULL); - gui_bitmap = temp; - return ret - 2; -} |