[openbeos] Re: Data or App Centric?

> On Sun, 20 Feb 2005 18:43:00 +0100 CET, Jonas Sundström
> <jonas@xxxxxxxxxxx> wrote:
> > I think it would be much better if the system could provide
> > the necessary uniformity, to keep everyone from rolling their own.
> > I would much rather have a good system-provided scanner dialog,
> > (with possible extensions, should they be necessary).

Actually I got that idea recently, and, humm... Sorry, can't tell more yet :p

> question:
> is there a way to have a program create a replicant of another at
> run-time?   eg,  WonderBrush creating and integrating a replicant of
> Colors!  without the aide of user-input?

Yes, BeHappy does that with NetPositive.
You just need to create a BMessage with the correct field and pass it to a 
BShelf.

==== ShelfTest.cpp

#include <stdio.h>
#include <Application.h>
#include <Message.h>
#include <Shelf.h>
#include <View.h>
#include <Window.h>

int main(int argc, char **argv)
{
        BRect windowBounds(0, 0, 300, 300);
        new BApplication("application/x-vnd.mmu_man.ShelfTest");

        if (!be_app)
                return 1;
        BWindow *win;
        win = new BWindow(windowBounds.OffsetByCopy(50, 50), "ShelfTest", 
B_DOCUMENT_WINDOW, B_WILL_ACCEPT_FIRST_CLICK | B_QUIT_ON_WINDOW_CLOSE);
        BView *view;
        view = new BView(windowBounds, "ShelfTestView", B_FOLLOW_ALL, 
B_WILL_DRAW | B_FRAME_EVENTS);
        view->SetViewColor(0, 0, 255);
        win->AddChild(view);
        BShelf *shelf;
        shelf = new BShelf(view, false, "theShelf");
        BMessage *replicant;
        replicant = new BMessage(B_ARCHIVED_OBJECT);
        replicant->AddString("add_on", "application/x-vnd.Be-NPOS");
        replicant->AddInt32("version", 2);
        replicant->AddString("url", "netpositive:Startup.html");
        replicant->AddBool("openAsText", false);
        replicant->AddInt32("encoding", 258);
        replicant->AddString("class", "NPBaseView");
        replicant->AddString("_name", "NetPositive");
        replicant->AddRect("_frame", windowBounds);
        replicant->AddInt32("_resize_mode", 0x00001234 /*B_FOLLOW_ALL*/);
        replicant->AddInt32("_flags", 0x24000000);

        replicant->PrintToStream();
        shelf->AddReplicant(replicant, BPoint(0, 0));
        BView *repview = view->ChildAt(0);
        if (repview) {
                printf("rep flags=0x%08lx resizemode=0x%08lx\n", 
repview->Flags(), repview->ResizingMode());
                repview->SetResizingMode(B_FOLLOW_ALL);
                repview->MoveBy(0, -28);
                repview->ResizeBy(0, 42);
        }
        win->Show();
        be_app->Run();
}



Other related posts: