home *** CD-ROM | disk | FTP | other *** search
- // kid13.cpp BROWSE DIALOG BOX
- // written by Gregory K. Miskin
- // COPYRIGHT (C) 1992. All Rights Reserved.
- // Gregory K. Miskin, Orem, Utah USA
-
- #define Uses_TEvent
- #define Uses_TScrollBar
- #define Uses_TListBox
- #define Uses_TDialog
- #define Uses_TKeys
- #define Uses_TProgram
- #define Uses_TDeskTop
- #define Uses_TButton
-
- #include <tv.h>
- #include <string.h>
- #include <stdlib.h>
- #include "commands.hpp"
- #include "structs.hpp"
- #include "demo2.hpp"
- #include "demo1.hpp"
-
- short screenSize = 18;
-
- /*------------------------------------------------------------------------*/
- TBrowseNames::TBrowseNames() :
- TDialog(TRect(0, 0, 80, 23), "Browse Names"),
- TWindowInit(&TBrowseNames::initFrame)
- {
- TRect r = getClipRect();
- r.grow(-1,-1);
- r.b.y = r.b.y -1;
- r.b.x = r.b.x -1;
-
- vbar = new TScrollBar(TRect (78,1,79,21));
- hbar = new TScrollBar(TRect (1,21,78,22));
-
- vbar->setStep(screenSize, 1);
- hbar->maxVal = 28;
- hbar->setStep(28, 1);
- hbar->setValue(0);
-
- listBox = new VListBox(r, 1, hbar, vbar);
- insert(listBox);
- insert(vbar);
- insert(hbar);
-
- options |= ofCentered;
- }
-
- /*------------------------------------------------------------------------*/
- void TBrowseNames::handleEvent(TEvent &event)
- {
- TDialog::handleEvent(event);
-
- switch(event.what)
- {
- case evCommand:
- switch(event.message.command)
- {
- default:
- break;
- }
- break;
-
- case evKeyDown:
- switch(event.keyDown.keyCode)
- {
- case kbRight:
- if(hbar->value <= hbar->maxVal)
- {
- int val = hbar->value + 1;
- hbar->setValue(val);
- }
- break;
-
- case kbLeft:
- if(hbar->value > 0)
- {
- int val = hbar->value - 1;
- hbar->setValue(val);
- }
- break;
-
- case kbCtrlRight:
- if(hbar->value <= hbar->maxVal)
- {
- int val = hbar->maxVal;
- hbar->setValue(val);
- }
- break;
-
- case kbCtrlLeft:
- if(hbar->value > 0)
- {
- int val = 0;
- hbar->setValue(val);
- }
- break;
-
- case kbAltF3:
- event.what = evCommand;
- event.message.command = cmCancel;
- event.message.infoPtr = 0;
- putEvent(event);
- break;
-
- default:
- break;
- }
- break;
-
- case evBroadcast:
- if(event.message.command == cmDefault)
- EditRecord();
- break;
-
- default:
- return;
- }
- }
-
- /*------------------------------------------------------------------------*/
- void TBrowseNames::EditRecord()
- {
- long currRecord;
- int recPos = 0;
-
- long item = listBox->focused;
- currRecord = listBox->GetRecord(item);
- status = listBox->cBase->close_all();
-
- edit_record = new TEditRecord(currRecord);
- TProgram::deskTop->execView(edit_record);
- destroy(edit_record);
-
- listBox->OpenFiles();
- listBox->name->top();
- listBox->name->skip(item);
- listBox->draw();
- }
-