|
Atrinik Client 2.5
|
00001 /************************************************************************ 00002 * Atrinik, a Multiplayer Online Role Playing Game * 00003 * * 00004 * Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team * 00005 * * 00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game) * 00007 * and Crossfire (Multiplayer game for X-windows). * 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 * This program is distributed in the hope that it will be useful, * 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00017 * GNU General Public License for more details. * 00018 * * 00019 * You should have received a copy of the GNU General Public License * 00020 * along with this program; if not, write to the Free Software * 00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00022 * * 00023 * The author can be reached at admin@atrinik.org * 00024 ************************************************************************/ 00025 00030 #include <global.h> 00031 00035 static widgetdata *selection_widget = NULL; 00037 static Uint32 textwin_border_color; 00041 static Uint32 textwin_border_color_selected; 00042 00045 void textwin_init() 00046 { 00047 textwin_border_color = SDL_MapRGB(ScreenSurface->format, 96, 96, 96); 00048 textwin_border_color_selected = SDL_MapRGB(ScreenSurface->format, 177, 126, 5); 00049 } 00050 00054 void textwin_scroll_adjust(widgetdata *widget) 00055 { 00056 textwin_struct *textwin = TEXTWIN(widget); 00057 00058 if (textwin->scroll < TEXTWIN_ROWS_VISIBLE(widget)) 00059 { 00060 textwin->scroll = TEXTWIN_ROWS_VISIBLE(widget); 00061 } 00062 00063 if (textwin->scroll > (int) textwin->num_entries) 00064 { 00065 textwin->scroll = textwin->num_entries; 00066 } 00067 } 00068 00073 void textwin_readjust(widgetdata *widget) 00074 { 00075 textwin_struct *textwin = TEXTWIN(widget); 00076 SDL_Rect box; 00077 int scroll; 00078 00079 if (!textwin->entries) 00080 { 00081 return; 00082 } 00083 00084 box.w = widget->wd - Bitmaps[BITMAP_SLIDER]->bitmap->w - 7; 00085 box.h = 0; 00086 box.x = 0; 00087 box.y = 0; 00088 string_blt(NULL, textwin->font, textwin->entries, 3, 0, COLOR_WHITE, TEXTWIN_TEXT_FLAGS(widget) | TEXT_HEIGHT, &box); 00089 scroll = box.h / FONT_HEIGHT(textwin->font); 00090 00091 /* Adjust the counts. */ 00092 textwin->scroll = scroll; 00093 textwin->num_entries = scroll; 00094 } 00095 00096 void draw_info_flags(const char *color, int flags, const char *str) 00097 { 00098 widgetdata *widget; 00099 textwin_struct *textwin; 00100 size_t len, scroll; 00101 SDL_Rect box; 00102 00103 if (flags & NDI_PLAYER) 00104 { 00105 widget = cur_widget[CHATWIN_ID]; 00106 } 00107 else 00108 { 00109 widget = cur_widget[MSGWIN_ID]; 00110 } 00111 00112 textwin = TEXTWIN(widget); 00113 WIDGET_REDRAW(widget); 00114 00115 box.w = widget->wd - Bitmaps[BITMAP_SLIDER]->bitmap->w - 7; 00116 box.h = 0; 00117 00118 len = strlen(str); 00119 /* Resize the characters array as needed. */ 00120 textwin->entries = realloc(textwin->entries, textwin->entries_size + len + 9); 00121 /* Tells the text module what color to use. */ 00122 textwin->entries[textwin->entries_size] = '\r'; 00123 textwin->entries[textwin->entries_size + 1] = color[0]; 00124 textwin->entries[textwin->entries_size + 2] = color[1]; 00125 textwin->entries[textwin->entries_size + 3] = color[2]; 00126 textwin->entries[textwin->entries_size + 4] = color[3]; 00127 textwin->entries[textwin->entries_size + 5] = color[4]; 00128 textwin->entries[textwin->entries_size + 6] = color[5]; 00129 textwin->entries_size += 7; 00130 /* Add the string, newline and terminating \0. */ 00131 strcpy(textwin->entries + textwin->entries_size, str); 00132 textwin->entries[textwin->entries_size + len] = '\n'; 00133 textwin->entries[textwin->entries_size + len + 1] = '\0'; 00134 textwin->entries_size += len + 1; 00135 00136 box.y = 0; 00137 /* Get the string's height. */ 00138 string_blt(NULL, textwin->font, str, 3, 0, COLOR_WHITE, TEXTWIN_TEXT_FLAGS(widget) | TEXT_HEIGHT, &box); 00139 scroll = box.h / FONT_HEIGHT(textwin->font) + 1; 00140 00141 /* Adjust the counts. */ 00142 textwin->scroll += scroll; 00143 textwin->num_entries += scroll; 00144 00145 /* Have the entries gone over maximum allowed lines? */ 00146 if (textwin->entries && textwin->num_entries >= (size_t) setting_get_int(OPT_CAT_GENERAL, OPT_MAX_CHAT_LINES)) 00147 { 00148 char *cp; 00149 00150 while (textwin->num_entries >= (size_t) setting_get_int(OPT_CAT_GENERAL, OPT_MAX_CHAT_LINES) && (cp = strchr(textwin->entries, '\n'))) 00151 { 00152 size_t pos = cp - textwin->entries + 1; 00153 char *buf = malloc(pos + 1); 00154 00155 /* Copy the string together with the newline to a temporary 00156 * buffer. */ 00157 memcpy(buf, textwin->entries, pos); 00158 buf[pos] = '\0'; 00159 00160 /* Get the string's height. */ 00161 box.h = 0; 00162 string_blt(NULL, textwin->font, buf, 3, 0, COLOR_WHITE, TEXTWIN_TEXT_FLAGS(widget) | TEXT_HEIGHT, &box); 00163 scroll = box.h / FONT_HEIGHT(textwin->font); 00164 00165 free(buf); 00166 00167 /* Move the string after the found newline to the beginning, 00168 * effectively erasing the previous line. */ 00169 textwin->entries_size -= pos; 00170 memcpy(textwin->entries, textwin->entries + pos, textwin->entries_size); 00171 textwin->entries[textwin->entries_size] = '\0'; 00172 00173 /* Adjust the counts. */ 00174 textwin->scroll -= scroll; 00175 textwin->num_entries -= scroll; 00176 } 00177 } 00178 } 00179 00184 void draw_info_format(const char *color, char *format, ...) 00185 { 00186 char buf[HUGE_BUF * 2]; 00187 va_list ap; 00188 00189 va_start(ap, format); 00190 vsnprintf(buf, sizeof(buf), format, ap); 00191 va_end(ap); 00192 00193 draw_info_flags(color, 0, buf); 00194 } 00195 00200 void draw_info(const char *color, const char *str) 00201 { 00202 draw_info_flags(color, 0, str); 00203 } 00204 00207 void textwin_handle_copy() 00208 { 00209 sint64 start, end; 00210 textwin_struct *textwin; 00211 char *str, *cp; 00212 size_t i, pos; 00213 00214 /* Nothing to copy? */ 00215 if (!selection_widget) 00216 { 00217 return; 00218 } 00219 00220 textwin = TEXTWIN(selection_widget); 00221 00222 start = textwin->selection_start; 00223 end = textwin->selection_end; 00224 00225 if (end < start) 00226 { 00227 start = textwin->selection_end; 00228 end = textwin->selection_start; 00229 } 00230 00231 if (end - start <= 0) 00232 { 00233 return; 00234 } 00235 00236 /* Get the string to copy, depending on the start and end positions. */ 00237 str = malloc(sizeof(char) * (end - start + 1 + 1)); 00238 memcpy(str, textwin->entries + start, end - start + 1); 00239 str[end - start + 1] = '\0'; 00240 00241 cp = malloc(sizeof(char) * (end - start + 1 + 1)); 00242 i = 0; 00243 00244 /* Remove the special \r color changers. */ 00245 for (pos = 0; pos < (size_t) (end - start + 1); pos++) 00246 { 00247 if (str[pos] == '\r') 00248 { 00249 pos += 6; 00250 } 00251 else 00252 { 00253 cp[i] = str[pos]; 00254 i++; 00255 } 00256 } 00257 00258 cp[i] = '\0'; 00259 00260 clipboard_set(cp); 00261 free(str); 00262 free(cp); 00263 } 00264 00271 static void show_window(widgetdata *widget, int x, int y, _BLTFX *bltfx) 00272 { 00273 textwin_struct *textwin = TEXTWIN(widget); 00274 SDL_Rect box; 00275 int temp; 00276 00277 textwin->x = x; 00278 textwin->y = y; 00279 x = y = 0; 00280 00281 /* Show the text entries, if any. */ 00282 if (textwin->entries) 00283 { 00284 box.w = widget->wd - Bitmaps[BITMAP_SLIDER]->bitmap->w - 7; 00285 box.h = widget->ht; 00286 box.y = MAX(0, textwin->scroll - TEXTWIN_ROWS_VISIBLE(widget)); 00287 text_set_selection(&textwin->selection_start, &textwin->selection_end, &textwin->selection_started); 00288 string_blt(bltfx->surface, textwin->font, textwin->entries, x + 3, y + 1, COLOR_WHITE, TEXTWIN_TEXT_FLAGS(widget) | TEXT_HEIGHT, &box); 00289 text_set_selection(NULL, NULL, NULL); 00290 } 00291 00292 /* Only draw scrollbar if needed */ 00293 if (textwin->num_entries > (size_t) TEXTWIN_ROWS_VISIBLE(widget)) 00294 { 00295 box.x = box.y = 0; 00296 box.w = Bitmaps[BITMAP_SLIDER]->bitmap->w; 00297 box.h = widget->ht - 12; 00298 00299 /* No textinput-line */ 00300 temp = -11; 00301 sprite_blt(Bitmaps[BITMAP_SLIDER_UP], x + widget->wd - 11, y + 1, NULL, bltfx); 00302 sprite_blt(Bitmaps[BITMAP_SLIDER_DOWN], x + widget->wd - 11, y + temp + widget->ht, NULL, bltfx); 00303 sprite_blt(Bitmaps[BITMAP_SLIDER], x + widget->wd - 11, y + Bitmaps[BITMAP_SLIDER_UP]->bitmap->h + 2 + temp, &box, bltfx); 00304 box.h += temp - 1; 00305 box.w -= 2; 00306 00307 /* Between 0.0 <-> 1.0 */ 00308 textwin->slider_h = box.h * TEXTWIN_ROWS_VISIBLE(widget) / textwin->num_entries; 00309 textwin->slider_y = ((textwin->scroll - TEXTWIN_ROWS_VISIBLE(widget)) * box.h) / textwin->num_entries; 00310 00311 if (textwin->slider_h < 1) 00312 { 00313 textwin->slider_h = 1; 00314 } 00315 00316 if (textwin->scroll - TEXTWIN_ROWS_VISIBLE(widget) > 0 && textwin->slider_y + textwin->slider_h < box.h) 00317 { 00318 textwin->slider_y++; 00319 } 00320 00321 box.h = textwin->slider_h; 00322 sprite_blt(Bitmaps[BITMAP_TWIN_SCROLL], x + widget->wd - 9, y + Bitmaps[BITMAP_SLIDER_UP]->bitmap->h + 2 + textwin->slider_y, &box, bltfx); 00323 00324 if (textwin->highlight == TW_HL_UP) 00325 { 00326 box.x = x + widget->wd - 11; 00327 box.y = y + 1; 00328 box.h = Bitmaps[BITMAP_SLIDER_UP]->bitmap->h; 00329 box.w = 1; 00330 SDL_FillRect(bltfx->surface, &box, -1); 00331 box.x += Bitmaps[BITMAP_SLIDER_UP]->bitmap->w - 1; 00332 SDL_FillRect(bltfx->surface, &box, -1); 00333 box.w = Bitmaps[BITMAP_SLIDER_UP]->bitmap->w - 1; 00334 box.h = 1; 00335 box.x = x + widget->wd - 11; 00336 SDL_FillRect(bltfx->surface, &box, -1); 00337 box.y += Bitmaps[BITMAP_SLIDER_UP]->bitmap->h - 1; 00338 SDL_FillRect(bltfx->surface, &box, -1); 00339 } 00340 else if (textwin->highlight == TW_ABOVE) 00341 { 00342 box.x = x + widget->wd - 9; 00343 box.y = y + Bitmaps[BITMAP_SLIDER_UP]->bitmap->h + 1; 00344 box.h = textwin->slider_y + 1; 00345 box.w = 5; 00346 SDL_FillRect(bltfx->surface, &box, 0); 00347 } 00348 else if (textwin->highlight == TW_HL_SLIDER) 00349 { 00350 box.x = x + widget->wd - 9; 00351 box.y = y + Bitmaps[BITMAP_SLIDER_UP]->bitmap->h + 2 + textwin->slider_y; 00352 box.w = 1; 00353 SDL_FillRect(bltfx->surface, &box, -1); 00354 box.x += 4; 00355 SDL_FillRect(bltfx->surface, &box, -1); 00356 box.x -= 4; 00357 box.h = 1; 00358 box.w = 4; 00359 SDL_FillRect(bltfx->surface, &box, -1); 00360 box.y += textwin->slider_h - 1; 00361 SDL_FillRect(bltfx->surface, &box, -1); 00362 } 00363 else if (textwin->highlight == TW_UNDER) 00364 { 00365 box.x = x + widget->wd - 9; 00366 box.y = y + Bitmaps[BITMAP_SLIDER_UP]->bitmap->h + 2 + textwin->slider_y + box.h; 00367 box.h = widget->ht - 13 - textwin->slider_y - textwin->slider_h - 10; 00368 box.w = 5; 00369 SDL_FillRect(bltfx->surface, &box, 0); 00370 } 00371 else if (textwin->highlight == TW_HL_DOWN) 00372 { 00373 box.x = x + widget->wd - 11; 00374 box.y = y + widget->ht - 13 + 2; 00375 box.h = Bitmaps[BITMAP_SLIDER_UP]->bitmap->h; 00376 box.w = 1; 00377 SDL_FillRect(bltfx->surface, &box, -1); 00378 box.x += Bitmaps[BITMAP_SLIDER_UP]->bitmap->w - 1; 00379 SDL_FillRect(bltfx->surface, &box, -1); 00380 box.w = Bitmaps[BITMAP_SLIDER_UP]->bitmap->w - 1; 00381 box.h = 1; 00382 box.x = x + widget->wd - 11; 00383 SDL_FillRect(bltfx->surface, &box, -1); 00384 box.y += Bitmaps[BITMAP_SLIDER_UP]->bitmap->h - 1; 00385 SDL_FillRect(bltfx->surface, &box, -1); 00386 } 00387 } 00388 else 00389 { 00390 textwin->slider_h = 0; 00391 } 00392 } 00393 00401 void textwin_show(int x, int y, int w, int h) 00402 { 00403 widgetdata *widget = cur_widget[MSGWIN_ID]; 00404 textwin_struct *textwin = TEXTWIN(widget); 00405 SDL_Rect box; 00406 int scroll; 00407 00408 box.w = w - 3; 00409 box.h = 0; 00410 box.x = 0; 00411 box.y = 0; 00412 string_blt(NULL, textwin->font, textwin->entries, 3, 0, COLOR_WHITE, TEXTWIN_TEXT_FLAGS(widget) | TEXT_HEIGHT, &box); 00413 scroll = box.h / FONT_HEIGHT(textwin->font); 00414 00415 box.x = x; 00416 box.y = y; 00417 box.w = w; 00418 box.h = h; 00419 SDL_FillRect(ScreenSurface, &box, 0); 00420 draw_frame(ScreenSurface, x, y, box.w, box.h); 00421 00422 box.w = w - 3; 00423 box.h = h; 00424 00425 box.y = MAX(0, scroll - (h / FONT_HEIGHT(textwin->font))); 00426 00427 string_blt(ScreenSurface, textwin->font, textwin->entries, x + 3, y + 1, COLOR_WHITE, TEXTWIN_TEXT_FLAGS(widget) | TEXT_HEIGHT, &box); 00428 } 00429 00433 void widget_textwin_show(widgetdata *widget) 00434 { 00435 int len; 00436 SDL_Rect box, box2; 00437 _BLTFX bltfx; 00438 textwin_struct *textwin = TEXTWIN(widget); 00439 int x = widget->x1; 00440 int y = widget->y1; 00441 int mx, my; 00442 00443 /* Sanity check. */ 00444 if (!textwin) 00445 { 00446 return; 00447 } 00448 00449 box.x = box.y = 0; 00450 box.w = widget->wd; 00451 box.h = len = widget->ht; 00452 00453 /* If we don't have a backbuffer, create it */ 00454 if (!widget->widgetSF) 00455 { 00456 /* Need to do this, or the foreground could be semi-transparent too. */ 00457 widget->widgetSF = SDL_ConvertSurface(Bitmaps[BITMAP_TEXTWIN_MASK]->bitmap, Bitmaps[BITMAP_TEXTWIN_MASK]->bitmap->format, Bitmaps[BITMAP_TEXTWIN_MASK]->bitmap->flags); 00458 } 00459 00460 box2.x = x; 00461 box2.y = y; 00462 00463 if (widget_mouse_event.owner != widget && widget == selection_widget && textwin->selection_start >= 0 && textwin->selection_end >= 0) 00464 { 00465 textwin->selection_start = -1; 00466 textwin->selection_end = -1; 00467 WIDGET_REDRAW(widget); 00468 } 00469 00470 /* Let's draw the widgets in the backbuffer */ 00471 if (widget->redraw) 00472 { 00473 widget->redraw = 0; 00474 00475 SDL_FillRect(widget->widgetSF, NULL, 0); 00476 00477 bltfx.surface = widget->widgetSF; 00478 bltfx.flags = 0; 00479 bltfx.alpha = 0; 00480 00481 show_window(widget, x, y - 2, &bltfx); 00482 } 00483 00484 box.x = x; 00485 box.y = y; 00486 box2.x = 0; 00487 box2.y = 0; 00488 box2.w = widget->wd; 00489 box2.h = widget->ht; 00490 00491 SDL_BlitSurface(widget->widgetSF, &box2, ScreenSurface, &box); 00492 00493 SDL_GetMouseState(&mx, &my); 00494 00495 if (mx < widget->x1 || mx > widget->x1 + widget->wd || my < widget->y1 || my > widget->y1 + widget->ht) 00496 { 00497 textwin->flags &= ~TW_SCROLL; 00498 widget->resize_flags = 0; 00499 } 00500 00501 box.x = x; 00502 box.y = y; 00503 box.h = 1; 00504 box.w = widget->wd; 00505 SDL_FillRect(ScreenSurface, &box, widget->resize_flags & RESIZE_TOP ? textwin_border_color_selected : textwin_border_color); 00506 box.x = x; 00507 box.y = y + widget->ht - 1; 00508 box.h = 1; 00509 box.w = widget->wd; 00510 SDL_FillRect(ScreenSurface, &box, widget->resize_flags & RESIZE_BOTTOM ? textwin_border_color_selected : textwin_border_color); 00511 box.x = x; 00512 box.y = y; 00513 box.w = 1; 00514 box.h = widget->ht; 00515 SDL_FillRect(ScreenSurface, &box, widget->resize_flags & RESIZE_LEFT ? textwin_border_color_selected : textwin_border_color); 00516 box.x = x + widget->wd - 1; 00517 box.y = y; 00518 box.w = 1; 00519 box.h = widget->ht; 00520 SDL_FillRect(ScreenSurface, &box, widget->resize_flags & RESIZE_RIGHT ? textwin_border_color_selected : textwin_border_color); 00521 } 00522 00527 void textwin_event(widgetdata *widget, SDL_Event *event) 00528 { 00529 textwin_struct *textwin = TEXTWIN(widget); 00530 00531 if (!textwin) 00532 { 00533 return; 00534 } 00535 00536 if (event->button.button == SDL_BUTTON_LEFT) 00537 { 00538 if (event->type == SDL_MOUSEBUTTONUP) 00539 { 00540 textwin->selection_started = 0; 00541 textwin->flags &= ~TW_SCROLL; 00542 } 00543 else if (event->type == SDL_MOUSEBUTTONDOWN) 00544 { 00545 textwin->selection_started = 0; 00546 textwin->selection_start = -1; 00547 textwin->selection_end = -1; 00548 selection_widget = widget; 00549 WIDGET_REDRAW(widget); 00550 } 00551 else if (event->type == SDL_MOUSEMOTION) 00552 { 00553 WIDGET_REDRAW(widget); 00554 textwin->selection_started = 1; 00555 } 00556 } 00557 00558 if (event->type == SDL_MOUSEBUTTONDOWN) 00559 { 00560 int old_scroll; 00561 00562 /* Scrolling */ 00563 if (textwin->flags & TW_SCROLL) 00564 { 00565 return; 00566 } 00567 00568 old_scroll = textwin->scroll; 00569 00570 if (event->button.button == SDL_BUTTON_WHEELUP) 00571 { 00572 textwin->scroll--; 00573 } 00574 else if (event->button.button == SDL_BUTTON_WHEELDOWN) 00575 { 00576 textwin->scroll++; 00577 } 00578 else if (event->button.button == SDL_BUTTON_LEFT) 00579 { 00580 /* Clicked scroller button up */ 00581 if (textwin->highlight == TW_HL_UP) 00582 { 00583 textwin->scroll--; 00584 } 00585 /* Clicked above the slider */ 00586 else if (textwin->highlight == TW_ABOVE) 00587 { 00588 textwin->scroll -= TEXTWIN_ROWS_VISIBLE(widget); 00589 } 00590 /* Clicked on the slider */ 00591 else if (textwin->highlight == TW_HL_SLIDER) 00592 { 00593 textwin->flags |= TW_SCROLL; 00594 textwin->highlight = TW_HL_SLIDER; 00595 textwin->old_slider_pos = event->motion.y - textwin->slider_y; 00596 WIDGET_REDRAW(widget); 00597 } 00598 /* Clicked under the slider */ 00599 else if (textwin->highlight == TW_UNDER) 00600 { 00601 textwin->scroll += TEXTWIN_ROWS_VISIBLE(widget); 00602 } 00603 /* Clicked scroller button down */ 00604 else if (textwin->highlight == TW_HL_DOWN) 00605 { 00606 textwin->scroll++; 00607 } 00608 } 00609 00610 textwin_scroll_adjust(widget); 00611 00612 if (textwin->scroll != old_scroll) 00613 { 00614 WIDGET_REDRAW(widget); 00615 } 00616 } 00617 else if (event->type == SDL_MOUSEMOTION) 00618 { 00619 int old_highlight = textwin->highlight; 00620 00621 textwin->highlight = TW_HL_NONE; 00622 00623 /* Highlighting */ 00624 if (event->motion.x > widget->x1 + widget->wd - 11 && event->motion.y > widget->y1 + 2 && event->motion.x < widget->x1 + widget->wd - 2 && event->motion.y < widget->y1 + widget->ht - 2) 00625 { 00626 if (event->motion.y < textwin->y + Bitmaps[BITMAP_SLIDER_UP]->bitmap->h + 3) 00627 { 00628 textwin->highlight = TW_HL_UP; 00629 } 00630 else if (event->motion.y < textwin->y + Bitmaps[BITMAP_SLIDER_UP]->bitmap->h + 3 + textwin->slider_y) 00631 { 00632 textwin->highlight = TW_ABOVE; 00633 } 00634 else if (event->motion.y < textwin->y + Bitmaps[BITMAP_SLIDER_UP]->bitmap->h + 3 + textwin->slider_y + textwin->slider_h + 3) 00635 { 00636 textwin->highlight = TW_HL_SLIDER; 00637 } 00638 else if (event->motion.y < widget->y1 + widget->ht - 12) 00639 { 00640 textwin->highlight = TW_UNDER; 00641 } 00642 else if (event->motion.y < widget->y1 + widget->ht) 00643 { 00644 textwin->highlight = TW_HL_DOWN; 00645 } 00646 } 00647 00648 if (textwin->highlight != old_highlight) 00649 { 00650 WIDGET_REDRAW(widget); 00651 } 00652 00653 /* Slider scrolling */ 00654 if (textwin->flags & TW_SCROLL && event->button.button == SDL_BUTTON_LEFT) 00655 { 00656 textwin->slider_y = event->motion.y - textwin->old_slider_pos; 00657 00658 textwin->scroll = TEXTWIN_ROWS_VISIBLE(widget) + MAX(0, textwin->slider_y) * textwin->num_entries / (widget->ht - 20); 00659 textwin_scroll_adjust(widget); 00660 00661 WIDGET_REDRAW(widget); 00662 } 00663 } 00664 } 00665 00671 void menu_textwin_clear(widgetdata *widget, int x, int y) 00672 { 00673 textwin_struct *textwin; 00674 00675 (void) x; 00676 (void) y; 00677 00678 textwin = TEXTWIN(widget); 00679 free(textwin->entries); 00680 textwin->entries = NULL; 00681 textwin->num_entries = textwin->entries_size = textwin->scroll = textwin->slider_h = textwin->slider_y = 0; 00682 WIDGET_REDRAW(widget); 00683 } 00684 00689 static void textwin_font_adjust(widgetdata *widget, int adjust) 00690 { 00691 textwin_struct *textwin; 00692 int font; 00693 00694 textwin = TEXTWIN(widget); 00695 font = MAX(FONT_ARIAL10, MIN(FONT_ARIAL16, textwin->font + adjust)); 00696 00697 if (textwin->font != font) 00698 { 00699 textwin->font = font; 00700 textwin_readjust(widget); 00701 WIDGET_REDRAW(widget); 00702 } 00703 } 00704 00710 void menu_textwin_font_inc(widgetdata *widget, int x, int y) 00711 { 00712 (void) x; 00713 (void) y; 00714 textwin_font_adjust(widget, 1); 00715 } 00716 00722 void menu_textwin_font_dec(widgetdata *widget, int x, int y) 00723 { 00724 (void) x; 00725 (void) y; 00726 textwin_font_adjust(widget, -1); 00727 }
1.7.4