Changeset 8333
- Timestamp:
- 19/01/12 17:26:19 (4 months ago)
- Location:
- branches/e4fix/EDIT4
- Files:
-
- 5 modified
-
ED4_base.cxx (modified) (3 diffs)
-
ED4_cursor.cxx (modified) (4 diffs)
-
ED4_edit_string.cxx (modified) (4 diffs)
-
ed4_class.hxx (modified) (4 diffs)
-
ed4_defs.hxx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/e4fix/EDIT4/ED4_base.cxx
r8331 r8333 212 212 // ----------------- 213 213 214 bool ED4_base::is_visible(ED4_window *in_ed4w, AW_pos x, AW_pos y, ED4_direction direction) { 215 // return true if position (world coordinates) is visible in_ed4w 216 // (tests only into direction) 217 bool visible = true; 218 ED4_coords& coords = in_ed4w->coords; 219 220 switch (direction) 221 { 222 case ED4_D_HORIZONTAL: 223 if ((long(x)<coords.window_left_clip_point) || 224 (long(x)>coords.window_right_clip_point)) { 225 visible = false; 226 } 227 break; 228 case ED4_D_VERTICAL: 229 if ((long(y)<coords.window_upper_clip_point) || 230 (long(y)>coords.window_lower_clip_point)) { 231 visible = false; 232 } 233 break; 234 case ED4_D_VERTICAL_ALL: // special case for scrolling (whole object visible) 235 if ((long(y) < coords.window_upper_clip_point) || 236 (long(y) + extension.size[HEIGHT] > coords.window_lower_clip_point)) { 237 visible = false; 238 } 239 break; 240 case ED4_D_ALL_DIRECTION: 241 if ((long(x) < coords.window_left_clip_point) || 242 (long(x) > coords.window_right_clip_point) || 243 (long(y) < coords.window_upper_clip_point) || 244 (long(y) > coords.window_lower_clip_point)) { 245 visible = false; 246 } 247 break; 248 default: 249 visible = false; 250 e4_assert(0); 251 break; 252 } 253 254 return visible; 255 } 256 257 inline bool ranges_overlap(AW_pos p1, AW_pos p2, int r1, int r2) { 214 inline bool ranges_overlap(int p1, int p2, int r1, int r2) { 258 215 // return true if ranges p1..p2 and r1..r2 overlap 259 216 e4_assert(p1 <= p2); … … 263 220 } 264 221 265 bool ED4_base::is_visible(ED4_window *in_ed4w, AW_pos x1, AW_pos y1, AW_pos x2, AW_pos y2, ED4_direction IF_ASSERTION_USED(direction)) { 222 inline bool range_contained_in(int p1, int p2, int r1, int r2) { 223 // return true if range p1..p2 is contained in range r1..r2 224 e4_assert(p1 <= p2); 225 e4_assert(r1 <= r2); 226 227 return p1 >= r1 && p2 <= r2; 228 } 229 230 bool ED4_window::partly_shows(int x1, int y1, int x2, int y2) const { 266 231 // return true if rectangle x1/y1/x2/y2 overlaps with clipped screen 267 e4_assert(direction == ED4_D_ALL_DIRECTION);268 232 e4_assert(x1 <= x2); 269 233 e4_assert(y1 <= y2); 270 234 271 ED4_coords& coords = in_ed4w->coords;272 273 235 bool visible = (ranges_overlap(x1, x2, coords.window_left_clip_point, coords.window_right_clip_point) && 274 236 ranges_overlap(y1, y2, coords.window_upper_clip_point, coords.window_lower_clip_point)); … … 277 239 } 278 240 241 bool ED4_window::completely_shows(int x1, int y1, int x2, int y2) const { 242 // return true if rectangle x1/y1/x2/y2 is contained in clipped screen 243 e4_assert(x1 <= x2); 244 e4_assert(y1 <= y2); 245 246 bool visible = (range_contained_in(x1, x2, coords.window_left_clip_point, coords.window_right_clip_point) && 247 range_contained_in(y1, y2, coords.window_upper_clip_point, coords.window_lower_clip_point)); 248 249 return visible; 250 } 279 251 280 252 char *ED4_base::resolve_pointer_to_string_copy(int *) const { return NULL; } -
branches/e4fix/EDIT4/ED4_cursor.cxx
r8332 r8333 955 955 } 956 956 957 // @@@ move parts of the following section into function is_hidden_by_parent() 957 958 ED4_base *temp_parent = owner_of_cursor; 958 959 while (temp_parent->parent) { … … 1282 1283 1283 1284 switch (owner_of_cursor->get_area_level(0)) { 1284 case ED4_A_TOP_AREA: { 1285 visible = 1286 owner_of_cursor->is_visible(win, x1, 0, ED4_D_HORIZONTAL) || 1287 owner_of_cursor->is_visible(win, x2, 0, ED4_D_HORIZONTAL); 1288 break; 1289 } 1290 case ED4_A_MIDDLE_AREA: 1291 visible = owner_of_cursor->is_visible(window(), x1, y1, x2, y2, ED4_D_ALL_DIRECTION); 1292 break; 1293 default: 1294 break; 1285 case ED4_A_TOP_AREA: visible = win->shows_xpos(x1) || win->shows_xpos(x2); break; 1286 case ED4_A_MIDDLE_AREA: visible = win->partly_shows(x1, y1, x2, y2); break; 1287 default: break; 1295 1288 } 1296 1289 1297 1290 return visible; 1298 1291 } 1292 1293 bool ED4_cursor::is_completely_visible() const { 1294 e4_assert(owner_of_cursor); 1295 e4_assert(cursor_shape); // cursor is not drawn, cannot test visibility 1296 1297 AW_pos x, y; 1298 owner_of_cursor->calc_world_coords(&x, &y); 1299 1300 int x1, y1, x2, y2; 1301 cursor_shape->get_bounding_box(cursor_abs_x, int(y), x1, y1, x2, y2); 1302 1303 bool visible = false; 1304 1305 switch (owner_of_cursor->get_area_level(0)) { 1306 case ED4_A_TOP_AREA: visible = win->shows_xpos(x1) && win->shows_xpos(x2); break; 1307 case ED4_A_MIDDLE_AREA: visible = win->completely_shows(x1, y1, x2, y2); break; 1308 default: break; 1309 } 1310 1311 return visible; 1312 } 1313 1314 #if defined(DEBUG) && 0 1315 #define DUMP_SCROLL_INTO_VIEW 1316 #endif 1299 1317 1300 1318 void ED4_terminal::scroll_into_view(ED4_window *ed4w) { // scroll y-position only … … 1312 1330 int slider_pos_y; 1313 1331 1314 AW_pos termw_y_upper = termw_y - term_height; // upper border of terminal 1332 AW_pos termw_y_upper = termw_y; // upper border of terminal 1333 AW_pos termw_y_lower = termw_y + term_height; // lower border of terminal 1315 1334 1316 1335 if (termw_y_upper > coords->top_area_height) { // don't scroll if terminal is in top area (always visible) 1317 1336 if (termw_y_upper < coords->window_upper_clip_point) { 1318 #if defined(DEBUG) && 01319 printf("termw_y (%i)-term_height(%i) < window_upper_clip_point(%i)\n",1320 int(termw_y ), term_height, int(coords->window_upper_clip_point));1337 #ifdef DUMP_SCROLL_INTO_VIEW 1338 printf("termw_y_upper(%i) < window_upper_clip_point(%i)\n", 1339 int(termw_y_upper), int(coords->window_upper_clip_point)); 1321 1340 #endif // DEBUG 1322 slider_pos_y = int(termw_y - coords->top_area_height - term_height);1341 slider_pos_y = int(termw_y_upper - coords->top_area_height - term_height); 1323 1342 scroll = true; 1324 1343 } 1325 else if (termw_y > coords->window_lower_clip_point) {1326 #if defined(DEBUG) && 01327 printf("termw_y (%i) > window_lower_clip_point(%i)\n",1328 int(termw_y ), int(coords->window_lower_clip_point));1344 else if (termw_y_lower > coords->window_lower_clip_point) { 1345 #ifdef DUMP_SCROLL_INTO_VIEW 1346 printf("termw_y_lower(%i) > window_lower_clip_point(%i)\n", 1347 int(termw_y_lower), int(coords->window_lower_clip_point)); 1329 1348 #endif // DEBUG 1330 slider_pos_y = int(termw_y - coords->top_area_height - win_ysize);1349 slider_pos_y = int(termw_y_upper - coords->top_area_height - win_ysize); 1331 1350 scroll = true; 1332 1351 } 1333 1352 } 1334 1353 1335 #if defined(DEBUG) && 01354 #ifdef DUMP_SCROLL_INTO_VIEW 1336 1355 if (!scroll) { 1337 printf("No scroll needed (termw_y =%i termw_y_upper=%i term_height=%i window_upper_clip_point=%i window_lower_clip_point=%i)\n",1338 int(termw_y ), int(termw_y_upper), term_height,1356 printf("No scroll needed (termw_y_upper=%i termw_y_lower=%i term_height=%i window_upper_clip_point=%i window_lower_clip_point=%i)\n", 1357 int(termw_y_upper), int(termw_y_lower), term_height, 1339 1358 int(coords->window_upper_clip_point), int(coords->window_lower_clip_point)); 1340 1359 } … … 1371 1390 show_cursor_at(terminal, scr_pos); 1372 1391 1373 if (!is_ partly_visible()) {1392 if (!is_completely_visible()) { 1374 1393 jump_sequence_pos(seq_pos, jump_type); 1375 1394 } -
branches/e4fix/EDIT4/ED4_edit_string.cxx
r8277 r8333 294 294 if (direction < 0) position--; 295 295 for (pos = position; pos>=0 && pos < seq_len; pos += direction) { 296 if (!ADPP_IS_ALIGN_CHARACTER(seq[pos]) && remap->is_ visible(pos)) {296 if (!ADPP_IS_ALIGN_CHARACTER(seq[pos]) && remap->is_shown(pos)) { 297 297 break; 298 298 } … … 305 305 if (direction < 0) position--; 306 306 for (pos = position; pos >= 0 && pos < seq_len; pos += direction) { 307 if (ADPP_IS_ALIGN_CHARACTER(seq[pos]) && remap->is_ visible(pos)) {307 if (ADPP_IS_ALIGN_CHARACTER(seq[pos]) && remap->is_shown(pos)) { 308 308 break; 309 309 } … … 317 317 if (direction < 0) position--; 318 318 for (pos = position; pos >= 0 && pos < seq_len; pos += direction) { 319 if (remap->is_ visible(pos)) {319 if (remap->is_shown(pos)) { 320 320 break; 321 321 } … … 414 414 seq_pos += direction; 415 415 } 416 while (legal_curpos(seq_pos) && !remap->is_ visible(seq_pos));416 while (legal_curpos(seq_pos) && !remap->is_shown(seq_pos)); 417 417 } 418 418 break; -
branches/e4fix/EDIT4/ed4_class.hxx
r8331 r8333 647 647 648 648 bool is_partly_visible() const; 649 bool is_completely_visible() const; 649 650 650 651 void changeType(ED4_CursorType typ); … … 731 732 ED4_returncode set_scrolled_rectangle(ED4_base *x_link, ED4_base *y_link, ED4_base *width_link, ED4_base *height_link); 732 733 734 bool shows_xpos(int x) const { return x >= coords.window_left_clip_point && x <= coords.window_right_clip_point; } 735 bool partly_shows(int x1, int y1, int x2, int y2) const; 736 bool completely_shows(int x1, int y1, int x2, int y2) const; 737 733 738 void update_window_coords(); 734 739 … … 1062 1067 1063 1068 ED4_returncode clear_background(int color=0); 1064 1065 bool is_visible(ED4_window *in_ed4w, AW_pos x, AW_pos y, ED4_direction direction);1066 bool is_visible(ED4_window *in_ed4w, AW_pos x1, AW_pos y1, AW_pos x2, AW_pos y2, ED4_direction direction);1067 1069 1068 1070 // functions concerned with links in the hierarchy … … 1753 1755 int was_changed() const { return changed; } // mapping changed by last compile ? 1754 1756 1755 int is_ visible(int position) const { return sequence_to_screen(position)>=0; }1757 int is_shown(int position) const { return sequence_to_screen(position)>=0; } 1756 1758 1757 1759 ExplicitRange clip_screen_range(PosRange screen_range) const { return ExplicitRange(screen_range, screen_len-1); } -
branches/e4fix/EDIT4/ed4_defs.hxx
r8192 r8333 236 236 ED4_D_HORIZONTAL, 237 237 ED4_D_ALL_DIRECTION, 238 ED4_D_VERTICAL_ALL239 238 }; 240 239
