home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************/
- /* Sample Program for IBMCLASS */
- /* */
- /* CHANGE ACTIVITY: */
- /* DATE: INITIAL: DESCRIPTION */
- /* */
- /* 123091 KKL Modify for V2.0 classes */
- /**************************************************************/
- #include <iframe.hpp>
- #include <iapp.hpp>
- #include <irect.hpp>
- #include <ievtres.hpp>
- #include <ievent.hpp>
- #include <ihandler.hpp>
- #include <ientryfd.hpp>
- #include <istattxt.hpp>
- #include <idrgsrch.hpp>
- #include <idrgtgth.hpp>
- #include <idrgtxt.hpp>
- #include <idrgstr.hpp>
- #include <icmdhdr.hpp> // ITheCommand, ICommandHandler
- #include <iabmenu.hpp> // IActionBarMenu
-
- #include <istream.hpp>
-
- #include <itrace.hpp>
-
- #include "win.h"
-
- extern "C" {
- #define INCL_WIN
- #include <os2.h>
- }
-
-
- #define DDEFSRC
- #define DDEFTGT
-
- //#define MYEFSRC
- //#define MYEFTGT
-
- class MyEFHandler : public IDragSourceHandler
- {
- public:
- MyEFHandler(IEntryField* pef);
-
- protected:
- virtual Boolean dispatchHandlerEvent(IEvent& evt);
-
- };
-
- class MyWindow : public IFrameWindow, public ICommandHandler
- {
- public:
- MyWindow(unsigned long windowId, const IWindow* parentWindow,
- const IWindow* ownerWindow, const IRectangle& initialSize);
-
- protected:
- virtual Boolean command(ICommandEvent& cmdevt);
-
- private:
- IEntryField* pef;
- IStaticText* psttxtSrc1;
- IStaticText* psttxtSrc2;
- IStaticText* psttxtTgt;
- IDragSourceHandler* psrch1;
- IDragSourceHandler* psrch2;
- IDragTargetHandler* ptgth;
- IDropCatcher* pdrpcatch;
- IResourceLibrary reslib;
-
- IEntryField* pefSrc;
- #ifdef DDEFSRC
- IDragDropEFHandler* pddefhSrc;
- #else
- #ifdef MYEFSRC
- MyEFHandler* pmyefhSrc;
- #else
- IDragSourceHandler* psrchText;
- IDragWinTextItem* pdrgitmSrc;
- #endif
- #endif
- IEntryField* pefTgt;
- #ifdef DDEFTGT
- IDragDropEFHandler* pddefhTgt;
- #else
- #ifdef MYEFTGT
- MyEFHandler* pmyefhTgt;
- #else
- IDragTargetHandler* ptgthText;
- IDropWinTextCatcher* pdrpctchTgt;
- #endif
- #endif
-
- ITypesString* pstrtyp;
- IRMFsString* pstrrmf;
- };
-
- /**************************************************************/
- /* main() program entry point */
- /**************************************************************/
- void main()
- {
- MyWindow m(WND_MAIN,
- IWindow::desktopWindow(),
- IWindow::desktopWindow(),
- IRectangle());
-
- IApplication::current.run();
- }
-
- MyWindow::MyWindow( unsigned long windowId, const IWindow* parentWindow,
- const IWindow* ownerWindow, const IRectangle& initialSize)
- : IFrameWindow(windowId, parentWindow, ownerWindow, initialSize),
- reslib()
- {
-
- IMODTRACE_DEVELOP("MyWindow :: MyWindow");
-
- // set ourselves as event handler, since we multiple-inherit
- addHandler((IHandler *)this);
-
- // set main menu
- IActionBarMenu* pabmnMain=new IActionBarMenu(WND_MAIN,this);
-
- IResourceId resid100=IResourceId(100,reslib);
- IResourceId resid200=IResourceId(100,reslib);
-
- static const char* pszTyp= "DRGWIN_Test";
-
- IRMFsString strRMF=IRMFsString("DRM_DUMMY","DRF_DUMMY");
-
- ITRACE_DEVELOP(IString("strRMF=") + (IString)strRMF);
-
- pef = new IEntryField(1, this, this, IRectangle(50,50,550,90));
-
- // set source items
- psttxtSrc1= new IStaticText(2, this, this, IRectangle(50,100,550,140));
- psttxtSrc1->setText("This is a Drag Source - Single");
- psttxtSrc2= new IStaticText(3, this, this, IRectangle(50,150,550,190));
- psttxtSrc2->setText("This is a Drag Source - Double");
-
- // now set a source drag handler for this text
- psrch1=new IDragSourceHandler();
- psrch2=new IDragSourceHandler();
-
- // add an item to the set
- IDragImage* pdrgimage100=new IDragImage(resid100,ISize(0,0));
- IDragImage* pdrgimage200=new IDragImage(resid200,ISize(20,20));
-
- ITRACE_DEVELOP("Drag Images created");
-
- IDragItem* pdrgitem11= new IDragItem(psttxtSrc1,
- 0L,
- pszTyp, strRMF,
- IDragItem::copyable);
- pdrgitem11->setDragImage(pdrgimage100);
- psrch1->dragItemList().add(pdrgitem11);
-
- IDragItem* pdrgitem21= new IDragItem(psttxtSrc2,
- 0L,
- pszTyp, strRMF,
- IDragItem::copyable |
- IDragItem::moveable);
- IDragItem* pdrgitem22= new IDragItem(psttxtSrc2,
- 0L,
- pszTyp, strRMF,
- IDragItem::copyable |
- IDragItem::moveable);
-
- ITRACE_DEVELOP("Drag Items created");
-
- pdrgitem21->setDragImage(pdrgimage100);
- pdrgitem22->setDragImage(pdrgimage200);
-
- psrch2->dragItemList().add(pdrgitem21);
- psrch2->dragItemList().add(pdrgitem22);
-
- // set the handlers
- psttxtSrc1->addHandler(psrch1);
- psttxtSrc2->addHandler(psrch2);
-
- // create drop target
- psttxtTgt= new IStaticText(4, this, this, IRectangle(50,200,550,240));
- psttxtTgt->setText("This is a Drag Target for RMF="+IString(strRMF));
-
- ptgth= new IDragTargetHandler();
-
- // create drop catcher
- pdrpcatch= new IDropCatcher(pszTyp,strRMF);
- ptgth->dropCatcherList().add(pdrpcatch);
-
- // set the handler on the static text
- psttxtTgt->addHandler(ptgth);
-
- IEntryField* pefSrc=new IEntryField(1000, this, this, IRectangle(50,250,550,290));
- #ifdef DDEFSRC
- pefSrc->setText("Source & Target");
- IDragDropEFHandler* pddefhSrc = new IDragDropEFHandler(pefSrc);
- #else
- pefSrc->setText("Source Only");
- IDragSourceHandler* psrchText= new IDragSourceHandler(IDragSourceHandler::systemIcons);
-
- IDragWinTextItem* pdrgitmSrc= new IDragWinTextItem(pefSrc);
- psrchText->dragItemList().add(pdrgitmSrc);
- pefSrc->addHandler(psrchText);
- #endif
- ITRACE_DEVELOP(IString("(ul)pefSrc->handle()=") + IString((unsigned long)pefSrc->handle()));
- ITRACE_DEVELOP(IString("(ul)pefSrc=") + IString((unsigned long)pefSrc));
- ITRACE_DEVELOP(IString("pefSrc->text()") + pefSrc->text());
- ITextControl* ptxtctl=(ITextControl*)pefSrc;
- ITRACE_DEVELOP(IString("(ul)ptxtctl") + IString((unsigned long)ptxtctl));
- ITRACE_DEVELOP(IString("ptxtctl->text()") + ptxtctl->text());
-
- IEntryField* pefTgt=new IEntryField(1001, this, this, IRectangle(50,300,550,340));
- #ifdef DDEFTGT
- pefTgt->setText("Source & Target");
- IDragDropEFHandler* pddefhTgt = new IDragDropEFHandler(pefTgt);
- #else
- pefTgt->setText("Target Only");
- IDragTargetHandler* ptgthText= new IDragTargetHandler();
-
- IDropWinTextCatcher* pdrpctchTgt= new IDropWinTextCatcher(pefTgt);
- pefTgt->addHandler(ptgthText);
- ptgthText->dropCatcherList().add(pdrpctchTgt);
- #endif
-
- pstrtyp=0;
-
- // show our frame
- show();
- }
-
- /**************************************************************************/
- /* MyWindow :: command PHG 10/09 */
- /* Handle menu commands */
- /**************************************************************************/
- Boolean MyWindow :: command(ICommandEvent& cmdevt)
- {
- switch(cmdevt.commandId()) {
- case MI_DRGSTR_TYP_CT:
- {IString strEF=pef->text();
-
- ITypesString strtyp(strEF);
-
- psttxtSrc1->setText((IString)strtyp);
- }
- break;
-
- case MI_DRGSTR_TYP_CNT:
- if(pstrtyp!=0) {
- psttxtSrc2->setText(IString(pstrtyp->count()));
- } else {
- psttxtSrc2->setText("?");
- }
- break;
-
- case MI_DRGSTR_TYP_IDX:
- if(pstrtyp!=0) {
- unsigned uEF=(pef->text()).asUnsigned();
- psttxtSrc2->setText(pstrtyp->type(uEF));
- } else {
- psttxtSrc2->setText("?");
- }
- break;
-
- case MI_DRGSTR_TYP_TRUE:
- if(pstrtyp!=0) {
- psttxtSrc2->setText(pstrtyp->trueType());
- } else {
- psttxtSrc2->setText("?");
- }
- break;
-
- case MI_DRGSTR_TYP_VERT:
- if(pstrtyp!=0) {
- IString strEF=pef->text();
-
- ITypesString strtyp=ITypesString(strEF);
- psttxtSrc2->setText(IString(pstrtyp->verifyTrueType(strtyp)));
- } else {
- psttxtSrc2->setText("?");
- }
- break;
-
- case MI_DRGSTR_RMF_CT:
- {IString strEF=pef->text();
-
- IRMFsString strrmf(strEF);
-
- psttxtSrc1->setText((IString)strrmf);
- }
- break;
-
- case MI_DRGSTR_RMF_CNT:
- if(pstrrmf!=0) {
- psttxtSrc2->setText(IString(pstrrmf->count()));
- } else {
- psttxtSrc2->setText("?");
- }
- break;
-
- case MI_DRGSTR_RMF_IDX:
- if(pstrrmf!=0) {
- unsigned uEF=(pef->text()).asUnsigned();
- psttxtSrc2->setText(pstrrmf->RMF(uEF));
- } else {
- psttxtSrc2->setText("?");
- }
- break;
-
- case MI_DRGSTR_RMF_NATV:
- if(pstrrmf!=0) {
- psttxtSrc2->setText(pstrrmf->nativeRMF());
- } else {
- psttxtSrc2->setText("?");
- }
- break;
-
- case MI_DRGSTR_RMF_VERN:
- if(pstrrmf!=0) {
- IString strEF=pef->text();
-
- IRMFsString strrmf=IRMFsString(strEF);
- psttxtSrc2->setText(IString(pstrrmf->verifyNativeRMF(strrmf)));
- } else {
- psttxtSrc2->setText("?");
- }
- break;
-
-
- }/* end switch */
-
- return(0);
- }/* end MyWindow :: command(...) */