00001
00002
00003
00004
00005 #include <ALL.H>
00006 #include <OINFO.H>
00007 #include <OMOUSE.H>
00008 #include <OVGA.H>
00009 #include <OSYS.H>
00010 #include <OFONT.H>
00011 #include <OPOWER.H>
00012 #include <OVBROW98.H>
00013 #include <OIFACE.H>
00014
00015
00016
00017 char VBrowse98::press_record=0;
00018 VBrowse98* VBrowse98::press_vbrowse_ptr;
00019
00020 VBrowse98::VBrowse98() {
00021 init_flag=0;
00022 refresh_bitmap=NULL;
00023 }
00024
00025 VBrowse98::~VBrowse98() {
00026 deinit();
00027 }
00028
00029 void VBrowse98::deinit() {
00030 if(refresh_bitmap) {
00031 mem_del(refresh_bitmap);
00032 refresh_bitmap=NULL;
00033 }
00034 }
00035
00036
00055
00056 int recWidth, int recHeight,
00057 int totalRec, BrowDispFP dispFunc,
00058 BrowDetectFP detectFunc,
00059 int dispFrame, int minInterSpace) {
00060 x1 = inX1;
00061 y1 = inY1;
00062 x2 = inX2;
00063 y2 = inY2;
00064
00065 ix1 = x1+6;
00066 iy1 = y1+6;
00067 ix2 = x2-6-SCROLL_BAR_WIDTH;
00068 iy2 = y2-6;
00069
00070
00071
00072 if( recWidth <= 0 )
00073 rec_width = ix2-ix1+1;
00074 else
00075 rec_width = recWidth;
00076
00077 rec_height = recHeight;
00078
00079 disp_rec_func = dispFunc;
00080 disp_frame = dispFrame;
00081
00082 x_max_rec = (ix2-ix1+minInterSpace+1) / (rec_width +minInterSpace);
00083 y_max_rec = (iy2-iy1+minInterSpace+1) / (rec_height+minInterSpace);
00084
00085 detect_pull_flag = 1;
00086
00087 err_if( x_max_rec <= 0 || y_max_rec <= 0 )
00088 err_now( "VBrowse98::init() error : disp_max_rec <= 0" );
00089
00090
00091
00092 if( x_max_rec > 1 )
00093 rec_x_space = minInterSpace + (ix2-ix1+minInterSpace+1) % (rec_width +minInterSpace)/(x_max_rec-1);
00094 else
00095 rec_x_space = minInterSpace;
00096
00097 if( y_max_rec > 1 )
00098 rec_y_space = minInterSpace + (iy2-iy1+minInterSpace+1) % (rec_height+minInterSpace)/(y_max_rec-1);
00099 else
00100 rec_y_space = minInterSpace;
00101
00102 init_var(totalRec,-1);
00103
00104 init_flag = 1;
00105
00106
00107
00108 paint();
00109 }
00110
00111
00112
00113
00117
00118 if( totalRec >= 0 ) {
00119 none_record = totalRec==0;
00120
00121 if( totalRec == 0 )
00122 total_rec_num = 1;
00123 else
00124 total_rec_num = totalRec;
00125 }
00126
00127
00128
00129 disp_max_rec = x_max_rec * y_max_rec;
00130
00131 if( disp_max_rec > total_rec_num )
00132 disp_max_rec = total_rec_num;
00133
00134
00135
00136 rec_no = recNo;
00137
00138 if(((recNo<top_rec_no)&&(recNo>top_rec_no+disp_max_rec-1))
00139 ||(init_flag==0)) {
00140
00141 top_rec_no = recNo - disp_max_rec/2;
00142 top_rec_no = max(1,top_rec_no);
00143
00144 if( top_rec_no+disp_max_rec-1 > total_rec_num ) {
00145 top_rec_no = total_rec_num-disp_max_rec+1;
00146 top_rec_no = max(top_rec_no,1);
00147 }
00148 }
00149
00150
00151
00152
00153
00154
00155
00156
00157 scroll_bar.init( 1, x2-SCROLL_BAR_WIDTH-7, y1+4, x2-7, y2-4, disp_max_rec,
00158 (disp_frame && x_max_rec==1 ? 1 : disp_max_rec),
00159 total_rec_num, 1 );
00160 }
00161
00162
00163
00164
00176
00177 state = 1;
00178
00179 if( newTotalRec >= 0 )
00180 total_rec_num = newTotalRec;
00181
00182 if( recNo > 0 )
00183 rec_no = recNo;
00184
00185 if( rec_no<1 )
00186 rec_no=1;
00187
00188 if( rec_no > total_rec_num )
00189 rec_no = total_rec_num;
00190
00191
00192
00193 if( !newTotalRec ) {
00194 top_rec_no = rec_no - disp_max_rec/2;
00195 top_rec_no = max(1,top_rec_no);
00196 }
00197 else {
00198 if( rec_no > top_rec_no+disp_max_rec-1 )
00199 top_rec_no = rec_no-disp_max_rec+1;
00200
00201 if( rec_no < top_rec_no )
00202 top_rec_no = rec_no;
00203 }
00204
00205
00206 if( top_rec_no+disp_max_rec-1 > total_rec_num ) {
00207 top_rec_no = total_rec_num-disp_max_rec+1;
00208 top_rec_no = max(top_rec_no,1);
00209 }
00210
00211
00212
00213 disp_all();
00214 }
00215
00216
00217
00218
00222
00223 state = 0;
00224
00225
00226
00227
00228 Vga::active_buf->d3_panel_up( x1+1, y1+1, x2-SCROLL_BAR_WIDTH-3, y2-1 );
00229 }
00230
00231
00232
00233
00237
00238 vga.use_back();
00239 refresh_bitmap=vga_back.save_area( x1, y1, x2-SCROLL_BAR_WIDTH-3, y2,refresh_bitmap);
00240 scroll_bar.paint();
00241 sys.yield();
00242 }
00243
00244
00245
00246
00255
00256 disp_one(rec_no,CLEAR_HIGH);
00257
00258 if( newRecNo>=0 || newTotalRec>=0 ) {
00259 if( newRecNo >= 1 )
00260 rec_no = newRecNo;
00261
00262 if( newTotalRec != -1 && rec_no > newTotalRec )
00263 rec_no = newTotalRec;
00264
00265 if( rec_no==0 && newTotalRec>0 )
00266 rec_no=1;
00267
00268 init_var(newTotalRec,rec_no);
00269 }
00270
00271 disp_all();
00272 }
00273
00274
00275
00276
00280
00281 int recNo, x, y;
00282
00283 if( none_record )
00284 return;
00285
00286 for( recNo=top_rec_no ; recNo<=total_rec_num && recNo<top_rec_no+disp_max_rec ; recNo++ ) {
00287 y = iy1 + (recNo-top_rec_no)/x_max_rec * (rec_height+rec_y_space);
00288 x = ix1 + (recNo-top_rec_no)%x_max_rec * (rec_width+rec_x_space);
00289
00290 disp_rec( recNo, x, y, INFO_UPDATE );
00291 }
00292 }
00293
00294
00295
00296
00303
00304 int newRecNo=0, rc;
00305
00306 double_click = 0;
00307
00308 if( state == 0 || none_record )
00309 return 0;
00310
00311
00312
00313
00314 if( detect_pull_flag && disp_frame && x_max_rec==1 ) {
00315 if( detect_pull() )
00316 return rec_no;
00317 }
00318
00319
00320
00321 if( disp_frame ) {
00322
00323
00324 if( mouse.any_click(ix1, iy1, ix2, iy2) ) {
00325
00326 newRecNo = top_rec_no +
00327 (mouse.cur_y-iy1) / (rec_height+rec_y_space) * x_max_rec +
00328 (mouse.cur_x-ix1) / (rec_width +rec_x_space);
00329
00330 if( detect_pull_flag )
00331 press_record = 1;
00332
00333 press_vbrowse_ptr = this;
00334 }
00335
00336
00337 if( newRecNo>=top_rec_no && newRecNo<=top_rec_no-1+disp_max_rec ) {
00338 if( mouse.click_count()==2 )
00339 double_click = 1;
00340
00341 if( newRecNo != rec_no ) {
00342 disp_one(rec_no, CLEAR_HIGH);
00343 disp_one(newRecNo , DISP_HIGH );
00344
00345 rec_no = newRecNo;
00346 return rec_no;
00347 }
00348
00349 if( double_click )
00350 return rec_no;
00351 }
00352 }
00353 else {
00354 if( mouse.any_click( ix1, iy1, ix2, iy2 ) ) {
00355 int newTopRec;
00356
00357 if( mouse.click_y() < iy1+ ( (iy2-iy1) >> 1 ) )
00358 newTopRec = scroll_bar.page_up();
00359 else
00360 newTopRec = scroll_bar.page_down();
00361
00362 if( top_rec_no != newTopRec ) {
00363 double_click = mouse.click_count()==2;
00364
00365 rec_no = top_rec_no = newTopRec;
00366 disp_all();
00367
00368 return rec_no;
00369 }
00370 }
00371 }
00372
00373
00374
00375 if( ( rc=scroll_bar.detect() ) > 0 ) {
00376 disp_one(rec_no,CLEAR_HIGH);
00377 rec_no = rc;
00378
00379 if( disp_frame && x_max_rec==1 ) {
00380 if( rec_no < top_rec_no ) {
00381 top_rec_no = rec_no;
00382 disp_all();
00383 }
00384
00385 else if( rec_no >= top_rec_no + disp_max_rec ) {
00386 top_rec_no = rec_no - disp_max_rec + 1;
00387 if( top_rec_no < 1 )
00388 top_rec_no = 1;
00389 disp_all();
00390 }
00391
00392 else
00393 disp_one(rec_no,DISP_HIGH);
00394 }
00395 else {
00396 top_rec_no = rc;
00397 disp_all();
00398 }
00399
00400 return rec_no;
00401 }
00402
00403 return 0;
00404 }
00405
00406
00407
00408
00412
00413 if( press_record ) {
00414 press_record = mouse.left_press;
00415
00416 if( press_record )
00417 press_vbrowse_ptr = this;
00418 }
00419
00420 if( !( mouse.left_press || mouse.click_count() ) )
00421 return 0;
00422
00423 if( !press_record )
00424 return 0;
00425
00426
00427
00428 if( ( x_max_rec==1 && mouse.press_area( x1, 0 , x2, y1 ) ) ||
00429 ( y_max_rec==1 && mouse.press_area( 0, y1, x1, y2 ) ) ) {
00430 if( rec_no > 1 ) {
00431 disp_one(rec_no, CLEAR_HIGH);
00432
00433 rec_no--;
00434 if( rec_no < top_rec_no )
00435 top_rec_no--;
00436
00437 disp_all();
00438 return 1;
00439 }
00440 }
00441
00442
00443
00444 if( ( x_max_rec==1 && mouse.press_area( x1, y2, x2, VGA_HEIGHT-1 ) ) ||
00445 ( y_max_rec==1 && mouse.press_area( x2, y1, VGA_WIDTH-1, y2 ) ) ) {
00446 if( rec_no < total_rec_num ) {
00447 disp_one(rec_no, CLEAR_HIGH);
00448
00449 rec_no++;
00450 if( rec_no >= top_rec_no+disp_max_rec )
00451 top_rec_no++;
00452
00453 disp_all();
00454 return 1;
00455 }
00456 }
00457
00458 return 0;
00459 }
00460
00461
00462
00463
00470
00471 if( state == 0 || none_record )
00472 return 0;
00473
00474
00475 if( mouse.single_click( ix1, iy1, ix2, iy2, 1 ) ) {
00476 int recNo;
00477
00478 recNo = top_rec_no +
00479 (mouse.click_y(1)-iy1) / (rec_height+rec_y_space) * x_max_rec +
00480 (mouse.click_x(1)-ix1) / (rec_width +rec_x_space);
00481
00482 if( recNo <= top_rec_no-1+disp_max_rec ) {
00483 disp_one(rec_no,CLEAR_HIGH);
00484 disp_one(recNo, DISP_HIGH);
00485
00486 rec_no = recNo;
00487 return recNo;
00488 }
00489 }
00490
00491 return 0;
00492 }
00493
00494
00495
00496
00500
00501 int recNo;
00502
00503 int scrollRecno = (disp_frame && x_max_rec==1) ? rec_no : top_rec_no;
00504
00505 scroll_bar.refresh( scrollRecno, 1, disp_max_rec,
00506 (disp_frame && x_max_rec==1 ? 1 : disp_max_rec),
00507 total_rec_num );
00508
00509 for( recNo=top_rec_no ; recNo<=total_rec_num && recNo<top_rec_no+disp_max_rec ; recNo++ ) {
00510 disp_one( recNo, DISP_REC );
00511
00512 if( recNo == rec_no )
00513 disp_one( recNo, DISP_HIGH );
00514 }
00515 }
00516
00517
00518
00519
00526
00527 if( none_record )
00528 return;
00529
00530 int x,y;
00531
00532 y = iy1 + (recNo-top_rec_no)/x_max_rec * (rec_height+rec_y_space);
00533 x = ix1 + (recNo-top_rec_no)%x_max_rec * (rec_width+rec_x_space);
00534
00535
00536
00537 if( disp_frame && dispType == CLEAR_HIGH ) {
00538 vga_back.rest_area_with_clipping(refresh_bitmap,
00539 x-2-x1,y-2-y1,x+rec_width-3-x1, y+rec_height+1-y1,
00540 0,1);
00541 disp_rec( recNo, x, y, INFO_REPAINT );
00542 vga.blt_buf(x-2,y-2,x+rec_width-3,y+rec_height-1);
00543 }
00544
00545 if( dispType == DISP_REC ) {
00546 disp_rec( recNo, x, y, INFO_REPAINT );
00547
00548 vga.blt_buf(x-2,y-2,x+rec_width-3,y+rec_height-1);
00549 }
00550 if( disp_frame && dispType == DISP_HIGH ) {
00551 vga_back.rest_area_with_clipping(refresh_bitmap,
00552 x-2-x1,y-2-y1,x+rec_width-3-x1, y+rec_height+1-y1,
00553 0,1);
00554 disp_rec( recNo, x, y, INFO_REPAINT );
00555 user_interface.darken(x-2,y+rec_height-2,x+rec_width-7,y+rec_height-1);
00556 user_interface.darken(x+rec_width-9,y-2,x+rec_width-7,y+rec_height-3);
00557 user_interface.darken(x-2,y-2,x+rec_width-7,y+rec_height-1);
00558 vga.blt_buf(x-2,y-2,x+rec_width-7,y+rec_height-1);
00559
00560 int scrollRecno = (disp_frame && x_max_rec==1) ? recNo : top_rec_no;
00561
00562 scroll_bar.refresh( scrollRecno, 0, disp_max_rec,
00563 (disp_frame && x_max_rec==1 ? 1 : disp_max_rec),
00564 total_rec_num );
00565 }
00566 }
00567
00568
00569
00570
00572
00573 vga.use_back();
00574 vga_back.rest_area_with_clipping(refresh_bitmap,
00575 0,y-y1,(rec_width-SCROLL_BAR_WIDTH+12),rec_height+y-y1,
00576 0,1);
00577 (*disp_rec_func)( recNo, x, y, refreshFlag );
00578 }
00579
00580