


#include "ui/applic.h"
#include "ui/stddlg.h"

#include "appwin.h"
#include <fstream.h>

#define ID_BUTTON 101

AppWindow::AppWindow ()
: UI_CompositeVObject (NULL, (UI_ViewDescriptor*) NULL, FALSE,
                       UI_Rectangle (50, 50, 310, 250))
{
    _btn   = new UI_PushButton (this, UI_Rectangle (120, 210,  60, 30),
                                ID_BUTTON);
    _edit  = new UI_TextEditor (this, UI_Rectangle (  5,   5, 300, 200));
    
    _btn->Title () = "Save";
//    I could have said 
//     (CL_String&) _edit->Model() = "What you type here will be saved"
//         " in junk.dat";
//    But Watcom C++ doesn't like that. So I say
    ((CL_String&) _edit->Model()) = "What you type here will be saved"
        " in junk.dat";
}

bool AppWindow::HandleChildEvent (const UI_Event& e)
{
    if (e.Type() != Event_Select || e.Origin() != _btn)
        return FALSE;
    CL_String msg = "Selection: " + _edit->Selection().AsString();
    UI_StandardDialog (msg);
    ofstream f ("junk.dat");
    f << (_edit->Model());
    _Application->Destroy (this);
    return TRUE;
}


