home *** CD-ROM | disk | FTP | other *** search
-
- #include <os2.h>
- #include "testcnr.hpp"
- #include <istring.hpp>
- #include <itrace.hpp>
- #include <ititle.hpp>
- #include <ireslib.hpp>
- #include <iapp.hpp>
- #include <icnrctl.hpp>
- #include <iabmenu.hpp>
- #include "testcnr.h"
-
- #ifdef __automake__
- source "testcnr.rc", "testcnr.def";
- library "ibase", "ibaseapp", "ibasectl", "icnr";
- #endif
-
-
- /*--------------------------------------------------------*/
- /* This is the entry point from the System. */
- /*--------------------------------------------------------*/
- void main(int argc,char **argv)
- {
- IMODTRACE_DEVELOP("main");
-
- // create our main window has child of the desktop
- CustomerList* pcnrList = new CustomerList(IRectangle());
-
- /*-----------------------------------------------------*/
- /* set the title data for all views, but make invisable*/
- /*-----------------------------------------------------*/
- ITRACE_DEVELOP("setting container Title");
- pcnrList->container().setContainerTitle("Customer Records");
-
- ITRACE_DEVELOP("setting focus");
- pcnrList->setFocus();
-
- // run the aplication
- ITRACE_DEVELOP("running the app");
- IApplication::current.run();
-
- delete pcnrList;
- }
-
-
-
-
- /*--------------------------------------------------------*/
- /* CustomerList Constructor. */
- /*--------------------------------------------------------*/
- CustomerList :: CustomerList(const IRectangle& rect,
- Boolean fLoadObjectsIn)
- : IFrameWindow(CNR_MAINWINDOW),
- // Create a Container Control
- _pcnrCustList(new IContainerControl(CNR_MAINCONTROL, this, this, IRectangle())),
- _pObjectList(new IContainerControl(CNR_MAINCONTROL+1, this, this, IRectangle(),
- IContainerControl::extendedSelection | IWindow::visible,
- IContainerControl::textView)),
- cnrcolIcon( IContainerObject :: iconOffset(),
- IContainerColumn::defHeadingStyle,
- IContainerColumn::icon |
- IContainerColumn::centerVertically),
- cnrcolName(IContainerObject::iconTextOffset(),
- IContainerColumn::defHeadingStyle,
- IContainerColumn::string |
- IContainerColumn::centerVertically |
- IContainerColumn::leftJustify |
- IContainerColumn::horizontalSeparator),
- cnrcolAddress( FIELDOFFSET2(Customer, strCustomerAddress)),
- cnrcolPhone( FIELDOFFSET2(Customer, strCustomerPhone)),
- cnrcolAge( FIELDOFFSET2(Customer, ulCustomerAge),
- IContainerColumn::defHeadingStyle,
- IContainerColumn::number |
- IContainerColumn::centerVertically |
- IContainerColumn::horizontalSeparator |
- IContainerColumn::rightJustify),
- cnrcolOrderDate( FIELDOFFSET2(Customer, strOrderDate),
- IContainerColumn::defHeadingStyle,
- IContainerColumn::string |
- IContainerColumn::centerVertically |
- IContainerColumn::horizontalSeparator |
- IContainerColumn::leftJustify),
- cnrcolOrderTime( FIELDOFFSET2(Customer, strOrderTime),
- IContainerColumn::defHeadingStyle,
- IContainerColumn::string |
- IContainerColumn::centerVertically |
- IContainerColumn::horizontalSeparator |
- IContainerColumn::rightJustify)
-
- {
- IMODTRACE_DEVELOP("CnrLst::CnrLst");
-
- // Add a title
- // _pTitle = new ITitle(this, "Container Test Program");
-
- // set ourselves as event handler, since we multiple-inherit
- addHandler(this);
-
- // set main menu
- IActionBarMenu* pabmnMain=new IActionBarMenu(CNR_MAIN_MENU,this);
-
- // Put the main container in the client area
- setClient(_pcnrCustList);
-
- // Create static text status area
- _pStatusLine = new IStaticText(CNR_STATUSAREA, this, this, IRectangle());
- _pStatusLine->setText("Loading Container. Please wait...");
-
- // set status line on top of client fill-box
- addControl(_pStatusLine,
- IFrCtlAttr::placeTop | IFrCtlAttr::splitBar,
- _pcnrCustList, None, 30);
-
- // Put the object list container as a frame extension
- addControl(_pObjectList,
- IFrCtlAttr::placeRight | IFrCtlAttr::splitBar,
- _pcnrCustList, None, 90);
-
-
- // Create titlebar icon
- // _pTitleIcon = new IIconControl(CNR_MINIICON, this, this, IRectangle(0, 0, 30,30),
- // CNR_MINIICON);
-
- // set this one as extension, left of titlebar
- // addControl(_pTitleIcon,
- // IFrCtlAttr::placeBottom | IFrCtlAttr::thinSepLine,
- // 0, Titlebar, 30);
-
-
- cnrcolAddress.enableDataUpdate();
- fLoadObjects=fLoadObjectsIn;
-
- show();
- container().hide();
-
- if(loadObjects()==TRUE)
- loadContainer(container());
-
- // Create Objects to match all of these and store the pointers
- // as an object in the second container.
- {
- ICnrObjectSet objset = container().objectList();
- ICnrObjectSet::Cursor objcur(objset);
- IContainerObject *pcnrobjOld, *pcnrobjNew;
- IString strPointer;
- for(objcur.setToFirst(); objcur.isValid(); objcur.setToNext())
- {
- pcnrobjOld = objset.elementAt(objcur);
- strPointer = IString((unsigned long)pcnrobjOld);
- strPointer.d2x();
- pcnrobjNew = new IContainerObject(strPointer);
- objectList().addObject(pcnrobjNew);
- }
- }
-
- /*-----------------------------------------------------*/
- /* Details View setup (Not required if not used). */
- /*-----------------------------------------------------*/
-
- /* set the title data for details view */
- colIcon()->setHeadingText("Icon");
- colName()->setHeadingText("Customer Name");
- colAddress()->setHeadingText("Address ");
- colPhone()->setHeadingIcon(IResourceId(ICON_PHONE));
- colAge()->setHeadingText("Customer Age");
- colOrderDate()->setHeadingText("Order Date");
- colOrderTime()->setHeadingText("Order Time");
-
- /* add column separators */
- colName()->showDataSeparators(IContainerColumn::horizontalSeparator);
- colAddress()->showDataSeparators();
- colPhone()->showDataSeparators(IContainerColumn::verticalSeparator);
-
- /* add the columns to the container */
- container().addColumn(colIcon());
- container().addColumn(colName());
- container().addColumn(colAddress());
- container().addColumn(colPhone());
- container().addColumn(colAge());
- container().addColumn(colOrderDate());
- container().addColumn(colOrderTime());
-
- container().setDetailsViewSplit(colName(), 150);
-
- container().setDestroyObjectsOnClose();
-
- /*-----------------------------------------------------*/
- /* Misc. adjustments to the various views. */
- /*-----------------------------------------------------*/
- container().arrangeIconView();
- container().showTreeLine();
- container().showContainerTitle();
- container().enableOwnerDraw();
-
- container().showTreeIconView();
-
- /*-----------------------------------------------------*/
- /* Setup to allow Direct Manipulation on the Container.*/
- /*-----------------------------------------------------*/
-
- container().show();
- _pStatusLine->setText("O.K.");
-
- }
-
- /*--------------------------------------------------------*/
- /* Add the objects to the passed container loading icons */
- /* from the passed resource manager. */
- /*--------------------------------------------------------*/
- void loadContainer(IContainerControl& cnrctl)
- {
- IResourceLibrary reslib;
-
- IMODTRACE_DEVELOP("loadContainer()");
-
- /* load the icons */
- ITRACE_DEVELOP("Loading icons");
- IPointerHandle hptrNotebook = reslib.loadIcon(ICON_NOTEBOOK);
- ITRACE_DEVELOP(IString("Returned PointerValue is:")+IString(hptrNotebook));
- IPointerHandle hptrCabinet = reslib.loadIcon(ICON_CABINET);
- ITRACE_DEVELOP(IString("Returned PointerValue is:")+IString(hptrCabinet));
- IPointerHandle hptrInBasket = reslib.loadIcon(ICON_INBASKET);
- IPointerHandle hptrShredder = reslib.loadIcon(ICON_SHREDDER);
-
- /* construct some strings to use in the objects */
- ITRACE_DEVELOP("Building default strings");
- IString strText("");
- IString strIconName(" - Icon Name");
- IString strName(" - Name");
- IString strAddress(" - Address");
- IString strPhone(" - Phone");
-
- /* Declare some stack arrays for the objects pointers */
- const int sObjCount = 10;
- Customer* NoteBookList[sObjCount];
- Customer* CabinetList[sObjCount];
- Customer* InBasketList[sObjCount];
- Customer* ShredderList[sObjCount];
-
-
- /* Build The Parent Objects */
- ITRACE_DEVELOP("Building parent objects");
- NoteBookList[0] = new Customer("Notebook Parent",hptrNotebook);
- CabinetList[0] = new Customer("Cabinet Parent" ,hptrCabinet );
- InBasketList[0] = new Customer("InBasket Parent",hptrInBasket);
- ShredderList[0] = new Customer("Shredder Parent",hptrShredder);
-
- /* Add Name Address & Phone to parents */
- ITRACE_DEVELOP(IString("Text is ")+NoteBookList[0]->iconText());
- NoteBookList[0]->setCustomerName("Nate Notebook");
- NoteBookList[0]->setCustomerAddress("12 Address");
- NoteBookList[0]->setCustomerPhone("361-5511");
- NoteBookList[0]->setCustomerAge(10);
- NoteBookList[0]->setOrderDate(IDate(IDate::December, 1, 1992));
- NoteBookList[0]->setOrderTime(ITime::now());
-
- CabinetList[0]->setCustomerName("Carla Cabinet");
- CabinetList[0]->setCustomerAddress("34 Address");
- CabinetList[0]->setCustomerPhone("361-5512");
- CabinetList[0]->setCustomerAge(20);
- CabinetList[0]->setOrderDate(IDate(IDate::February, 15, 1990));
- CabinetList[0]->setOrderTime(ITime::now());
-
- InBasketList[0]->setCustomerName("Inna InBasket");
- InBasketList[0]->setCustomerAddress("56 Address");
- InBasketList[0]->setCustomerPhone("361-5512");
- InBasketList[0]->setCustomerAge(30);
- InBasketList[0]->setOrderDate(IDate(IDate::February, 22, 1993));
- InBasketList[0]->setOrderTime(ITime::now());
-
- ShredderList[0]->setCustomerName("Shirley Shredder");
- ShredderList[0]->setCustomerAddress("78 Address");
- ShredderList[0]->setCustomerPhone("361-551");
- ShredderList[0]->setCustomerAge(40);
- ShredderList[0]->enableDataUpdate();
- ShredderList[0]->setOrderDate(IDate(IDate::December, 3, 3));
- ShredderList[0]->setOrderTime(ITime::now());
-
-
- /* Add the parent objects to the container */
- ITRACE_DEVELOP("Adding parent objects to container");
- cnrctl.addObject(NoteBookList[0]);
- cnrctl.addObject(CabinetList[0]);
- cnrctl.addObject(InBasketList[0]);
- cnrctl.addObject(ShredderList[0]);
-
- int s;
- ITRACE_DEVELOP("Constructing Notebook child objects");
- /* Add some children to the Notebook */
- for (s=1; s<sObjCount; s++)
- {
- strText = IString(s) + strName;
-
- /* construct the Notebook Customer */
- hptrNotebook = reslib.loadIcon(ICON_NOTEBOOK);
- NoteBookList[s] = new Customer(strText,hptrNotebook);
-
- /* Add the Name, Address, and Phone */
- NoteBookList[s]->setCustomerName(strText);
- strText = IString(s) + strAddress;
- NoteBookList[s]->setCustomerAddress(strText);
- strText = IString(s) + strPhone;
- NoteBookList[s]->setCustomerPhone(strText);
- NoteBookList[s]->setCustomerAge(10+s);
- NoteBookList[0]->setOrderDate(IDate::today());
- NoteBookList[0]->setOrderTime(ITime::now());
-
-
- /* add the object to the container */
- cnrctl.addObject(NoteBookList[s], NoteBookList[0]);
- }
-
- /* Add some children to the Cabinet */
- ITRACE_DEVELOP("Constructing Cabinet child objects");
- for (s=1; s<sObjCount; s++)
- {
- strText = IString(s) + strName;
-
- /* construct the Cabinet Customer */
- hptrCabinet = reslib.loadIcon(ICON_CABINET);
- CabinetList[s] = new Customer(strText,hptrCabinet);
-
- /* Add the Name, Address, and Phone */
- CabinetList[s]->setCustomerName(strText);
- strText = IString(s) + strAddress;
- CabinetList[s]->setCustomerAddress(strText);
- strText = IString(s) + strPhone;
- CabinetList[s]->setCustomerPhone(strText);
- CabinetList[s]->setCustomerAge(20+s);
- CabinetList[0]->setOrderDate(IDate::today());
- CabinetList[0]->setOrderTime(ITime::now());
-
- /* add the object to the container */
- cnrctl.addObject(CabinetList[s], CabinetList[0]);
- }
-
- /* Add some children to the Inbasket */
- ITRACE_DEVELOP("Constructing Inbasket child objects");
- for (s=1; s<sObjCount; s++)
- {
- strText = IString(s) + strName;
-
- /* construct the Inbasket Customer */
- hptrInBasket = reslib.loadIcon(ICON_INBASKET);
- InBasketList[s] = new Customer(strText,hptrInBasket);
-
- /* Add the Name, Address, and Phone */
- InBasketList[s]->setCustomerName(strText);
- strText = IString(s) + strAddress;
- InBasketList[s]->setCustomerAddress(strText);
- strText = IString(s) + strPhone;
- InBasketList[s]->setCustomerPhone(strText);
- InBasketList[s]->setCustomerAge(30+s);
- InBasketList[0]->setOrderDate(IDate::today());
- InBasketList[0]->setOrderTime(ITime::now());
-
- /* add the object to the container */
- cnrctl.addObject(InBasketList[s], InBasketList[0]);
- }
-
- /* Add some children to the Shredder */
- ITRACE_DEVELOP("Constructing Shredder child objects");
- for (s=1; s<sObjCount; s++)
- {
- strText = IString(s) + strName;
-
- /* construct the Shredder Customer */
- hptrShredder = reslib.loadIcon(ICON_SHREDDER);
- ShredderList[s] = new Customer(strText,hptrShredder);
-
- /* Add the Name, Address, and Phone */
- ShredderList[s]->setCustomerName(strText);
- strText = IString(s) + strAddress;
- ShredderList[s]->setCustomerAddress(strText);
- strText = IString(s) + strPhone;
- ShredderList[s]->setCustomerPhone(strText);
- ShredderList[s]->setCustomerAge(40+s);
- ShredderList[0]->setOrderDate(IDate::today());
- ShredderList[0]->setOrderTime(ITime::now());
-
-
- /* add the object to the container */
- cnrctl.addObject(ShredderList[s], ShredderList[0]);
- }
-
- /* Test Dropping on an Object */
- ITRACE_DEVELOP("Constructing Drop Tester");
- Customer* DropTester = new Customer("Drop Tester",
- reslib.loadIcon(ICON_SHREDDER));
- // DropTester->enableDrop();
- DropTester->setCustomerName("Drop Gobler");
- DropTester->setCustomerAddress("1");
- DropTester->setCustomerPhone("2");
- DropTester->setCustomerAge(50);
- cnrctl.addObject(DropTester);
-
- };
-
-
- void Customer :: handleOpen(IContainerControl* pcnrctl)
- {
- IMODTRACE_DEVELOP("Cust::open");
- /* Construct a Child Iterator */
- IContainerControl::ObjectCursor iter(*pcnrctl, this);
- Customer* pcust;
- pcust = (Customer*)iter.first();
-
- /* If any children open a container on the children */
- if (pcust!=0L)
- {
-
- ITRACE_DEVELOP("Building Child Container");
- CustomerList* pcnr2 = new CustomerList(IRectangle(0,0,0,0), FALSE);
-
- pcnr2->container().setContainerTitle("Customer Child Records");
-
- while(pcust!=0L)
- {
- pcnr2->container().addObject(pcust);
- pcust = (Customer*)iter.next();
- }
-
- pcnr2->container().arrangeIconView();
- pcnr2->container().showTreeLine();
- pcnr2->container().showContainerTitle();
- pcnr2->container().showDetailsView();
- pcnr2->show();
- }
- /* ensure we get marked as "open" */
- IContainerObject::setOpen();
- }
-
- /*--------------------------------------------------------*/
- /* Customer object constructor. */
- /*--------------------------------------------------------*/
- Customer :: Customer(const IString& strName, const IPointerHandle& hptrIcon,
- const IString& strAddress,
- const IString& strPhone, unsigned long ulAge)
- : IContainerObject(strName, hptrIcon),
- strCustomerName(strName),
- strCustomerAddress(strAddress),
- strCustomerPhone(strPhone),
- ulCustomerAge(ulAge),
- strOrderDate(),
- strOrderTime()
- {
- IMODTRACE_DEVELOP("Cust::Cust");
- }
-
-
- /*--------------------------------------------------------*/
- /* Customer object copy constructor. */
- /*--------------------------------------------------------*/
- Customer :: Customer(Customer& custOld) : IContainerObject(custOld),
- strCustomerName(custOld.customerName()),
- strCustomerAddress(custOld.customerAddress()),
- strCustomerPhone(custOld.customerPhone()),
- ulCustomerAge(custOld.ulCustomerAge)
- {
- IMODTRACE_DEVELOP("Cust::Cust(&)");
- }
-
- /*--------------------------------------------------------*/
- /* Return a copy of an object. */
- /*--------------------------------------------------------*/
- IContainerObject* Customer :: objectCopy()
- {
- /* invoke Customer :: Customer(Customer&) to do copy */
- Customer* pcustCopy = new Customer(*this);
- return (IContainerObject*)pcustCopy;
- }
-
-
- /*--------------------------------------------------------*/
- /* CustomerList object destructor. */
- /*--------------------------------------------------------*/
- Customer :: ~Customer()
- {
- IMODTRACE_DEVELOP("Cust::~Cust");
- }
-
- void Customer :: setOrderDate(const IDate& date)
- {
- #if 0
- cdateOrder.day = date.dayOfMonth();
- cdateOrder.month = date.monthOfYear();
- cdateOrder.year = date.year();
- #else
- strOrderDate = date.asString();
- #endif
-
- }
-
- void Customer :: setOrderTime(const ITime& time)
- {
- #if 0
- ctimeOrder.hours = time.hours();
- ctimeOrder.minutes = time.minutes();
- ctimeOrder.seconds = time.seconds();
- #else
- strOrderTime = time.asString();
- #endif
- }
-
-
-
-
-
- /**********************************************************/
- /* Process commands from the Window (MenuItems) */
- /**********************************************************/
- Boolean CustomerList::command(ICommandEvent& cmdevt)
- {
- IMODTRACE_DEVELOP("CustList::command");
-
- static IContainerControl::ObjectCursor iter(container());
- static Customer* pcustSave;
-
-
- ITRACE_DEVELOP(IString("Command Id is ")+IString(cmdevt.commandId()));
-
- switch(cmdevt.commandId())
- {
- /*--------------------------------------*/
- /* View Menu */
- /*--------------------------------------*/
- case CNR_VIEW_TEXT:
- container().showTextView();
- break;
-
- case CNR_VIEW_FLOWED_TEXT:
- container().showFlowedTextView();
- break;
-
- case CNR_VIEW_NAME:
- container().showNameView();
- break;
-
- case CNR_VIEW_FLOWED_NAME:
- container().showFlowedNameView();
- break;
-
- case CNR_VIEW_ICON:
- container().showIconView();
- break;
-
- case CNR_VIEW_DETAIL:
- container().showDetailsView();
- break;
-
- case CNR_VIEW_TREE_ICON:
- container().showTreeIconView();
- break;
-
- case CNR_VIEW_TREE_TEXT:
- container().showTreeTextView();
- break;
-
- case CNR_VIEW_TREE_NAME:
- container().showTreeNameView();
- break;
-
- /*--------------------------------------*/
- /* View - Sort SubMenu */
- /*--------------------------------------*/
- case CNR_SORT_BYCUSTOMER:
- container().setSortFunction((ICOMPOBJCALLBACK*)pfncompName);
- container().sort();
- break;
-
- case CNR_SORT_BYADDRESS:
- container().setSortFunction((ICOMPOBJCALLBACK*)pfncompAddress);
- container().sort();
- break;
-
- case CNR_SORT_BYPHONE:
- container().setSortFunction((ICOMPOBJCALLBACK*)pfncompPhone);
- container().sort();
- break;
-
- case CNR_SORT_BYAGE:
- container().setSortFunction((ICOMPOBJCALLBACK*)pfncompAge);
- container().sort();
- break;
-
- case CNR_ARRANGE_ICONVIEW:
- container().arrangeIconView();
- break;
-
- /*--------------------------------------*/
- /* View - Include SubMenu */
- /*--------------------------------------*/
- case CNR_INCLUDE_A_K :
- {
- container().setFilterFunction((IFILTEROBJCALLBACK*)pfnfilterA_K);
- container().filter();
- break;
- }
-
- case CNR_INCLUDE_L_Z :
- {
- container().setFilterFunction((IFILTEROBJCALLBACK*)pfnfilterL_Z);
- container().filter();
- break;
- }
-
- case CNR_INCLUDE_OVER_30 :
- {
- container().setFilterFunction((IFILTEROBJCALLBACK*)pfnfilterOver30);
- container().filter();
- break;
- }
-
- case CNR_INCLUDE_ALL :
- {
- container().setFilterFunction((IFILTEROBJCALLBACK*)0);
- container().filter();
- break;
- }
-
- /*--------------------------------------*/
- /* Edit Menu */
- /*--------------------------------------*/
- /* Note: copy just keeps a pointer to the object around */
- case CNR_COPY_CURSOR:
- {
- pcustSave = (Customer*)container().cursoredObject();
- break;
- }
-
- case CNR_COPY_MARKS:
- { /* Note: iterating through a collection while adding */
- /* objects is dangerous business. Be sure you know */
- /* what you are doing. Here we iterate from the end */
- /* while adding new things to the end so we don't see*/
- /* them twice. */
- IContainerControl::ObjectCursor cnrcursor(container(), IContainerObject::selected);
- Customer* pcust = (Customer*)cnrcursor.last();
- Customer* pcustCopy;
-
- while(pcust)
- {
- pcustCopy = new Customer(*pcust);
- pcustCopy->setRefreshOff();
- container().addObject(pcustCopy);
- pcust = (Customer*)cnrcursor.previous();
- }
- container().refresh();
- break;
- }
-
- case CNR_DELETE_CURSOR:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- delete pcust;
- break;
- }
-
- case CNR_DELETE_MARKS:
- {
- container().deleteSelectedObjects();
- break;
- }
-
- case CNR_DELETE_ALL_OBJECTS:
- {
- container().deleteAllObjects();
- break;
- }
-
- case CNR_CREATE_AT_CURSOR:
- {
- Customer* pcust = new Customer("Added Object",
- ICON_INBASKET);
- pcust->setCustomerName("Added Shredder");
- pcust->setCustomerAddress("34 Address");
- pcust->setCustomerPhone("361-5512");
- Customer* pcustCurrent = (Customer*)container().cursoredObject();
- container().addObjectAfter(pcust, pcustCurrent);
- break;
- }
-
- case CNR_CREATE_AS_CHILD:
- {
- Customer* pcustCurrent = (Customer*)container().cursoredObject();
- Customer* pcust = new Customer("Added Child Object",
- ICON_INBASKET);
- pcust->setCustomerName("Added Shredder");
- pcust->setCustomerAddress("34 Address");
- pcust->setCustomerPhone("361-5512");
- container().addObject(pcust, pcustCurrent);
- break;
- }
-
- case CNR_CUT_OBJECT:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- pcustSave = pcust;
- delete pcust;
- break;
- }
-
- case CNR_PASTE_AT_CURSOR:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcustSave && pcust)
- {
- Customer* pcustNew = new Customer(*pcustSave);
- container().addObjectAfter(pcustNew,pcust);
- }
- break;
- }
-
- case CNR_PASTE_AS_CHILD: /* Add a copy as child of current */
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcustSave && pcust)
- {
- container().copyObjectTo(pcust, pcustSave);
- // Customer* pcustNew = new Customer(*pcustSave);
- // container().addObject(pcustNew,pcust);
- }
- break;
- }
-
- case CNR_REMOVE_CURSOR:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust!=0)
- container().removeObject(pcust);
- break;
- }
-
- case CNR_REMOVE_MARKS:
- {
- container().removeSelectedObjects();
- break;
- }
-
- case CNR_REMOVE_ALL:
- {
- container().removeAllObjects();
- break;
- }
- #if 1
- case CNR_SELECT_ALL:
- {
- break;
- }
-
- case CNR_DESELECT_ALL:
- {
- break;
- }
- #endif
- /*--------------------------------------*/
- /* Attribute Menu - Column SubMenu */
- /*--------------------------------------*/
- case CNR_SHOW_COL_2:
- {
- unsigned long ul = 1;
- IContainerColumn* pcnrcol = container().columnAt(ul);
- if(pcnrcol!=0)
- pcnrcol->show();
- break;
- }
-
- case CNR_HIDE_COL_2:
- {
- IContainerColumn* pcnrcol = container().columnAt(1);
- if(pcnrcol!=0)
- pcnrcol->hide();
- break;
- }
-
- case CNR_MOVE_COL_2TOLAST:
- {
- IContainerColumn* pcnrcol = container().columnAt(1);
- IContainerColumn* pcnrcol3 = container().columnAt(3);
- container().removeColumn(pcnrcol);
- container().addColumn(pcnrcol, pcnrcol3);
- container().setDetailsViewSplit(pcnrcol);
- break;
- }
-
- case CNR_INCREASE_WIDTH_COL2:
- {
- IContainerColumn* pcnrcol = container().columnAt(1);
- if(pcnrcol->displayWidth() == 0)
- pcnrcol->setDisplayWidth(40);
- else
- pcnrcol->setDisplayWidth(pcnrcol->displayWidth() + 10);
- break;
- }
-
- case CNR_DECREASE_WIDTH_COL2:
- {
- IContainerColumn* pcnrcol = container().columnAt(1);
- if(pcnrcol->displayWidth() == 0)
- pcnrcol->setDisplayWidth(30);
- else
- pcnrcol->setDisplayWidth(pcnrcol->displayWidth() - 10);
- break;
- }
-
- /*--------------------------------------*/
- /* Attribute Menu - Container Sub-Menu */
- /*--------------------------------------*/
- case CNR_INCREMENT_LINESPACING:
- {
- container().setLineSpacing(container().lineSpacing() + 5);
- break;
- }
-
- case CNR_DECREMENT_LINESPACING:
- {
- container().setLineSpacing(container().lineSpacing() - 5);
- break;
- }
-
- case CNR_ORDEREDTARGET:
- {
- container().setOrderedTargetEmphasis();
- break;
- }
-
- case CNR_MIXEDTARGET:
- {
- container().setMixedTargetEmphasis();
- break;
- }
-
- case CNR_NORMALTARGET:
- {
- container().setNormalTargetEmphasis();
- break;
- }
-
- case CNR_SINGLESELECT:
- {
- container().setSingleSelection();
- break;
- }
-
- case CNR_MULTIPLESELECT:
- {
- container().setMultipleSelection();
- break;
- }
-
- case CNR_EXTENDEDSELECT:
- {
- container().setExtendedSelection();
- break;
- }
-
- /*--------------------------------------*/
- /* Attribute Menu - Object Sub-Menu */
- /*--------------------------------------*/
- case CNR_ENABLE_DROP_ALL:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust)
- pcust->enableDrop();
- break;
- }
-
- case CNR_ENABLE_DROP_ONE:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust)
- container().enableDrop(pcust);
- break;
- }
-
- case CNR_DISABLE_DROP_ALL:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust)
- pcust->disableDrop();
- break;
- }
-
- case CNR_DISABLE_DROP_ONE:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust)
- container().disableDrop(pcust);
- break;
- }
-
- case CNR_ENABLE_OBJECTUPDATE_ALL:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust)
- pcust->enableDataUpdate();
- break;
- }
-
- case CNR_ENABLE_OBJECTUPDATE_ONE:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust)
- container().enableDataUpdate(pcust);
- break;
- }
-
- case CNR_DISABLE_OBJECTUPDATE_ALL:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust)
- pcust->disableDataUpdate();
- break;
- }
-
- case CNR_DISABLE_OBJECTUPDATE_ONE:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust)
- container().disableDataUpdate(pcust);
- break;
- }
-
- case CNR_SET_INUSE_ALL:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust!=0)
- pcust->setInUse();
- break;
- }
-
- case CNR_SET_INUSE_ONE:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust!=0)
- container().setInUse(pcust);
- break;
- }
-
- case CNR_REMOVE_INUSE_ALL:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust!=0)
- pcust->removeInUse();
- break;
- }
-
- case CNR_REMOVE_INUSE_ONE:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust!=0)
- container().removeInUse(pcust);
- break;
- }
-
- case CNR_SELECT:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust!=0)
- container().setSelected(pcust);
- break;
- }
-
- case CNR_DESELECT:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust!=0)
- container().removeSelected(pcust);
- break;
- }
-
- case CNR_EXPAND_CURRENT:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust!=0)
- container().expand(pcust);
- break;
- }
-
- case CNR_COLLAPSE_CURRENT:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if(pcust!=0)
- container().collapse(pcust);
- break;
- }
-
- case CNR_INCREMENT_ICONSIZE:
- {
- ISize siz = container().iconSize();
- container().setIconSize(siz + ISize(5,5));
- break;
- }
-
- case CNR_DECREMENT_ICONSIZE:
- {
- ISize siz = container().iconSize();
- container().setIconSize(siz - ISize(5,5));
- break;
- }
-
- /*------------------------------------------*/
- /* Attribute Menu - Object Status Sub-Menu */
- /*------------------------------------------*/
- case CNR_IS_DROP_ENABLED_ALL:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if (pcust->isDropOnAble())
- statusArea().setText("Cursor Object is droponable in all containers");
- else
- statusArea().setText("Cursor Object is Not droponable in all containers");
- break;
- }
-
- case CNR_IS_DROP_ENABLED_ONE:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if (container().isDropOnAble(pcust))
- statusArea().setText("Cursor Object is droponable in this containers");
- else
- statusArea().setText("Cursor Object is Not droponable in this containers");
- break;
- }
-
- case CNR_IS_READONLY_ALL:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if (pcust->isReadOnly())
- statusArea().setText("Cursor Object is readonly in all containers.");
- else
- statusArea().setText("Cursor Object is editable in all containers.");
- break;
- }
-
- case CNR_IS_READONLY_ONE:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if (container().isReadOnly(pcust))
- statusArea().setText("Cursor Object is readonly in this containers.");
- else
- statusArea().setText("Cursor Object is editable in this containers.");
- break;
- }
-
- case CNR_IS_INUSE_ALL:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if (pcust->isInUse())
- statusArea().setText("Cursor Object is in-use in all containers.");
- else
- statusArea().setText("Cursor Object is not in-use in all containers.");
- break;
- }
-
- case CNR_IS_INUSE_ONE:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if (container().isInUse(pcust))
- statusArea().setText("Cursor Object is in-use in this containers.");
- else
- statusArea().setText("Cursor Object is not in-use in this containers.");
- break;
- }
-
- case CNR_IS_SELECTED:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if (container().isSelected(pcust))
- statusArea().setText("Cursor Object is selected.");
- else
- statusArea().setText("Cursor Object is not selected.");
- break;
- }
-
- case CNR_IS_EXPANDED:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- if (container().isExpanded(pcust))
- statusArea().setText("Cursor Object is expanded.");
- else
- statusArea().setText("Cursor Object is not expanded.");
- break;
- }
-
- /*------------------------------------------*/
- /* Attribute Menu - Title Sub-Menu */
- /*------------------------------------------*/
- case CNR_SHOW_CONTAINERTITLE:
- {
- container().showContainerTitle();
- break;
- }
-
- case CNR_HIDE_CONTAINERTITLE:
- {
- container().hideContainerTitle();
- break;
- }
-
- case CNR_CONTAINERTITLE_VISIBLE:
- {
- if (container().isContainerTitleVisible())
- statusArea().setText("Title is visible.");
- else
- statusArea().setText("Title is not visible.");
- break;
- }
-
- case CNR_ENABLE_TITLEUPDATE:
- {
- container().enableTitleUpdate();
- break;
- }
-
- case CNR_DISABLE_TITLEUPDATE:
- {
- container().disableTitleUpdate();
- break;
- }
-
- case CNR_SHOW_TITLESEPARATOR:
- {
- container().showTitleSeparator();
- break;
- }
-
- case CNR_HIDE_TITLESEPARATOR:
- {
- container().hideTitleSeparator();
- break;
- }
-
- /*------------------------------------------*/
- /* Attribute Menu - TreeView Sub-Menu */
- /*------------------------------------------*/
- case CNR_SHOW_TREELINE:
- {
- container().showTreeLine();
- break;
- }
-
- case CNR_HIDE_TREELINE:
- {
- container().hideTreeLine();
- break;
- }
- case CNR_INCREMENT_EXPANDICON:
- {
- ISize siz = container().iconSize();
- container().setTreeExpandIconSize(siz + ISize(2,2));
- break;
- }
-
- case CNR_DECREMENT_EXPANDICON:
- {
- ISize siz = container().iconSize();
- container().setTreeExpandIconSize(siz - ISize(2,2));
- break;
- }
-
- case CNR_EXPAND:
- {
- container().expandTree();
- break;
- }
-
- case CNR_COLLAPSE:
- {
- container().collapseTree();
- break;
- }
-
- /*------------------------------------------*/
- /* Attribute Menu - DetailsView Sub-Menu */
- /*------------------------------------------*/
- case CNR_SHOW_DETAILSTITLE:
- {
- container().showDetailsViewTitles();
- break;
- }
-
- case CNR_HIDE_DETAILSTITLE:
- {
- container().hideDetailsViewTitles();
- break;
- }
-
-
- case CNR_SHOW_SPLITBAR:
- {
- container().showSplitBar();
- break;
- }
-
- case CNR_HIDE_SPLITBAR:
- {
- container().hideSplitBar();
- break;
- }
-
-
- /*------------------------------------------*/
- /* Move Menu */
- /*------------------------------------------*/
- case CNR_MOVE_ICON_RIGHT:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- IPoint pt = container().iconRectangle(pcust).bottomLeft();
- container().moveIconTo(pcust, pt + IPoint(5,0));
- break;
- }
- case CNR_MOVE_ICON_LEFT:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- IPoint pt = container().iconRectangle(pcust).bottomLeft();
- container().moveIconTo(pcust, pt + IPoint(-5,0));
- break;
- }
- case CNR_MOVE_ICON_UP:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- IPoint pt = container().iconRectangle(pcust).bottomLeft();
- pt += IPoint(0,5);
- container().moveIconTo(pcust, pt );
- break;
- }
- case CNR_MOVE_ICON_DOWN:
- {
- Customer* pcust = (Customer*)container().cursoredObject();
- IPoint pt = container().iconRectangle(pcust).bottomLeft();
- container().moveIconTo(pcust, pt + IPoint(0,-5));
- break;
- }
- case CNR_MOVE_CURSORED_TOVIEW:
- {
- IMODTRACE_DEVELOP("To View");
- Customer* pcust = (Customer*)container().cursoredObject();
- container().scrollToObject(pcust);
- break;
- }
- case CNR_MOVE_CURSORED_TOPRIGHT:
- {
- IMODTRACE_DEVELOP("Top Right");
- Customer* pcust = (Customer*)container().cursoredObject();
- IRectangle rectIcon = container().iconRectangle(pcust);
- IRectangle rectClient = container().rect();
- ISize siz = ISize(rectClient.topRight()-rectIcon.topRight());
- ITRACE_DEVELOP(IString("Size is ")+IString(siz.sizeX())+IString(",")+IString(siz.sizeY()));
- container().scroll(siz.sizeY(), siz.sizeX());
- break;
- }
- case CNR_MOVE_CURSORED_TOPLEFT:
- {
- IMODTRACE_DEVELOP("Top Left");
- Customer* pcust = (Customer*)container().cursoredObject();
- IRectangle rectIcon = container().iconRectangle(pcust);
- IRectangle rectClient = container().rect();
- ISize siz = ISize(rectClient.topLeft()-rectIcon.topLeft());
- ITRACE_DEVELOP(IString("Size is ")+IString(siz.sizeX())+IString(",")+IString(siz.sizeY()));
- container().scroll(siz.sizeY(), siz.sizeX());
- break;
- }
- case CNR_MOVE_CURSORED_BOTRIGHT:
- {
- IMODTRACE_DEVELOP("Bottom Right");
- Customer* pcust = (Customer*)container().cursoredObject();
- IRectangle rectIcon = container().iconRectangle(pcust);
- IRectangle rectClient = container().rect();
- ISize siz = ISize(rectClient.bottomRight()-rectIcon.bottomRight());
- ITRACE_DEVELOP(IString("Size is ")+IString(siz.sizeX())+IString(",")+IString(siz.sizeY()));
- container().scroll(siz.sizeY(), siz.sizeX());
- break;
- }
- case CNR_MOVE_CURSORED_BOTLEFT:
- {
- IMODTRACE_DEVELOP("Bottom Left");
- Customer* pcust = (Customer*)container().cursoredObject();
- IRectangle rectIcon = container().iconRectangle(pcust);
- IRectangle rectClient = container().rect();
- ISize siz = ISize(rectClient.bottomLeft()-rectIcon.bottomLeft());
- ITRACE_DEVELOP(IString("Size is ")+IString(siz.sizeX())+IString(",")+IString(siz.sizeY()));
- container().scroll(siz.sizeY(), siz.sizeX());
- break;
- }
- default :
- return false;
- }
- return true;
- };
-
-
- /*--------------------------------------------------------*/
- /* Compare Customer names - for sorting. */
- /*--------------------------------------------------------*/
- long _System pfncompName(const Customer* p1,
- const Customer* p2,
- const IContainerControl* pcnrctl)
- {
- return (pcnrctl->nlsCompare(p1->customerName(),
- p2->customerName()));
- };
-
- /*--------------------------------------------------------*/
- /* Compare Customer Address - for sorting. */
- /*--------------------------------------------------------*/
- long _System pfncompAddress(const Customer* p1,
- const Customer* p2,
- const IContainerControl* pcnrctl)
- {
- return (pcnrctl->nlsCompare(p1->customerAddress(),
- p2->customerAddress()));
- };
-
- /*--------------------------------------------------------*/
- /* Compare Customer Phone - for sorting. */
- /*--------------------------------------------------------*/
- long _System pfncompPhone(const Customer* p1,
- const Customer* p2,
- const IContainerControl* pcnrctl)
- {
- return (pcnrctl->nlsCompare(p1->customerPhone(),
- p2->customerPhone()));
- };
-
- /*--------------------------------------------------------*/
- /* Compare Customer Age - for sorting. */
- /*--------------------------------------------------------*/
- long _System pfncompAge(const Customer* p1,
- const Customer* p2,
- const IContainerControl* pcnrctl)
- {
- if(p1->customerAge() > p2->customerAge())
- return 1;
- else if(p1->customerAge() < p2->customerAge())
- return -1;
- else
- return 0;
-
- };
-
-
- /*--------------------------------------------------------*/
- /* Filter Function - return TRUE for A-K */
- /*--------------------------------------------------------*/
- Boolean _System pfnfilterA_K(const Customer* pcust,
- const IContainerControl* pcnrctl)
- {
- Boolean fKeep = (pcnrctl->nlsCompare(pcust->customerName(), "L") < 0);
- return fKeep;
- }
-
- /*--------------------------------------------------------*/
- /* Filter Function - return TRUE for L-Z */
- /*--------------------------------------------------------*/
- Boolean _System pfnfilterL_Z(const Customer* pcust,
- const IContainerControl* pcnrctl)
- {
- Boolean fKeep = (pcnrctl->nlsCompare(pcust->customerName(), "K") > 0);
- return fKeep;
-
- }
- /*--------------------------------------------------------*/
- /* Filter Function - return TRUE for Age>30 */
- /*--------------------------------------------------------*/
- Boolean _System pfnfilterOver30(const Customer* pcust,
- const IContainerControl* pcnrctl)
- {
- Boolean fKeep = (pcust->customerAge() > 30);
- return fKeep;
-
- }
-