UIDRAW.C 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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/uidraw.c $
  15. * $Revision: 1.5 $
  16. * $Author: john $
  17. * $Date: 1994/11/18 23:07:34 $
  18. *
  19. * Graphics primatives for the ui gadgets and windows.
  20. *
  21. * $Log: uidraw.c $
  22. * Revision 1.5 1994/11/18 23:07:34 john
  23. * Changed a bunch of shorts to ints.
  24. *
  25. * Revision 1.4 1994/09/13 11:20:22 john
  26. * Made ui_string_centered not clip.
  27. *
  28. * Revision 1.3 1993/10/26 13:46:33 john
  29. * *** empty log message ***
  30. *
  31. * Revision 1.2 1993/10/05 17:31:00 john
  32. * *** empty log message ***
  33. *
  34. * Revision 1.1 1993/09/20 10:35:41 john
  35. * Initial revision
  36. *
  37. *
  38. */
  39. #pragma off (unreferenced)
  40. static char rcsid[] = "$Id: uidraw.c 1.5 1994/11/18 23:07:34 john Exp $";
  41. #pragma on (unreferenced)
  42. #include "fix.h"
  43. #include "types.h"
  44. #include "gr.h"
  45. #include "ui.h"
  46. void Hline(short x1, short x2, short y )
  47. {
  48. gr_uscanline( x1, x2, y );
  49. }
  50. void Vline(short y1, short y2, short x )
  51. {
  52. for ( ; y1 <= y2; y1++ )
  53. gr_upixel( x, y1 );
  54. }
  55. void ui_string_centered( short x, short y, char * s )
  56. {
  57. int height, width, avg;
  58. gr_get_string_size(s, &width, &height, &avg );
  59. //baseline = height-grd_curcanv->cv_font->ft_baseline;
  60. gr_ustring(x-((width-1)/2), y-((height-1)/2), s );
  61. }
  62. void ui_draw_shad( short x1, short y1, short x2, short y2, short c1, short c2 )
  63. {
  64. gr_setcolor( c1 );
  65. Hline( x1+0, x2-1, y1+0 );
  66. Vline( y1+1, y2+0, x1+0 );
  67. gr_setcolor( c2 );
  68. Hline( x1+1, x2, y2-0 );
  69. Vline( y1+0, y2-1, x2-0 );
  70. }
  71. void ui_draw_frame( short x1, short y1, short x2, short y2 )
  72. {
  73. ui_draw_shad( x1+0, y1+0, x2-0, y2-0, CBRIGHT, CGREY );
  74. ui_draw_shad( x1+1, y1+1, x2-1, y2-1, CBRIGHT, CGREY );
  75. ui_draw_shad( x1+2, y1+2, x2-2, y2-2, CWHITE, CWHITE );
  76. ui_draw_shad( x1+3, y1+3, x2-3, y2-3, CWHITE, CWHITE );
  77. ui_draw_shad( x1+4, y1+4, x2-4, y2-4, CWHITE, CWHITE );
  78. ui_draw_shad( x1+5, y1+5, x2-5, y2-5, CWHITE, CWHITE );
  79. ui_draw_shad( x1+6, y1+6, x2-6, y2-6, CGREY, CBRIGHT );
  80. ui_draw_shad( x1+7, y1+7, x2-7, y2-7, CGREY, CBRIGHT );
  81. }
  82. void ui_draw_box_out( short x1, short y1, short x2, short y2 )
  83. {
  84. gr_setcolor( CWHITE );
  85. gr_urect( x1+2, y1+2, x2-2, y2-2 );
  86. ui_draw_shad( x1+0, y1+0, x2-0, y2-0, CBRIGHT, CGREY );
  87. ui_draw_shad( x1+1, y1+1, x2-1, y2-1, CBRIGHT, CGREY );
  88. }
  89. void ui_draw_box_in( short x1, short y1, short x2, short y2 )
  90. {
  91. gr_setcolor( CWHITE );
  92. gr_urect( x1+2, y1+2, x2-2, y2-2 );
  93. ui_draw_shad( x1+0, y1+0, x2-0, y2-0, CGREY, CBRIGHT );
  94. ui_draw_shad( x1+1, y1+1, x2-1, y2-1, CGREY, CBRIGHT );
  95. }
  96. void ui_draw_line_in( short x1, short y1, short x2, short y2 )
  97. {
  98. gr_setcolor( CGREY );
  99. Hline( x1, x2, y1 );
  100. Hline( x1, x2-1, y2-1 );
  101. Vline( y1+1, y2-2, x1 );
  102. Vline( y1+1, y2-2, x2-1 );
  103. gr_setcolor( CBRIGHT );
  104. Hline( x1+1, x2-1, y1+1 );
  105. Hline( x1, x2, y2 );
  106. Vline( y1+2, y2-2, x1+1 );
  107. Vline( y1+1, y2-1, x2 );
  108. }
  109.