Post subject: OSBA OS Update Posted: Wed Nov 08, 2006 6:00 am
Ex OSBA Member
Joined Sat Aug 19, 2006 1:25 am
Posts 591
Location Israel
Over the last few weeks I've been working on oDisplay (OSBA OS' native windowing environment).
To show (off) what oDisplay can already do, here's a sample application that draws the image given as a parameter and displays a "Hello, World!" message:
Code:
#include "oDisplay.h"
int main(int *argc,char *argv[]) { unsigned long *image; unsigned int width,height; odWindow *wnd,*wnd2;
// check that a file was specified if ( argc < (int *)2 ) fatalError(-1,"main","no file specified."); // initiate oDisplay odInit();
// load the specified image image = odLoadImage(argv[1],&width,&height); // if we can't load it, exit with an error message if ( ! image ) fatalError(-1,"main","can't load image.");
// create a window at location 100,100 with the image's width and height, // set its parent window to the root window, make it shown by default // (first 1) and managed by default (second 1), and make it without an // event handler (the NULL) wnd = odCreateWindow(100,100,width,height,odGetRootWindow(),1,1,NULL); // set its transparency to 64 (25%) odSetWindowAlpha(wnd,0,0,width,height,64); // color the root window with a light blue color odFill(odGetRootWindow(),0,0,screenWidth,screenHeight,0xFFCCCCFF); // draw the image odDrawBlock(wnd,0,0,width,height,image);
// get the text size odGetTextSize("Hello, World!","arial",12,&width,&height); // create the second window wnd2 = odCreateWindow(350,500,width+40,height+10,odGetRootWindow(),1,1,NULL); // color it white odFill(wnd2,0,0,width+40,height+10,0xFFFFFFFF); // draw the text on the second window, at location 20,5, using font arial size 12, color black and 0xFF opacity odDrawTextToWindow(wnd2,20,5,"Hello, World!","arial",12,0xFF000000);
// wait ten seconds sleep(10); // destroy both windows odDestroyWindow(wnd); odDestroyWindow(wnd2); // terminate oDisplay and exit with a success code odTerminate(); return 0; }
this is what this program looks like when run with the Google logo as a parameter:
As you can see, oDisplay already has windowing, text, transparency and image-loading support, and I'm currently working on loadable widget support.
Notice the coding simplicity compared to other low level windowing environments (X11, Win32, ...).
Users browsing this forum: No registered users and 2 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum
All views expressed in these forums are those of the author and do not necessarily represent the views of the BetaArchive site owner.