home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
IOC
/
SETCV
/
ASETCV.CPP
next >
Wrap
Text File
|
1995-05-01
|
8KB
|
139 lines
/******************************************************************************/
/* Canvas Classes Example 2 - Set Canvas */
/* */
/* COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1993. */
/* */
/* DISCLAIMER OF WARRANTIES: */
/* The following [enclosed] code is sample code created by IBM */
/* Corporation. This sample code is not part of any standard IBM product */
/* and is provided to you solely for the purpose of assisting you in the */
/* development of your applications. The code is provided "AS IS", */
/* without warranty of any kind. IBM shall not be liable for any damages */
/* arising out of your use of the sample code, even if they have been */
/* advised of the possibility of such damages. */
/******************************************************************************/
/* NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE */
/******************************************************************************/
/* Canvas Classes Example 2 - Set Canvas */
/* key functions: */
/* - create a main window */
/* - run the current application */
/* - create a horizontal split canvas */
/* - create static text controls */
/* - create vertical and horizontal set canvases with multiple decks */
/* - create radio buttons */
/* - control cursor and tab movement between different groups */
/* - process 'Select' events on the radio buttons */
/* - load strings from resource bound to the exe */
/******************************************************************************/
//Include IBM UI class headers:
#ifndef _IBASE_ //Make sure ibase.hpp is included
#include <ibase.hpp> // since that is where IC_<environ>
#endif // is defined.
#include <iapp.hpp> // IApplication class
#include <ipoint.hpp> // ISize class
#include <istring.hpp> // IString class
#include "asetcv.h"
#include "asetcv.hpp"
/******************************************************************************/
/* main - Application entry point */
/******************************************************************************/
int main() //Main Procedure with no parameters
{
ASetCanvas mainWindow(WND_MAIN); //Create our main window on the decktop
IApplication::current().run(); //Get current & run the application
return 0;
} /* end main */
/******************************************************************************/
/* ASetCanvas :: ASetCanvas - Constructor for our main window */
/******************************************************************************/
ASetCanvas::ASetCanvas(unsigned long windowId)
: IFrameWindow( windowId )
, clientCanvas( WND_SPLITCANVAS, this, this, IRectangle(),
ISplitCanvas::horizontal | IWindow::visible )
, status( WND_STATUS, &clientCanvas, &clientCanvas )
, vSetCanvas( WND_VSETCANVAS, &clientCanvas, &clientCanvas )
, hSetCanvas( WND_HSETCANVAS, &clientCanvas, &clientCanvas )
{
setIcon( id() ); // Set the icon
// make split canvas the client area
setClient( &clientCanvas );
// set alignment of status area text
status.setAlignment( IStaticText::centerCenter );
// top canvas has 3 vertical decks
vSetCanvas.setDeckOrientation( ISetCanvas::vertical );
vSetCanvas.setDeckCount( 3 );
// bottom canvas has 3 horizontal decks
hSetCanvas.setDeckOrientation( ISetCanvas::horizontal );
hSetCanvas.setDeckCount( 3 );
hSetCanvas.setPad(ISize(10,10)); // set some space around buttons
buttonHandler.useStatus( &status ); // give button handler a text control
unsigned int i, mid = (NUMBER_OF_BUTTONS/2);
// create the first set of radio buttons
for (i = 0 ; i < mid ; ++i)
{
radiobut[i] = new IRadioButton( WND_BUTTON + i, &vSetCanvas, &vSetCanvas );
buttonHandler.handleEventsFor( radiobut[i] ); // add handler to button
radiobut[i]->setText( STR_TEXT + i );
}
radiobut[0]->enableGroup().enableTabStop(); // set tabStop and Group styles
radiobut[0]->select(); // select first button in group
// create the second set of radio buttons
for (i = mid ; i < NUMBER_OF_BUTTONS ; ++i)
{
radiobut[i] = new IRadioButton( WND_BUTTON + i, &hSetCanvas, &hSetCanvas );
buttonHandler.handleEventsFor( radiobut[i] ); // add handler to button
radiobut[i]->setText( STR_TEXT + i );
}
radiobut[mid]->enableGroup().enableTabStop(); // set tabStop and Group styles
radiobut[mid]->select(); // select first button in group
radiobut[0]->setFocus(); // set focus to radio button one
status.setText( STR_STATUS ); // set status area text from resource
show(); // show main window
} /* end ASetCanvas :: ASetCanvas(...) */
/******************************************************************************/
/* ASetCanvas ::~ASetCanvas - Destructor for our main window */
/******************************************************************************/
ASetCanvas::~ASetCanvas()
{
for (unsigned int i = 0; i < NUMBER_OF_BUTTONS ; ++i)
{
delete radiobut[i];
}
}
/******************************************************************************/
/* AButtonHandler::selected - an ISelectEventHandler */
/* return true if event handled else return false */
/* display the number of the button selected in a text control */
/******************************************************************************/
IBase::Boolean AButtonHandler::selected(IControlEvent& evt )
{
Boolean fHandled = true; // assume event is for us
unsigned long ulButtonId = evt.controlId();
// if the id is one of the buttons
// then display the button number in the
// static text control
if ( ulButtonId >= WND_BUTTON &&
ulButtonId <= (WND_BUTTON+NUMBER_OF_BUTTONS) &&
output)
output->setText( IString( ulButtonId-WND_BUTTON+1 ) );
else
fHandled = false; // pass event to other handlers
return fHandled;
} /* end AButtonHandler::selected(...) */