/* $Id:$
Dialog for machining
*/
#include <stdio.h>
#include <string.h>
#define Uses_TStringCollection
#include <tvision/tv.h>
#include "giselhlp.h"
#include "machdlg.h"
#include "machinin.h"
extern Machining Machining;
TMachining::TMachining() :
TDialog(TRect(14, 4, 51, 20), "Machining I/O"),
TWindowInit(TMachining::initFrame)
{
TView *control;
this->helpCtx = hcMachining;
control = new TScrollBar(TRect(33, 2, 34, 12));
insert(control);
listBox = new TListBox(TRect(3, 2, 33, 12), 1, (TScrollBar*)control);
TCollection *items = new TStringCollection(10,2);
for (int i = 0; i < 30000; i++)
{
char *cmd;
if ((cmd = Machining.GetCommand('M', i)) != NULL)
{
char buffer[MAX_COMMAND_STRING_LEN];
sprintf(buffer, "M%02d=%s", i, cmd);
items->insert(strdup(buffer));
}
if ((cmd = Machining.GetCommand('S', i)) != NULL)
{
char buffer[MAX_COMMAND_STRING_LEN];
sprintf(buffer, "S%02d=%s", i, cmd);
items->insert(strdup(buffer));
}
if ((cmd = Machining.GetCommand('T', i)) != NULL)
{
char buffer[MAX_COMMAND_STRING_LEN];
sprintf(buffer, "T%d=%s", i, cmd);
items->insert(strdup(buffer));
}
}
listBox->newList(items);
insert(listBox);
insert(new TLabel(TRect(3, 1, 18, 2), "~C~MD Definition", control));
control = new TButton(TRect(6, 13, 16, 15), "O~K~", cmOK, bfDefault);
insert(control);
control = new TButton(TRect(19, 13, 29, 15), "~E~dit", cmCancel, bfNormal);
insert(control);
selectNext(False);
}
void TMachining::handleEvent( TEvent& event)
{
TDialog::handleEvent(event);
switch (event.what)
{
case evKeyboard:
switch (event.keyDown.keyCode)
{
// case kbDown:
// moveInDirection(cmXplus);
// break;
}
break;
case evCommand:
switch( event.message.command )
{
case cmOK:
case cmCancel:
close();
break;
}
default:
return;
}
clearEvent(event);
}
Boolean TMachining::valid(ushort command)
{
Boolean rslt = TDialog::valid(command);
if (rslt && (command == cmOK))
{
}
return rslt;
}
const char * const TMachining::name = "TMachining";
void TMachining::write( opstream& os )
{
TDialog::write( os );
}
void *TMachining::read( ipstream& is )
{
TDialog::read( is );
return this;
}
TStreamable *TMachining::build()
{
return new TMachining( streamableInit );
}
// From here to end of file may be removed if TMachining will not be streamed.
TStreamableClass RMachining( TMachining::name,
TMachining::build,
__DELTA(TMachining)
);
__link(RListBox)
__link(RButton)
__link(RLabel)
__link(RMachining)
__link(RScrollBar)
syntax highlighted by Code2HTML, v. 0.9.1