00001
00002
00003
00004 #include <OMOUSECR.H>
00005 #include <ALL.H>
00006 #include <OSYS.H>
00007 #include <OINFO.H>
00008 #include <OVGA.H>
00009 #include <ODB.H>
00010 #include <OMOUSE.H>
00011 #include <OWORLDMT.H>
00012 #include <OBLOB2W.H>
00013 #include <OBOX.H>
00014
00015
00016
00017 #define CURSOR_DBF DIR_RES"CURSOR.RES"
00018
00019
00020
00021 MouseCursor::MouseCursor() {
00022 memset( this, 0, sizeof(MouseCursor) );
00023 }
00024
00025
00026
00027
00028
00029 MouseCursor::~MouseCursor() {
00030 deinit();
00031 }
00032
00033
00034
00035
00037
00038
00039
00040 String str;
00041
00042 str = DIR_RES;
00043 str += "I_CURSOR.RES";
00044
00045 res_bitmap.init_imported(str,1);
00046
00047
00048
00049 load_cursor_info();
00050
00051
00052
00053 save_scr = new Blob2DW;
00054 save_back_scr = new Blob2DW;
00055 merge_buf = new Blob2DW;
00056
00057 init_flag=1;
00058 }
00059
00060
00061
00062
00063
00064 void MouseCursor::deinit() {
00065 if( init_flag ) {
00066 mem_del(cursor_info_array);
00067
00068 if( save_scr ) {
00069 delete save_scr;
00070 save_scr = NULL;
00071 }
00072
00073 if( save_back_scr ) {
00074 delete save_back_scr;
00075 save_back_scr = NULL;
00076 }
00077
00078 if( merge_buf ) {
00079 delete merge_buf;
00080 merge_buf = NULL;
00081 }
00082
00083 init_flag = 0;
00084 icon_ptr = NULL;
00085
00086 cur_icon = 0;
00087
00088 }
00089 }
00090
00091
00092
00093
00095
00096 CursorRec *cursorRec;
00097 CursorInfo *cursorInfo;
00098 int i;
00099 long bitmapOffset;
00100 Database dbCursor(CURSOR_DBF, 1);
00101
00102 cursor_count = (short) dbCursor.rec_count();
00103 cursor_info_array = (CursorInfo*) mem_add( sizeof(CursorInfo)*cursor_count );
00104
00105
00106
00107 memset( cursor_info_array, 0, sizeof(CursorInfo) * cursor_count );
00108
00109 for( i=0 ; i<cursor_count ; i++ ) {
00110 cursorRec = (CursorRec*) dbCursor.read(i+1);
00111 cursorInfo = cursor_info_array+i;
00112
00113 memcpy( &bitmapOffset, cursorRec->bitmap_ptr, sizeof(long) );
00114
00115 cursorInfo->bitmap_ptr = res_bitmap.read_imported(bitmapOffset);
00116
00117 cursorInfo->hot_spot_x = m.atoi( cursorRec->hot_spot_x, cursorRec->HOT_SPOT_LEN );
00118 cursorInfo->hot_spot_y = m.atoi( cursorRec->hot_spot_y, cursorRec->HOT_SPOT_LEN );
00119 }
00120 }
00121
00122
00123
00124
00130
00131 if(box.progress_val>0)
00132 if(info.prerun_year==1) {
00133 cursorId=CURSOR_WAITING;
00134 }
00135
00136 if( !init_flag )
00137 return;
00138
00139
00140
00141 int hideAllFlag = hide_all_flag;
00142
00143 if( !hideAllFlag )
00144 mouse.hide();
00145
00146
00147
00148 CursorInfo* cursorInfo = cursor_info_array+cursorId-1;
00149
00150 icon_ptr = cursorInfo->bitmap_ptr;
00151 hot_spot_x = cursorInfo->hot_spot_x;
00152 hot_spot_y = cursorInfo->hot_spot_y;
00153
00154 err_when( !icon_ptr );
00155
00156 icon_width = *((short*)icon_ptr);
00157 icon_height = *((short*)icon_ptr+1);
00158
00159
00160 cur_icon = cursorId;
00161
00162
00163
00164
00165 save_scr->clear();
00166 save_scr->resize( 0, 0, icon_width, icon_height );
00167 save_back_scr->clear();
00168 save_back_scr->resize(0, 0, icon_width, icon_height);
00169 merge_buf->clear();
00170 merge_buf->resize(0, 0, icon_width,icon_height);
00171
00172
00173
00174 if( !hideAllFlag ) {
00175 if( vga_front.dd_buf ) {
00176 mouse.show();
00177 sys.blt_virtual_buf();
00178 }
00179 }
00180 }
00181
00182
00183
00184
00191
00192 if( frame_flag == frameFlag )
00193 return;
00194
00195 frame_flag = frameFlag;
00196 frame_shown = 0;
00197 }
00198
00199
00200
00201
00202
00203 void MouseCursor::set_frame_border(int borderX1, int borderY1, int borderX2, int borderY2) {
00204 frame_border_x1 = borderX1;
00205 frame_border_y1 = borderY1;
00206 frame_border_x2 = borderX2;
00207 frame_border_y2 = borderY2;
00208 }
00209
00210
00211
00212
00213
00214 void MouseCursor::process(int curX, int curY) {
00215 if( processing_flag || !icon_ptr)
00216 return;
00217
00218 if( !vga_front.dd_buf )
00219 return;
00220
00221 processing_flag = 1;
00222
00223
00224
00225 if( cursor_shown )
00226 vga_front.put_bitmapW( max(cur_x1,0), max(cur_y1,0), save_scr->bitmap_ptr() );
00227
00228
00230
00231
00232
00233 if( frame_flag ) {
00234 curX = max(curX, ZOOM_X1);
00235 curY = max(curY, ZOOM_Y1);
00236 curX = min(curX, ZOOM_X2);
00237 curY = min(curY, ZOOM_Y2);
00238
00239 process_frame(curX, curY);
00240 }
00241
00242
00243
00244 cur_x1 = curX - hot_spot_x;
00245 cur_y1 = curY - hot_spot_y;
00246 cur_x2 = cur_x1 + icon_width - 1;
00247 cur_y2 = cur_y1 + icon_height - 1;
00248
00249
00250
00251 if( hide_all_flag || ( hide_area_flag &&
00252 is_touch( hide_x1, hide_y1, hide_x2, hide_y2 ) ) ) {
00253 cursor_shown = 0;
00254 }
00255 else {
00256
00257
00258 if( cur_x1 < 0 || cur_x2 >= VGA_WIDTH || cur_y1 < 0 || cur_y2 >= VGA_HEIGHT ) {
00259 vga_front.read_bitmapW( max(cur_x1,0), max(cur_y1,0),
00260 min(cur_x2,VGA_WIDTH-1), min(cur_y2,VGA_HEIGHT-1), save_scr->bitmap_ptr() );
00261
00262 vga_front.put_bitmap_area_trans( cur_x1, cur_y1, icon_ptr,
00263 max(0,cur_x1)-cur_x1, max(0,cur_y1)-cur_y1,
00264 min(VGA_WIDTH-1,cur_x2)-cur_x1, min(VGA_HEIGHT-1,cur_y2)-cur_y1 );
00265 }
00266 else {
00267 vga_front.read_bitmapW( cur_x1, cur_y1, cur_x2, cur_y2, save_scr->bitmap_ptr() );
00268
00269 vga_front.put_bitmap_trans( cur_x1, cur_y1, icon_ptr );
00270 }
00271
00272 cursor_shown = 1;
00273 }
00274
00275
00276
00277 processing_flag = 0;
00278 }
00279
00280
00281
00282
00283
00284 void MouseCursor::process_frame(int curX, int curY) {
00285
00286
00287 if( frame_shown ) {
00288 vga_front.put_bitmapW( frame_x1, frame_y1, frame_top_save_scr );
00289 vga_front.put_bitmapW( frame_x1, frame_y2, frame_bottom_save_scr );
00290 vga_front.put_bitmapW( frame_x1, frame_y1, frame_left_save_scr );
00291 vga_front.put_bitmapW( frame_x2, frame_y1, frame_right_save_scr );
00292 }
00293
00294
00295
00296 if( !frame_shown ) {
00297 frame_origin_x = curX;
00298 frame_origin_y = curY;
00299
00300 frame_x1 = curX;
00301 frame_y1 = curY;
00302 frame_x2 = curX;
00303 frame_y2 = curY;
00304 }
00305 else {
00306
00307
00308 if( curX > frame_origin_x ) {
00309 if( curY > frame_origin_y ) {
00310 frame_x1 = frame_origin_x;
00311 frame_y1 = frame_origin_y;
00312 frame_x2 = curX;
00313 frame_y2 = curY;
00314 }
00315 else {
00316 frame_x1 = frame_origin_x;
00317 frame_y1 = curY;
00318 frame_x2 = curX;
00319 frame_y2 = frame_origin_y;
00320 }
00321 }
00322 else {
00323 if( curY > frame_origin_y ) {
00324 frame_x1 = curX;
00325 frame_y1 = frame_origin_y;
00326 frame_x2 = frame_origin_x;
00327 frame_y2 = curY;
00328 }
00329 else {
00330 frame_x1 = curX;
00331 frame_y1 = curY;
00332 frame_x2 = frame_origin_x;
00333 frame_y2 = frame_origin_y;
00334 }
00335 }
00336 }
00337
00338
00339
00340 disp_frame(&vga_front);
00341 }
00342
00343
00344
00345
00346
00347 void MouseCursor::disp_frame(VgaBuf* vgaBufPtr) {
00348
00349
00350 vgaBufPtr->read_bitmapW( frame_x1, frame_y1, frame_x2, frame_y1, frame_top_save_scr );
00351 vgaBufPtr->read_bitmapW( frame_x1, frame_y2, frame_x2, frame_y2, frame_bottom_save_scr );
00352 vgaBufPtr->read_bitmapW( frame_x1, frame_y1, frame_x1, frame_y2, frame_left_save_scr );
00353 vgaBufPtr->read_bitmapW( frame_x2, frame_y1, frame_x2, frame_y2, frame_right_save_scr );
00354
00355
00356
00357 vgaBufPtr->rect( frame_x1, frame_y1, frame_x2, frame_y2, 1, OWN_SELECT_FRAME_COLOR );
00358
00359
00360
00361 frame_shown = 1;
00362 }
00363
00364
00365
00366
00370
00371 if( !icon_ptr )
00372 return;
00373
00374
00375
00376 if( frame_flag )
00377 disp_frame(&vga_back);
00378
00379
00380
00381 if( is_touch(bltX1, bltY1, bltX2, bltY2) ) {
00382
00383
00384 int x1 = max(cur_x1,bltX1);
00385 int y1 = max(cur_y1,bltY1);
00386 int x2 = min(cur_x2,bltX2);
00387 int y2 = min(cur_y2,bltY2);
00388
00389 vga_back.read_bitmapW( x1, y1, x2, y2, save_back_scr->bitmap_ptr() );
00390
00391
00392
00393
00394
00395
00396
00397
00398 IMGbltW( save_scr->buf_ptr(), sizeof(short) * (min(cur_x2,VGA_WIDTH-1) -max(cur_x1,0)+1), x1-max(cur_x1,0), y1-max(cur_y1,0), save_back_scr->bitmap_ptr() );
00399
00400
00401
00402 if( cur_x1 < bltX1 || cur_x2 > bltX2 || cur_y1 < bltY1 || cur_y2 > bltY2 ) {
00403 vga_back.put_bitmap_area_trans( cur_x1, cur_y1, icon_ptr,
00404 max(bltX1,cur_x1)-cur_x1, max(bltY1,cur_y1)-cur_y1,
00405 min(bltX2,cur_x2)-cur_x1, min(bltY2,cur_y2)-cur_y1 );
00406 }
00407
00408
00409
00410 else {
00411 vga_back.put_bitmap_trans(cur_x1, cur_y1, icon_ptr);
00412 }
00413
00414 cursor_shown = 1;
00415 }
00416 }
00417
00418
00419
00420
00426
00427 return (( cur_y1 <= y1 && cur_y2 >= y1 ) ||
00428 ( y1 <= cur_y1 && y2 >= cur_y1 )) &&
00429 (( cur_x1 <= x1 && cur_x2 >= x1 ) ||
00430 ( x1 <= cur_x1 && x2 >= cur_x1 ));
00431 }
00432
00433
00434
00435
00436
00437 void MouseCursor::restore_icon(int newCursorId) {
00438 if(box.progress_val>0)
00439 if(info.prerun_year==1) {
00440 newCursorId=CURSOR_WAITING;
00441 }
00442
00443 if( newCursorId == 0) {
00444 err_here();
00445
00446
00447 if( !hide_all_flag )
00448 mouse.hide();
00449 cur_icon = 0;
00450 icon_ptr = NULL;
00451 }
00452 else if( cur_icon == 0 || newCursorId != cur_icon ) {
00453 set_icon(newCursorId);
00454 }
00455 }
00456
00457
00458