PObject *o = NULL;
o = NewObject("PWindow");
StringValue sv("FooWindowTest");
o->SetProperty("Title", &sv);
RectValue rv(BRect(100,100,500,400));
o->SetProperty("Frame",&rv);
BFile file("/boot/home/Desktop/test.plg",B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
BMessage msg;
o->Archive(&msg);
msg.Flatten(&file);
In these reasonably few lines of test code, I not only manage to create a window in the upper left corner of the screen in a thread-safe fashion, but I can even save it to disk and recreate it in the exact same state as I left it, and the code is refreshingly short:
BFile file("/boot/home/Desktop/test.plg",B_READ_ONLY);
BMessage msg;
msg.Unflatten(&file);
PObject *o = (PObject*)UnflattenObject(&msg);
The backend code is only 5 or 6 files of reasonable length, but even so, I'd be hard-pressed to do the same kind of trick using regular BWindow and BMessage code in anywhere near the same amount of code. Then again, maybe I'm just overly excited. *shrug*
What's the significance of this technical rambling? The designer, assuming no other major roadblocks from here, will be very flexible, relatively easy to code, and pretty simple to extend with classes not bundled with the operating system. Code generation may not be all that difficult, either, but only time will tell on that one.
No comments:
Post a Comment