comparison dwtest.c @ 219:79968cf0f3b3

Choose a nice font. ;)
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 04 Feb 2003 23:48:48 +0000
parents fe0ab0040ba2
children 3fd010a0a33f
comparison
equal deleted inserted replaced
218:fe0ab0040ba2 219:79968cf0f3b3
4 #include <stdlib.h> 4 #include <stdlib.h>
5 #include <string.h> 5 #include <string.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include "dw.h" 7 #include "dw.h"
8 8
9 /* Select a fixed width font for our platform */
10 #ifdef __OS2__
11 #define FIXEDFONT "5.System VIO"
12 #elif defined(__WIN32__)
13 #define FIXEDFONT "10.Terminal"
14 #elif GTK_MAJOR_VERSION > 1
15 #define FIXEDFONT "monospace 10"
16 #else
17 #define FIXEDFONT "fixed"
18 #endif
9 19
10 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | 20 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR |
11 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; 21 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER;
12 22
13 HWND mainwindow, 23 HWND mainwindow,
54 return TRUE; 64 return TRUE;
55 } 65 }
56 66
57 void read_file( void ) 67 void read_file( void )
58 { 68 {
59 char line[1024]; 69 int i,len;
60 char buf[10];
61 int i,y,len;
62 fp = fopen( current_file, "r" ); 70 fp = fopen( current_file, "r" );
63 lp = (char **)calloc( 1000,sizeof(char *)); 71 lp = (char **)calloc( 1000,sizeof(char *));
64 /* should test for out of memory */ 72 /* should test for out of memory */
65 max_linewidth=0; 73 max_linewidth=0;
66 for ( i = 0; i < 1000; i++ ) 74 for ( i = 0; i < 1000; i++ )
175 HPIXMAP old1 = text1pm, old2 = text2pm; 183 HPIXMAP old1 = text1pm, old2 = text2pm;
176 rows = height / font_height; 184 rows = height / font_height;
177 cols = width / font_width; 185 cols = width / font_width;
178 186
179 /* Create new pixmaps with the current sizes */ 187 /* Create new pixmaps with the current sizes */
180 text1pm = dw_pixmap_new( textbox2, font_width*width1, height, dw_color_depth()); 188 text1pm = dw_pixmap_new( textbox2, (font_width*width1)+2, height, dw_color_depth());
181 text2pm = dw_pixmap_new( textbox2, width, height, dw_color_depth()); 189 text2pm = dw_pixmap_new( textbox2, width, height, dw_color_depth());
182 190
183 /* Destroy the old pixmaps */ 191 /* Destroy the old pixmaps */
184 dw_pixmap_destroy(old1); 192 dw_pixmap_destroy(old1);
185 dw_pixmap_destroy(old2); 193 dw_pixmap_destroy(old2);
263 status = dw_status_text_new("", 0); 271 status = dw_status_text_new("", 0);
264 dw_box_pack_start( notebookbox2, status, 100, 20, TRUE, FALSE, 1); 272 dw_box_pack_start( notebookbox2, status, 100, 20, TRUE, FALSE, 1);
265 273
266 /* create render box for number pixmap */ 274 /* create render box for number pixmap */
267 textbox1 = dw_render_new( 100 ); 275 textbox1 = dw_render_new( 100 );
268 dw_window_set_font(textbox1, "9.WarpSans"); 276 dw_window_set_font(textbox1, FIXEDFONT);
269 dw_font_text_extents( NULL, text1pm, "O", &font_width, &font_height ); 277 dw_font_text_extents(textbox1, NULL, "O", &font_width, &font_height );
270 dw_box_pack_start(pagebox, textbox1, font_width*width1, font_height*rows, FALSE, TRUE, 0); 278 dw_box_pack_start(pagebox, textbox1, (font_width*width1)+2, font_height*rows, FALSE, TRUE, 0);
271 279
272 /* create box for filecontents and horz scrollbar */ 280 /* create box for filecontents and horz scrollbar */
273 textboxA = dw_box_new( BOXVERT,0 ); 281 textboxA = dw_box_new( BOXVERT,0 );
274 dw_box_pack_start( pagebox, textboxA, 0, 0, TRUE, TRUE, 0); 282 dw_box_pack_start( pagebox, textboxA, 0, 0, TRUE, TRUE, 0);
275 283
276 /* create render box for filecontents pixmap */ 284 /* create render box for filecontents pixmap */
277 textbox2 = dw_render_new( 101 ); 285 textbox2 = dw_render_new( 101 );
278 dw_box_pack_start( textboxA, textbox2, 10, 10, TRUE, TRUE, 0); 286 dw_box_pack_start( textboxA, textbox2, 10, 10, TRUE, TRUE, 0);
279 dw_window_set_font(textbox2, "9.WarpSans"); 287 dw_window_set_font(textbox2, FIXEDFONT);
280 /* create horizonal scrollbar */ 288 /* create horizonal scrollbar */
281 hscrollbar = dw_scrollbar_new(FALSE, 100, 50); 289 hscrollbar = dw_scrollbar_new(FALSE, 100, 50);
282 dw_box_pack_start( textboxA, hscrollbar, 100, 20, TRUE, FALSE, 0); 290 dw_box_pack_start( textboxA, hscrollbar, 100, 20, TRUE, FALSE, 0);
283 291
284 /* create vertical scrollbar */ 292 /* create vertical scrollbar */
285 vscrollbar = dw_scrollbar_new(TRUE, 100, 50); 293 vscrollbar = dw_scrollbar_new(TRUE, 100, 50);
286 dw_box_pack_start(pagebox, vscrollbar, 20, 100, FALSE, TRUE, 0); 294 dw_box_pack_start(pagebox, vscrollbar, 20, 100, FALSE, TRUE, 0);
287 295
288 text1pm = dw_pixmap_new( textbox1, font_width*width1, font_height*rows, depth ); 296 text1pm = dw_pixmap_new( textbox1, (font_width*width1)+2, font_height*rows, depth );
289 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, depth ); 297 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, depth );
290 298
291 dw_messagebox("DWTest", "Width: %d Height: %d\n", font_width, font_height); 299 dw_messagebox("DWTest", "Width: %d Height: %d\n", font_width, font_height);
292 dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows); 300 dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows);
293 dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows); 301 dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows);