Mercurial > dwindows
comparison dwtest.c @ 380:fcb52d773ed2
Implement tests for setting background color on render boxes.
Calculate full font height correctly.
author | mhessling@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 29 Apr 2003 10:54:09 +0000 |
parents | 12b3980a41a2 |
children | 761e5fddffca |
comparison
equal
deleted
inserted
replaced
379:2e5f3cb38d19 | 380:fcb52d773ed2 |
---|---|
225 } | 225 } |
226 | 226 |
227 void draw_file( int row, int col ) | 227 void draw_file( int row, int col ) |
228 { | 228 { |
229 char buf[10]; | 229 char buf[10]; |
230 int i,y; | 230 int i,y,fileline; |
231 char *pLine; | 231 char *pLine; |
232 | 232 |
233 if ( current_file ) | 233 if ( current_file ) |
234 { | 234 { |
235 dw_color_foreground_set(DW_CLR_WHITE); | 235 dw_color_foreground_set(DW_CLR_WHITE); |
236 dw_draw_rect(0, text1pm, TRUE, 0, 0, DW_PIXMAP_WIDTH(text1pm), DW_PIXMAP_HEIGHT(text1pm)); | 236 dw_draw_rect(0, text1pm, TRUE, 0, 0, DW_PIXMAP_WIDTH(text1pm), DW_PIXMAP_HEIGHT(text1pm)); |
237 dw_draw_rect(0, text2pm, TRUE, 0, 0, DW_PIXMAP_WIDTH(text2pm), DW_PIXMAP_HEIGHT(text2pm)); | 237 dw_draw_rect(0, text2pm, TRUE, 0, 0, DW_PIXMAP_WIDTH(text2pm), DW_PIXMAP_HEIGHT(text2pm)); |
238 | |
238 for ( i = 0;(i < rows) && (i+row < num_lines); i++) | 239 for ( i = 0;(i < rows) && (i+row < num_lines); i++) |
239 { | 240 { |
241 fileline = i + row - 1; | |
240 y = i*(font_height+font_gap); | 242 y = i*(font_height+font_gap); |
241 dw_color_foreground_set( i ); | 243 dw_color_background_set( 1 + (fileline % 15) ); |
244 dw_color_foreground_set( fileline % 16 ); | |
242 sprintf( buf, "%6.6d", i+row ); | 245 sprintf( buf, "%6.6d", i+row ); |
243 dw_draw_text( 0, text1pm, 0, y, buf); | 246 dw_draw_text( 0, text1pm, 0, y, buf); |
244 pLine = lp[i+row]; | 247 pLine = lp[i+row]; |
245 dw_draw_text( 0, text2pm, 0, y, pLine+col ); | 248 dw_draw_text( 0, text2pm, 0, y, pLine+col ); |
246 } | 249 } |
329 | 332 |
330 rows = height / (font_height+font_gap); | 333 rows = height / (font_height+font_gap); |
331 cols = width / font_width; | 334 cols = width / font_width; |
332 | 335 |
333 /* Create new pixmaps with the current sizes */ | 336 /* Create new pixmaps with the current sizes */ |
334 text1pm = dw_pixmap_new(textbox1, (font_width*(width1+1)), height+1, depth); | 337 text1pm = dw_pixmap_new(textbox1, (font_width*(width1)), height, depth); |
335 text2pm = dw_pixmap_new(textbox2, width, height, depth); | 338 text2pm = dw_pixmap_new(textbox2, width, height, depth); |
336 | 339 |
337 /* Destroy the old pixmaps */ | 340 /* Destroy the old pixmaps */ |
338 dw_pixmap_destroy(old1); | 341 dw_pixmap_destroy(old1); |
339 dw_pixmap_destroy(old2); | 342 dw_pixmap_destroy(old2); |
489 dw_box_pack_start( notebookbox2, status1, 100, 20, TRUE, FALSE, 1); | 492 dw_box_pack_start( notebookbox2, status1, 100, 20, TRUE, FALSE, 1); |
490 | 493 |
491 /* create render box for number pixmap */ | 494 /* create render box for number pixmap */ |
492 textbox1 = dw_render_new( 100 ); | 495 textbox1 = dw_render_new( 100 ); |
493 dw_window_set_font(textbox1, FIXEDFONT); | 496 dw_window_set_font(textbox1, FIXEDFONT); |
494 dw_font_text_extents(textbox1, NULL, "O", &font_width, &font_height); | 497 dw_font_text_extents(textbox1, NULL, "Og", &font_width, &font_height); |
498 font_width = font_width / 2; | |
495 vscrollbox = dw_box_new(BOXVERT, 0); | 499 vscrollbox = dw_box_new(BOXVERT, 0); |
496 dw_box_pack_start(vscrollbox, textbox1, font_width*width1, font_height*rows, FALSE, TRUE, 0); | 500 dw_box_pack_start(vscrollbox, textbox1, font_width*width1, font_height*rows, FALSE, TRUE, 0); |
497 dw_box_pack_start(vscrollbox, 0, (font_width*(width1+1)), SCROLLBARWIDTH, FALSE, FALSE, 0); | 501 dw_box_pack_start(vscrollbox, 0, (font_width*(width1+1)), SCROLLBARWIDTH, FALSE, FALSE, 0); |
498 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); | 502 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); |
499 | 503 |
500 /* create render box for gap pixmap */ | 504 /* pack empty space 1 character wide */ |
505 dw_box_pack_start(pagebox, 0, font_width, 0, FALSE, TRUE, 0); | |
506 | |
501 /* create box for filecontents and horz scrollbar */ | 507 /* create box for filecontents and horz scrollbar */ |
502 textboxA = dw_box_new( BOXVERT,0 ); | 508 textboxA = dw_box_new( BOXVERT,0 ); |
503 dw_box_pack_start( pagebox, textboxA, 0, 0, TRUE, TRUE, 0); | 509 dw_box_pack_start( pagebox, textboxA, 0, 0, TRUE, TRUE, 0); |
504 | 510 |
505 /* create render box for filecontents pixmap */ | 511 /* create render box for filecontents pixmap */ |