
"Reece Dunn" <msclrhd@hotmail.com> wrote
I am currently designing a GUI framework in C++ (initially targeting the Windows platform) that uses a model similar to that which Java uses in it's AWT and Swing libraries. Specifically:
I would appreciate comments and ideas as to what people would like out of
a
GUI framework, especially one that will be multi-platform.
I am currently looking into GUI but from the point of view of drawing whats in a window. One major issue with Windows SDK is spending a lot of time figuring out whether device or logical units are required. It seems a natural application for my physical quantities library. So instead of saying: DeviceContext dc; int x,y; dc.move(x,y); One could say: DeviceContext dc; length::mm x,y; dc.move(x,y); Although I am more keen on an object approach as below, more like windows metafile. Another issue is the local coordinate system, so I am trying to look at how to make that more user friendly too: // A container for the drawing Drawing drawing<Rectangle>; // set drawing to "graphics" direction drawing.set_direction(x_increasing_right(), y_increasing_up()); drawing.set_scale(1,1); drawing.set_origin(point(length::mm(0),length::mm(0))); printer printer = GetPrinter(); // synchronise printers way of looking at things with drawing printer.set_direction(drawing.direction); printer.set_scale(drawing.scale); printer.set_origin(drawing.origin); //ok should get sane values //get paper size for printing Rectangle<length::mm> paper_size = printer.get_paper_size(); drawing.rectangle = paper_size; GraphicLayer border_layer; // a layer representing border for drawing // sync border_layer direction with drawing border.set_direction(drawing.direction); border.set_scale(drawing.scale); border.set_origin(drawing.origin); length::mm left_border(10); length::mm right_border = left_border; typedef length height; // easy reading height::mm top_border(10); height::mm bottom_border(15); //points representing the border point<length::mm> first(left_border, bottom_border); point<length::mm> second(paper_size.width - right_border, bottom_border); point<length::mm> third(paper_size.width - right_border, paper_size.height - top_border); point<length::mm> fourth(left_border, paper_size.height - top_border); typedef length width; Pen pen(width::mm(0.2),color(BLACK),style(continuous)); border_layer << line(first,second,pen) << line(second,third,pen) << line(third,fourth,pen) << line(fourth,first,pen); // add the layer to the drawing drawing << border_layer; TextLayer text_layer; // sync text layer with drawing solely for purposes // of getting correct origin offset in drawing text_layer.set_direction(drawing.direction); text_layer.set_scale(drawing.scale); Font font ("Times New Roman",height::mm(7),width::mm(0)); text_layer.set_origin(left_border,-(paper_size.height - top_border- font.height))); // now set direction to text mode text_layer.set_direction(x_increasing_right(), y_increasing_down()); //... play text into text layer point(left_border,font.height) start_text; Text text(start_text,font,"Hello World",color(BLACK),increasing_right(),increasing_up(),of_angle::deg(0) ); drawing << text; text.x += text.length ; /*...*/ drawing >> printer; Or something like that, then of course theres time and velocity for moving things about in real time :-) regards Andy Little