2. EXPLANATION.
zAppFrame *appWindow = new zAppFrame(0, new zSizer,zSTDFRAME,
"A zApp App"
This line dynamically allocats mamory and creates the application's main
window object,calld the frame window, which belongs to th class zFrameWin.
But this is only the frame. We cannot input and output in this class.
zText Pane *hellowPane = new zTextPane(main Window, new zSizeWithParent);
This line dynamically allocates a zTextPane as a child of the zAppFrame window.
The zTextPane allows to input, to output, to show text using C function such as
printf( ).
Next explanation will be in the point called "TEXT" as comments.
4. TEXT.
constant.h
#define MENUEXEMPLE 100
#define ID_HELLO 101
#define ID_WHATSUP 102
#define ID_CONTINIUE 103
#define ID_GOODBYE 104
#include "zapp.hpp"
#include "constant.h"
/*
The definition MenuFrame class frpm zAppFrame class, which
inherits all of the attributes of a zAppFrame.
*/
class MyMenuFrame : public zAppFrame{
zMyTextPane* tp;
public:
/*
MyMenuFrame defines two member functions, a constructor
and a destructor.
- constructor initalizes and creates "MyMenuFrame" object.
- distructor destroys the zMyTextPane, which frees the
resources that " HellowFrame" had allocated
upon constructor.
*/
MyMenuFrame(zWindow* parent, zSizer* sizer,
DWORD winStyle, "GOLDENBERG");
~MyMenuFrame( );
/*
Commend( ) is a vartual function. All menu evnts go to this function,
and classes that own a zMenu typically overload this member to process
the zCommandEvts for the various items contained in the menu.
The doWhatsUp( ) function will be used to handle one of the three
items in the menu
*/
virtual int command(zCommandEvt *);
int doWhatsUp(zCommendEVT *)
}
/*
The MyMenuFrame constructor initializes and creates object.
*/
MyMenuFrame::MyMenuFrame(zWindow* parent,zSizer* sizer,
DWORD WinStyle, const char* title)
:zAppFrame(parnt, sizer, WinStyle, title) {
/*
This line of code creates the zMenu and attaches it to the
MyMenuFrame.
*/
menu(new zMenu(this, zResId(MENUEXAMPLE)));
menu ( ) -> setCommand(this,
(CommandProc)&MenuFrame::doWhatsUp,ID_WHATSUP);
tp = new MyzTextPane(this,new zSizeWithParent);
tp = show ( );
};
/*
The MyMenuFrame distructor destroys the MyzTextPane, which frees the
resources that MyHelloFrame had allocated upon constructor.
*/
MyMenuFrame::~MyMenuFrame ( ) {
delete tp;
};
/*
Creating user menu
*/
MyMenuFrame::command(zCommandEvt *ce) {
tp -> clearRect ( );
tp -> moveTo(6,0);
switch(ce -> cmd()) {
case ID_HELLO:
tp -> printf("Hello! \n");
break;
case ID_CONTINUE:
tp->printf("continue \n");
break;
case ID_GOODBYE:
tp->printf("Goodbye! \n");
break;
default:
return 0;
};
return 1;
};
MyMenuFrame::doWhatUp(zCommandEvt *ce) {
tp - > clearRect ( );
tp -> moveTo(6,0);
tp -> printf("what's up?\n");
return 1;
}
void zApp::main ( ) {
MyMenuFrame *mainWnd =
new MyMenuFrame(0, new zSizer, zSTDFRAME, "GOLDENBERG");
mainWnd -> show ( );
delete mainWnd;
}
#include "constant.h"
MENUEXEMPLE MENU {
POPUP "&Say" {
MENUITEM "&Hello!", ID_HELLO
MENUITEM "&What's up?", ID_WHATSUP
MENUITEM "&Continue",ID_CONTINUE
MENUITEM "Good bye.", ID_GOODBYE
}
}