BARBOX.C 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/ui/rcs/barbox.c $
  15. * $Revision: 1.2 $
  16. * $Author: john $
  17. * $Date: 1994/01/18 11:07:45 $
  18. *
  19. * File for creating a barbox...
  20. *
  21. * $Log: barbox.c $
  22. * Revision 1.2 1994/01/18 11:07:45 john
  23. * *** empty log message ***
  24. *
  25. * Revision 1.1 1994/01/10 15:24:32 john
  26. * Initial revision
  27. *
  28. *
  29. */
  30. #pragma off (unreferenced)
  31. static char rcsid[] = "$Id: barbox.c 1.2 1994/01/18 11:07:45 john Exp $";
  32. #pragma on (unreferenced)
  33. #include <stdio.h>
  34. #include <stdarg.h>
  35. #include "fix.h"
  36. #include "types.h"
  37. #include "gr.h"
  38. #include "ui.h"
  39. #include "key.h"
  40. static UI_WINDOW * wnd = NULL;
  41. static int bar_width, bar_height, bar_x, bar_y, bar_maxlength;
  42. void ui_barbox_open( char * text, int length )
  43. {
  44. grs_font * temp_font;
  45. short text_width, text_height, avg;
  46. int w,h, width, height, xc, yc, x, y;
  47. w = grd_curscreen->sc_w;
  48. h = grd_curscreen->sc_h;
  49. width = w/3;
  50. bar_maxlength = length;
  51. if ( w < 640 ) {
  52. temp_font = grd_curscreen->sc_canvas.cv_font;
  53. grd_curscreen->sc_canvas.cv_font = ui_small_font;
  54. }
  55. gr_get_string_size(text, &text_width, &text_height, &avg );
  56. text_width += avg*6;
  57. text_width += 10;
  58. if (text_width > width )
  59. width = text_width;
  60. height = text_height;
  61. height += 30;
  62. xc = w/2;
  63. yc = h/2;
  64. x = xc - width/2;
  65. y = yc - height/2;
  66. if (x < 0 ) x = 0;
  67. if ( (x+width-1) >= w ) x = w - width;
  68. if (y < 0 ) y = 0;
  69. if ( (y+height-1) >= h ) y = h - height;
  70. wnd = ui_open_window( x, y, width, height, WIN_DIALOG );
  71. y = 5 + text_height/2 ;
  72. ui_string_centered( width/2, y, text );
  73. y = 10 + text_height;
  74. bar_width = width - 15;
  75. bar_height = 10;
  76. bar_x = (width/2) - (bar_width/2);
  77. bar_y = height - 15;
  78. ui_draw_line_in( bar_x-2, bar_y-2, bar_x+bar_width+1, bar_y+bar_height+1 );
  79. grd_curscreen->sc_canvas.cv_font = temp_font;
  80. }
  81. int ui_barbox_update( int position )
  82. {
  83. int spos;
  84. spos = (position * bar_width)/bar_maxlength;
  85. gr_set_current_canvas( wnd->canvas );
  86. ui_mouse_hide();
  87. gr_setcolor( BM_XRGB(0,0,10));
  88. gr_rect( bar_x, bar_y, bar_x+spos-1, bar_y+bar_height-1 );
  89. ui_mouse_show();
  90. ui_mouse_process();
  91. }
  92. void ui_barbox_close()
  93. {
  94. if (wnd)
  95. ui_close_window(wnd);
  96. }
  97.