OVBROWIF.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //Filename : OVBROWIF.CPP
  21. //Description : Object Visual Browse for the Interface
  22. #include <OSYS.h>
  23. #include <OINFO.h>
  24. #include <OVGA.h>
  25. #include <OVBROWIF.h>
  26. //---------- Begin of function VBrowseIF::VBrowseIF -------//
  27. //
  28. VBrowseIF::VBrowseIF()
  29. {
  30. vga_front_only = 0; // if 1, then it does all the bitmap processing on the front buffer only
  31. }
  32. //----------- End of function VBrowseIF::VBrowseIF ----------//
  33. //---------- Begin of function VBrowseIF::init_var -------//
  34. //
  35. void VBrowseIF::init_var(int totalRec, int recNo)
  36. {
  37. VBrowse::init_var(totalRec, recNo);
  38. scroll_bar.init( 1, x2-SCROLL_BAR_WIDTH, y1, x2, y2, disp_max_rec,
  39. (disp_frame && x_max_rec==1 ? 1 : disp_max_rec), // only use record as scroller unit when it's a vertical browser with frame
  40. total_rec_num, 1, 1 ); // last 1 - Interface mode if_flag is 1
  41. }
  42. //----------- End of function VBrowseIF::init_var ----------//
  43. //--------- Begin of function VBrowseIF::paint ---------//
  44. //
  45. void VBrowseIF::paint()
  46. {
  47. vga.d3_panel_down( x1, y1, x2-SCROLL_BAR_WIDTH-3, y2, vga_front_only ); // the list content box
  48. scroll_bar.paint();
  49. }
  50. //--------- End of function VBrowseIF::paint ---------//
  51. //--------- Begin of function VBrowseIF::refresh ---------//
  52. //
  53. // Reset the no. of record and current record pointer and cause displaying
  54. //
  55. // [int] newRecNo = new current record no.
  56. // (default : -1, no change)
  57. // [int] newTotalRec = new total no. of records
  58. // (default : -1, no change)
  59. //
  60. void VBrowseIF::refresh(int newRecNo, int newTotalRec)
  61. {
  62. if( !vga_front_only && !vga.use_back_buf )
  63. vga.blt_buf( x1, y1, x2-SCROLL_BAR_WIDTH-3, y2, 0 ); // the list content box
  64. VBrowse::refresh(newRecNo, newTotalRec);
  65. }
  66. //--------- End of function VBrowseIF::refresh ---------//
  67. //-------- Begin of function VBrowseIF::disp_all ----------//
  68. //
  69. // Display all records on screen, highlight cur_rec_no
  70. //
  71. void VBrowseIF::disp_all()
  72. {
  73. int recNo;
  74. if( !vga_front_only && !vga.use_back_buf )
  75. vga.blt_buf( ix1, iy1, ix2, iy2, 0 ); // clear background
  76. int scrollRecno = (disp_frame && x_max_rec==1) ? rec_no : top_rec_no;
  77. scroll_bar.refresh( scrollRecno, 1, disp_max_rec,
  78. (disp_frame && x_max_rec==1 ? 1 : disp_max_rec),
  79. total_rec_num );
  80. for( recNo=top_rec_no ; recNo<=total_rec_num && recNo<top_rec_no+disp_max_rec ; recNo++ )
  81. {
  82. disp_one( recNo, DISP_REC );
  83. if( recNo == rec_no )
  84. disp_one( recNo, DISP_HIGH );
  85. }
  86. }
  87. //--------- End of function VBrowseIF::disp_all ----------//
  88. //-------- Begin of function VBrowseIF::disp_one ----------//
  89. //
  90. // <int> recNo = the no. of the record to display
  91. // <int> putType = DISP_REC - display record
  92. // DISP_HIGH - highlight rect
  93. // CLEAR_HIGH- clear highlight rect
  94. //
  95. void VBrowseIF::disp_one(int recNo, int dispType)
  96. {
  97. if( none_record )
  98. return;
  99. int x,y;
  100. y = iy1 + (recNo-top_rec_no)/x_max_rec * (rec_height+rec_y_space);
  101. x = ix1 + (recNo-top_rec_no)%x_max_rec * (rec_width+rec_x_space);
  102. //---- put a outline rect around the record if it is highlight ---//
  103. if( disp_frame && dispType == CLEAR_HIGH && !vga.use_back_buf && !vga_front_only )
  104. {
  105. vga.blt_buf( x-2, y-2 , x+rec_width+1, y-2 , 0 ); // top
  106. vga.blt_buf( x-2, y+rec_height+1, x+rec_width+1, y+rec_height+1, 0 ); // bottom
  107. vga.blt_buf( x-2, y-2 , x-2 , y+rec_height+1, 0 ); // left
  108. vga.blt_buf( x+rec_width+1, y-2 , x+rec_width+1, y+rec_height+1, 0 ); // right
  109. }
  110. if( dispType == DISP_REC )
  111. disp_rec( recNo, x, y, INFO_REPAINT ); // call user defined function
  112. if( disp_frame && dispType == DISP_HIGH )
  113. {
  114. //-------- draw d3 up border --------//
  115. Vga::active_buf->draw_d3_up_border(x-2, y-2, x+rec_width+1, y+rec_height+1);
  116. //--------- display the record --------//
  117. int scrollRecno = (disp_frame && x_max_rec==1) ? recNo : top_rec_no;
  118. scroll_bar.refresh( scrollRecno, 0, disp_max_rec,
  119. (disp_frame && x_max_rec==1 ? 1 : disp_max_rec),
  120. total_rec_num );
  121. }
  122. }
  123. //--------- End of function VBrowseIF::disp_one ----------//
  124. //-------- Begin of function VBrowseIF::disp_rec --------//
  125. //
  126. void VBrowseIF::disp_rec(int recNo, int x, int y, int refreshFlag)
  127. {
  128. (*disp_rec_func)( recNo, x, y, refreshFlag ); // call user defined function
  129. sys.yield();
  130. }
  131. //---------- End of function VBrowseIF::disp_rec -----------//