home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ICLUI.ZIP
/
HELLO6
/
ASPEEDW6.CPP
< prev
next >
Wrap
Text File
|
1993-03-09
|
9KB
|
166 lines
/******************************************************************************/
/* HELLO WORLD SAMPLE PROGRAM - Version 6: ASpeedWindow Class (ASPEEDW6.CPP) */
/* */
/* 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. */
/******************************************************************************/
//**************************************************************************
// The entire file was created at version 6 *
//**************************************************************************
#include <ientryfd.hpp> //IEntryField Class
#include <icmdevt.hpp> //ICommandEvent
#include <istring.hpp> //IString Class
#include <inotebk.hpp> //INotebook Class
#include <isetcv.hpp> //ISetCanvas Class
#include <imcelcv.hpp> //IMultiCellCanvas
#include <islider.hpp> //ISlider Class
#include <icolor.hpp> //IColor Class
#include <istattxt.hpp> //IStaticText Class
#include <ilistbox.hpp> //IListBox Class
#include <imcelcv.hpp> //IMultiCellCanvas
#include <iradiobt.hpp> //IRadioButton
#include <ipushbut.hpp> //IPushButton Class
#include <ireslib.hpp> //IResourceLibrary/IResourceId Class
#include "ahellow6.h" //Include our Symbolic definitions
#include "aspeedw6.hpp" //ASpeedWindow Class
#include "ahellow6.hpp" //AHelloWindow Class
//**************************************************************************
// ASpeedWindow :: ASpeedWindow - Constructor *
// *
// MultiCell Canvas *
// *
// Column 1 Column 2 Column 3 *
// Row 1 *
// Row 2 Label 1 *
// Row 3 Label 2 *
// Row 4 Slider *
// Row 5 *
// *
//**************************************************************************
ASpeedWindow :: ASpeedWindow (AHelloWindow * demoWindow,
IWindow * ownerWnd) //Onwer Window
: IFrameWindow( //Call IFrameWindow Constructor
WND_DEMO_SPEED, //Window Id
ownerWnd) //Owner Window
{ //
target=demoWindow; //Save Target Window
clientWindow=new IMultiCellCanvas( //Create Client Window with
WND_DEMO_CLIENT, // Window ID and
this, this, IRectangle()); // parent, owner and size
setClient(clientWindow); //Set the client to the split canvas
ICommandHandler::handleEventsFor(this);//Set self as command event handler
slider=new ISlider(WND_DEMO_SLIDER, //Create Slider Window
clientWindow, clientWindow, // Set Window ID, client-owner/parent
IRectangle(), 5); // Set Rectangle and number of Ticks
for (unsigned long i=0; i<5; i++) //Loop to set the Tick Text
slider->setTickText( // Set the tick text for each tick
i, (char*)(IString(i+1))); // tick number, tick text
slider->enableSnapToTick(); //Enable Snap to Tick
slider->moveArmToTick( //Set the arm (zero based) to the
target->speed()-1); // current Speed Value from target
label1=new IStaticText(WND_DEMO_LABEL1,//Create Static Text Control
clientWindow, clientWindow); // Pass in client as owner & parent
label1->setAlignment( //Set Alignment to Center in both
IStaticText::centerCenter); // directions
label1->setText(STR_DEMO_LABEL1); //Set the demo label 1
label2=new IStaticText(WND_DEMO_LABEL2,//Create Static Text Control
clientWindow, clientWindow); // Pass in client as owner & parent
label2->setAlignment( //Set Alignment to Center in both
IStaticText::centerCenter); // directions
label2->setText(STR_DEMO_LABEL2); //Set the demo label 2
clientWindow->addToCell(label1, 2, 2);//Add label1 to Canvas at column 2 row 2
clientWindow->addToCell(label2, 2, 3);//Add label2 to Canvas at column 2 row 3
clientWindow->addToCell(slider, 2, 4);//Add Slider to Canvas at column 2 row 4
clientWindow->setColumnWidth(1, 30); //Specify Column 1 Width for Border
clientWindow->setColumnWidth(2, 100, //Specify Column 2 Width and set
true); // expandable
clientWindow->setColumnWidth(3, 30); //Specify Column 3 Width for Border
clientWindow->setRowHeight(1, 30); //Specify Row 1 Height for Border
clientWindow->setRowHeight(2, 0, //Specify Row 2 as expandable
true);
clientWindow->setRowHeight(3, 0, //Specify Row 3 as expandable
true);
clientWindow->setRowHeight(4, 60, //Specify Row 4 as expandable
true);
clientWindow->setRowHeight(5, 30); //Specify Row 5 Height for Border
buttons=new ISetCanvas( //Create a Set Canvas for Buttons
WND_DEMO_BUTTONS, this, this) ; // Parent and Owner=me
buttons->setMargin(ISize()); //Set Canvas Margins to zero
buttons->setPad(ISize()); //Set Button Canvas Pad to zero
applyButton=new IPushButton( //Create the Apply Push Button
WND_DEMO_APPLY,
buttons, this); // Parent is buttons, owner is me
applyButton->setText(STR_APPLY); //Set the text of the Apply Button
cancelButton=new IPushButton( //Create the Cancel Push Button
WND_DEMO_CANCEL,
buttons, this); // Parent is buttons, owner id me
cancelButton->setText(STR_CANCEL); //Set the text of the Cancel Button
addExtension(buttons, //Add Buttons below client area
IFrameWindow::belowClient, 30UL); // and specify the height
sizeTo(ISize(400,300)); //Set the size of main window
setFocus(); //Set focus to main window
show(); //Set to show main window
} /* end ASpeedWindow :: ASpeedWindow(...) */
//**************************************************************************
// ASpeedWindow :: ~ASpeedWindow - Destructor *
//**************************************************************************
ASpeedWindow :: ~ASpeedWindow()
{
} /* end ASpeedWindow :: ~ASpeedWindow(...) */
//**************************************************************************
// ASpeedWindow :: command - Process Commands *
//**************************************************************************
Boolean ASpeedWindow :: command(ICommandEvent& cmdevt)
{
switch(cmdevt.commandId()) {
case WND_DEMO_APPLY: //Process Apply
apply(); //Apply Changes
return(true); //Return Processing Completed
break;
case WND_DEMO_CANCEL: //Process Cancel
close(); //Close the Window
return(true); //Return Processing Completed
break;
}/* end switch */
return(false); //Allow Default Processing to occur
} /* end ASpeedWindow :: command(...) */
//**************************************************************************
// ASpeedWindow :: apply - Apply Changes *
//**************************************************************************
Boolean ASpeedWindow :: apply()
{
int armOffset;
armOffset=slider->armTickOffset()+1; //Get Current Arm Offset (zero based)
target->setSpeed(armOffset); //Set New Speed Value into Target
return true;
} /* end ASpeedWindow :: apply() */