home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ICLUI.ZIP
/
HELLO6
/
ACOLORW6.CPP
next >
Wrap
Text File
|
1993-03-09
|
17KB
|
394 lines
/******************************************************************************/
/* HELLO WORLD SAMPLE PROGRAM - Version 6: AColorWindow Class (ACOLORW6.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 <inotebk.hpp> //INotebook 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 "acolorw6.hpp" //AColorWindow Class
//**************************************************************************
// AColorWindow :: AColorButton:: AColorButton - Constructor *
//**************************************************************************
AColorWindow :: AColorButton :: AColorButton(
unsigned long windowId, //Window ID
IWindow * parentOwner, //Parent/Owner
unsigned long stringId) : //Resource String ID
IRadioButton (windowId,
parentOwner, parentOwner)
{
setText(stringId);
}
//**************************************************************************
// AColorWindow :: AColorWindow - Constructor *
//**************************************************************************
AColorWindow :: AColorWindow(
IStaticText * staticWindow,
IListBox * listWindow,
IWindow * ownerWnd)
: IFrameWindow(WND_COLOR, //Call IFrameWindow Constructor
ownerWnd) // Owner Window
{ //
staticTarget=staticWindow; //Save Static Target Window
listTarget=listWindow; //Save ListBox Target Window
notebook=new INotebook(WND_COLOR_NOTE,//Create Notebook Color
this, this, IRectangle(), //
INotebook::defaultStyle()); //
setClient(notebook); //Set the client to the notebook
ICommandHandler::handleEventsFor(this);//Set self as command event handler
createStaticPage(); //Create Static Color Page
createListPage(); //Create ListBox Color Page
sizeTo(ISize(400,300)); //Set the size of main window
setFocus(); //Set focus to main window
show(); //Set to show main window
} /* end AColorWindow :: AColorWindow(...) */
//**************************************************************************
// AColorWindow :: ~AColorWindow - Destructor *
//**************************************************************************
AColorWindow :: ~AColorWindow()
{
} /* end AColorWindow :: ~AColorWindow(...) */
//**************************************************************************
// AColorWindow :: createStaticPage() *
// *
// MultiCell Canvas *
// *
// Column 1 Column 2 Column 3 Column 4 Column 5 *
// Row 1 *
// Row 2 <--------------Title----------------> *
// Row 3 White Button Pink Button *
// Row 4 Black Button Green Button *
// Row 5 Blue Button Cyan Button * *
// Row 6 Red Button Yellow Button * *
// Row 7 *
// Row 8 Apply Button Cancel Button *
// Row 9 *
//**************************************************************************
Boolean AColorWindow :: createStaticPage()
{
staticCanvas=new IMultiCellCanvas(
WND_STATIC_COLOR, notebook, this,
IRectangle());
IStaticText * staticTitle=new //Create Fore Title Text
IStaticText(0, staticCanvas, staticCanvas);
staticTitle->setText(STR_STATIC_COLOR);//Set the text for the title
staticWhite=new AColorButton( //Static White Radio Button
WND_SWHITE, staticCanvas, STR_WHITE);
staticWhite->enableGroup();
staticWhite->enableTabStop();
staticBlack=new AColorButton( //Static Black Radio Button
WND_SBLACK, staticCanvas, STR_BLACK);
staticBlue=new AColorButton( //Static Blue Radio Button
WND_SBLUE, staticCanvas, STR_BLUE);
staticRed=new AColorButton( //Static Red Radio Button
WND_SRED, staticCanvas, STR_RED);
staticPink=new AColorButton( //Static Pink Radio Button
WND_SPINK, staticCanvas, STR_PINK);
staticGreen=new AColorButton( //Static Green Radio Button
WND_SGREEN, staticCanvas, STR_GREEN);
staticCyan=new AColorButton( //Static Cyan Radio Button
WND_SCYAN, staticCanvas, STR_CYAN);
staticYellow=new AColorButton( //Static Yellow Radio Button
WND_SYELLOW, staticCanvas, STR_YELLOW);
staticApply=new IPushButton( //Static Apply Button
WND_SAPPLY, staticCanvas, this);
staticApply->setText(STR_APPLY);
staticCancel=new IPushButton( //Static Cancel Button
WND_SCANCEL, staticCanvas, this);
staticCancel->setText(STR_CANCEL);
staticCanvas->addToCell(staticTitle, 2, 2, 3, 1);
staticCanvas->addToCell(staticWhite, 2, 3);
staticCanvas->addToCell(staticBlack, 2, 4);
staticCanvas->addToCell(staticBlue, 2, 5);
staticCanvas->addToCell(staticRed, 2, 6);
staticCanvas->addToCell(staticPink, 4, 3);
staticCanvas->addToCell(staticGreen, 4, 4);
staticCanvas->addToCell(staticCyan, 4, 5);
staticCanvas->addToCell(staticYellow, 4, 6);
staticCanvas->addToCell(staticApply, 2, 8);
staticCanvas->addToCell(staticCancel, 4, 8);
staticCanvas->setColumnWidth(1, 20, true);
staticCanvas->setColumnWidth(5, 20, true);
staticCanvas->setRowHeight(1, 20, true);
staticCanvas->setRowHeight(7, 5);
staticCanvas->setRowHeight(9, 30, true);
INotebook::Page::Attribute //Define the Page Attributes
attribute=INotebook::Page::majorTab // with a Major Tab and
| INotebook::Page::autoPageSize; // AutoPageSize
staticPage=INotebook::Page(attribute);//Create Static Color Page
staticPage.setTabText("1"); //Set Tab Text
notebook->addFirstPage(staticPage); //Add as First Page to notebook
staticPage.setWindow(staticCanvas); //Add Window After inserting Page
return true; //Return
} /* end AColorWindow :: createStaticPage() */
//**************************************************************************
// AColorWindow :: createListPage() *
// *
// MultiCell Canvas *
// *
// Column 1 Column 2 Column 3 Column 4 Column 5 *
// Row 1 *
// Row 2 <--------------Title----------------> *
// Row 3 White Button Pink Button *
// Row 4 Black Button Green Button *
// Row 5 Blue Button Cyan Button * *
// Row 6 Red Button Yellow Button * *
// Row 7 *
// Row 8 Apply Button Cancel Button *
// Row 9 *
//**************************************************************************
Boolean AColorWindow :: createListPage()
{
listCanvas=new IMultiCellCanvas(
WND_LIST_COLOR, notebook, this,
IRectangle());
IStaticText * listTitle=new //Create Fore Title Text
IStaticText(0, listCanvas, listCanvas);
listTitle->setText(STR_LIST_COLOR); //Set the text for the title
listWhite=new AColorButton( //List White Radio Button
WND_LWHITE, listCanvas, STR_WHITE);
listWhite->enableGroup();
listWhite->enableTabStop();
listBlack=new AColorButton( //List Black Radio Button
WND_LBLACK, listCanvas, STR_BLACK);
listBlue=new AColorButton( //List Blue Radio Button
WND_LBLUE, listCanvas, STR_BLUE);
listRed=new AColorButton( //List Red Radio Button
WND_LRED, listCanvas, STR_RED);
listPink=new AColorButton( //List Pink Radio Button
WND_LPINK, listCanvas, STR_PINK);
listGreen=new AColorButton( //List Green Radio Button
WND_LGREEN, listCanvas, STR_GREEN);
listCyan=new AColorButton( //List Cyan Radio Button
WND_LCYAN, listCanvas, STR_CYAN);
listYellow=new AColorButton( //List Yellow Radio Button
WND_LYELLOW, listCanvas, STR_YELLOW);
listApply=new IPushButton(WND_LAPPLY, //ListBox Apply Button
listCanvas, this);
listApply->setText(STR_APPLY);
listCancel=new IPushButton(WND_LCANCEL,//ListBox Cancel Button
listCanvas, this);
listCancel->setText(STR_CANCEL);
listCanvas->addToCell(listTitle, 2, 2, 3, 1);
listCanvas->addToCell(listWhite, 2, 3);
listCanvas->addToCell(listBlack, 2, 4);
listCanvas->addToCell(listBlue, 2, 5);
listCanvas->addToCell(listRed, 2, 6);
listCanvas->addToCell(listPink, 4, 3);
listCanvas->addToCell(listGreen, 4, 4);
listCanvas->addToCell(listCyan, 4, 5);
listCanvas->addToCell(listYellow, 4, 6);
listCanvas->addToCell(listApply, 2, 8);
listCanvas->addToCell(listCancel, 4, 8);
listCanvas->setColumnWidth(1, 20, true);
listCanvas->setColumnWidth(5, 20, true);
listCanvas->setRowHeight(1, 20, true);
listCanvas->setRowHeight(7, 5);
listCanvas->setRowHeight(9, 20, true);
INotebook::Page::Attribute //Define the Page Attributes
attribute=INotebook::Page::majorTab // with a Major Tab and
| INotebook::Page::autoPageSize; // AutoPageSize
listPage=INotebook::Page(attribute);//Create ListBox Color Page
listPage.setTabText("2"); //Set the tab text
notebook->addLastPage(listPage); //Add as the Last Page to Notebook
listPage.setWindow(listCanvas); //Add Window after inserting Page
return true; //Return
} /* end AColorWindow :: createListPage() */
//**************************************************************************
// AColorWindow :: command - Process Commands *
//**************************************************************************
Boolean AColorWindow :: command(ICommandEvent& cmdevt)
{
switch(cmdevt.commandId()) {
case WND_SAPPLY: //Process Static Apply
applyStatic(); //Apply Changes from Page 1
return(true); //Return Processing Completed
break;
case WND_SCANCEL: //Process Static Cancel
close(); //Close the Window
return(true); //Return Processing Completed
break;
case WND_LAPPLY: //Process ListBox Apply
applyList(); //Apply Changes from Page 2
return(true); //Return Processing Completed
break;
case WND_LCANCEL: //Process ListBox Cancel
close(); //Close the Window
return(true); //Return Processing Completed
break;
}/* end switch */
return(false); //Allow Default Processing to occur
} /* end AColorWindow :: command(...) */
//**************************************************************************
// AColorWindow :: applyStatic - Apply Changes from Page 1 *
//**************************************************************************
Boolean AColorWindow :: applyStatic()
{
switch (staticWhite->selectedIndex())
{
case 0:
staticTarget->setColor(
IStaticText::foreground,
IColor(IColor::white));
break;
case 1:
staticTarget->setColor(
IStaticText::foreground,
IColor(IColor::black));
break;
case 2:
staticTarget->setColor(
IStaticText::foreground,
IColor(IColor::blue));
break;
case 3:
staticTarget->setColor(
IStaticText::foreground,
IColor(IColor::red));
break;
case 4:
staticTarget->setColor(
IStaticText::foreground,
IColor(IColor::pink));
break;
case 5:
staticTarget->setColor(
IStaticText::foreground,
IColor(IColor::green));
break;
case 6:
staticTarget->setColor(
IStaticText::foreground,
IColor(IColor::cyan));
break;
case 7:
staticTarget->setColor(
IStaticText::foreground,
IColor(IColor::yellow));
break;
} /* endswitch */
return true;
} /* end AColorWindow :: applyStatic() */
//**************************************************************************
// AColorWindow :: applyList - Apply Changes from Page 2 *
//**************************************************************************
Boolean AColorWindow :: applyList()
{
switch (listWhite->selectedIndex())
{
case 0:
listTarget->setColor(
IListBox::foreground,
IColor(IColor::white));
break;
case 1:
listTarget->setColor(
IListBox::foreground,
IColor(IColor::black));
break;
case 2:
listTarget->setColor(
IListBox::foreground,
IColor(IColor::blue));
break;
case 3:
listTarget->setColor(
IListBox::foreground,
IColor(IColor::red));
break;
case 4:
listTarget->setColor(
IListBox::foreground,
IColor(IColor::pink));
break;
case 5:
listTarget->setColor(
IListBox::foreground,
IColor(IColor::green));
break;
case 6:
listTarget->setColor(
IListBox::foreground,
IColor(IColor::cyan));
break;
case 7:
listTarget->setColor(
IListBox::foreground,
IColor(IColor::yellow));
break;
} /* endswitch */
return true;
} /* end AColorWindow :: applyList() */