00001
00002
00003
00004 #include <OVGA.H>
00005 #include <OSYS.H>
00006 #include <OFONT.H>
00007 #include <OINFO.H>
00008 #include <OMOUSE.H>
00009 #include <OVBROW98.H>
00010 #include <OSCROLL.H>
00011 #include <OTXTLIST.H>
00012 #include <OIFACE.H>
00013
00014
00015
00016 #define SCROLL_BAR_WIDTH 15
00017
00018 #define TEXT_LINE_SPACE 6
00019 #define TEXT_MARGIN 20
00020
00021
00022
00023 static ScrollBar scroll_bar;
00024 static TxtList* cur_txt_list_ptr;
00025 static VBrowse98 topic_browse;
00026
00027 static short * txtlist_refresh_bitmap = NULL;
00028
00029 static void disp_topic_rec(int,int,int,int);
00030 static void disp_idx_topic_rec(int,int,int,int);
00031
00032
00033
00034 TxtList::TxtList() {
00035 init_flag = 0;
00036 init_pict_flag = 0;
00037 init_list_flag = 0;
00038 history_pos = 0;
00039 can_back=0;
00040 top_line=1;
00041 memset( history_array, 0, sizeof(history_array[0]) * HISTORY_SIZE );
00042 }
00043
00044
00045
00046
00054
00055 text_x1 = x1;
00056 text_y1 = y1;
00057 text_x2 = x2-SCROLL_BAR_WIDTH-4;
00058 text_y2 = y2;
00059
00060 scroll_x1 = x2-SCROLL_BAR_WIDTH+1;
00061 scroll_y1 = y1;
00062 scroll_x2 = x2;
00063 scroll_y2 = y2;
00064
00065 res_txt.init( resTxtName, 0 );
00066
00067 if(topic_id < 1)
00068 topic_id=1;
00069
00070 init_flag = 1;
00071 }
00072
00073
00074
00075
00077
00078 res_txt .deinit();
00079
00080 res_pict.deinit();
00081 if(txtlist_refresh_bitmap)
00082 mem_del(txtlist_refresh_bitmap);
00083 txtlist_refresh_bitmap=NULL;
00084 }
00085
00086
00087
00088
00094
00095 pict_x1 = x1;
00096 pict_y1 = y1;
00097 pict_x2 = x2;
00098 pict_y2 = y2;
00099
00100 res_pict.init( resPictName, 0 );
00101
00102 init_pict_flag = 1;
00103 }
00104
00105
00106
00107
00111
00112 list_x1 = x1;
00113 list_y1 = y1;
00114 list_x2 = x2;
00115 list_y2 = y2;
00116
00117 init_list_flag = 1;
00118 top_line=1;
00119 }
00120
00121
00122
00123
00129
00130 vga.use_back();
00131 err_when( !init_flag );
00132
00133
00134
00135 char* textPtr;
00136
00137 if( topicId )
00138 topic_id = topicId;
00139
00140
00141 if(init_list_flag) {
00142 if( refreshFlag==INFO_REPAINT ) {
00143 user_interface.brighten( list_x1, list_y1, list_x2, list_y2 );
00144 user_interface.rect( list_x1, list_y1, list_x2, list_y2 );
00145
00146
00147 cur_txt_list_ptr = this;
00148
00149 topic_browse.init( list_x1, list_y1, list_x2, list_y2,
00150 0, 20, res_txt.rec_count, disp_topic_rec );
00151 topic_browse.open(topic_id);
00152 }
00153
00154 }
00155
00156 if(!init_list_flag) {
00157 if( refreshFlag==INFO_REPAINT ) {
00158 user_interface.rect( text_x1, text_y1, text_x2, text_y2 );
00159 user_interface.brighten( text_x1, text_y1, text_x2, text_y2 );
00160
00161 if( init_pict_flag )
00162 vga.active_buf->d3_panel_down( pict_x1, pict_y1, pict_x2, pict_y2, 2, 0 );
00163 cur_txt_list_ptr = this;
00164
00165 txtlist_refresh_bitmap=vga_back.save_area(
00166 text_x1,text_y1,text_x2,text_y2,
00167 txtlist_refresh_bitmap);
00168 }
00169
00170 vga_back.rest_area(txtlist_refresh_bitmap,0,1);
00171
00172 if(topicId && refreshFlag==INFO_REPAINT ) {
00173
00174 textPtr = res_txt.get_body(topic_id);
00175
00176
00177
00178 int dispLines;
00179 int totalLines;
00180
00181 font_letter.count_line( text_x1+TEXT_MARGIN, text_y1+TEXT_MARGIN,
00182 text_x2-TEXT_MARGIN+2, text_y2-TEXT_MARGIN,
00183 textPtr, TEXT_LINE_SPACE, dispLines, totalLines );
00184
00185
00186
00187 scroll_bar.init( 1, scroll_x1, scroll_y1, scroll_x2, scroll_y2,
00188 dispLines, dispLines, totalLines );
00189
00190 scroll_bar.paint();
00191 scroll_bar.refresh(top_line,1);
00192 }
00193 else {
00194 textPtr = res_txt.get_body(topic_id);
00195 }
00196 font_letter.put_paragraph( text_x1+TEXT_MARGIN, text_y1+TEXT_MARGIN,
00197 text_x2-TEXT_MARGIN+2, text_y2-TEXT_MARGIN,
00198 textPtr, TEXT_LINE_SPACE, top_line );
00199
00200 if( init_pict_flag ) {
00201 char* pictName = res_txt.get_pict_name(topic_id);
00202
00203 if( pictName[0] ) {
00204 char* pictPtr = res_pict.read(pictName);
00205
00206 if( pictPtr )
00207 vga.active_buf->put_bitmap( pict_x1+2, pict_y1+2, pictPtr );
00208 }
00209 }
00210
00211 vga.blt_buf( text_x1, text_y1, text_x2, text_y2 );
00212 }
00213
00214
00215 }
00216
00217
00218
00219
00223
00224
00225
00226
00227
00228
00229
00230
00231 int next_pos=((history_pos+1)>=HISTORY_SIZE)?0:history_pos+1;
00232 int prev_pos=((history_pos-1)<0)?HISTORY_SIZE-1:history_pos-1;
00233
00234
00235
00236 if(history_array[prev_pos]==topicId)
00237 return;
00238
00239 if(history_array[history_pos]!=0) {
00240 history_array[next_pos]=0;
00241 }
00242
00243 history_array[history_pos] = topicId;
00244 can_back=(history_array[(((prev_pos)<0)?HISTORY_SIZE-1:prev_pos)]>0);;
00245 history_pos = next_pos;
00246 }
00247
00248
00249
00250
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 int prev_pos=history_pos;
00273
00274 do {
00275 prev_pos--;
00276 prev_pos=(prev_pos<0)?HISTORY_SIZE-1:prev_pos;
00277 }
00278 while(history_array[prev_pos]==topic_id && history_array[prev_pos]!=0);
00279
00280 int topicId = history_array[prev_pos];
00281 if( topicId>0 ) {
00282 history_array[prev_pos] = 0;
00283 history_pos = prev_pos;
00284 disp( INFO_UPDATE, topicId );
00285 if( init_list_flag )
00286 topic_browse.refresh( topicId );
00287 can_back=(history_array[(((prev_pos-1)<0)?HISTORY_SIZE-1:prev_pos-1)]>0);
00288 }
00289 }
00290
00291
00292
00293
00298
00299 int rc;
00300
00301
00302
00303
00304 if( init_list_flag && (rc=topic_browse.detect()) > 0 ) {
00305 double_clicked=topic_browse.double_click;
00306 topic_id=rc;
00307 sys.redraw_all_flag=1;
00308
00309 return 1;
00310 }
00311
00312 if(!init_list_flag) {
00313 if( (rc=scroll_bar.detect()) > 0 ) {
00314
00315 top_line = rc;
00316 sys.redraw_all_flag=1;
00317 disp(INFO_UPDATE);
00318 return 1;
00319
00320 }
00321 if( detect_text() )
00322 return 1;
00323 }
00324 return 0;
00325
00326 }
00327
00328
00333
00334
00335
00336
00337 if( !mouse.single_click( text_x1, text_y1, text_x2, text_y2 ) )
00338 return 0;
00339
00340
00341
00342 int i, topicId;
00343 char saveChar;
00344 HyperField* hyperField = font_letter.hyper_field_array;
00345
00346 for( i=0 ; i<font_letter.hyper_field_count ; i++, hyperField++ ) {
00347 if( mouse.click_x() >= hyperField->x1 &&
00348 mouse.click_x() <= hyperField->x2 &&
00349 mouse.click_y() >= hyperField->y1 &&
00350 mouse.click_y() <= hyperField->y2 ) {
00351 err_when( hyperField->text_len > TxtIndex::TITLE_LEN );
00352
00353 saveChar = hyperField->text_ptr[hyperField->text_len];
00354 hyperField->text_ptr[hyperField->text_len] = NULL;
00355
00356 topicId = res_txt.locate_topic(hyperField->text_ptr);
00357
00358 hyperField->text_ptr[hyperField->text_len] = saveChar;
00359
00360 if( topicId ) {
00361 add_history(topic_id);
00362
00363 disp(INFO_UPDATE, topicId);
00364 sys.redraw_all_flag=1;
00365 if( init_list_flag )
00366 topic_browse.refresh( topicId );
00367
00368 return 1;
00369 }
00370 }
00371 }
00372
00373
00374
00375 if( mouse.click_y() < text_y1 + (text_y2-text_y1) / 2 )
00376 top_line = scroll_bar.page_up(1);
00377 else
00378 top_line = scroll_bar.page_down(1);
00379
00380 disp(INFO_UPDATE);
00381
00382 return 1;
00383 }
00384
00385
00386
00387
00388
00389 static void disp_topic_rec(int recNo, int x, int y, int refreshFlag) {
00390 if( refreshFlag == INFO_REPAINT )
00391 font_letter.put( x+10, y, cur_txt_list_ptr->res_txt.get_title(recNo) );
00392 }
00393
00394