home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
odtlktv4.zip
/
ODTLKT
/
TOOLKIT
/
BETA
/
SAMPLES
/
OPENDOC
/
PARTS
/
CNTNRPRT
/
CNNOTEBK.CPP
next >
Wrap
Text File
|
1995-11-29
|
13KB
|
402 lines
/*
* This file was generated by the SOM Compiler and Emitter Framework.
* Generated using:
* SOM Emitter emitxtm: 2.41
*/
/* File: Cnnotebk.cpp
*
* Contains: Implementation for Container Part's notebook
*
* Written by: The OpenDoc Development Team
*
* Copyright: (c) 1995 by IBM Corp., all rights reserved.
*
* Change History (most recent first):
*
* 137691 11/28/95 ced Fix up exception handling
* 143378 11/14/95 BLG mod AddNotebookPages() added removeNotebookPage()
* 127364 9/28/95 BLG Insert view pages for containers - AddNotebookPages.
* 137002 9/15/95 jso Updated to follow base cntnrpr specs
*/
#ifndef _EXCEPT_
#include "Except.h"
#endif
#ifndef SOM_Module_cnnotebk_Source
#define SOM_Module_cnnotebk_Source
#endif
#define CNNotebook_Class_Source
#define VARIABLE_MACROS
#define INCL_WINHELP
#define INCL_DOS
#define INCL_WINPOINTERS
#define INCL_WINFRAMEMGR
#define INCL_WINWINDOWMGR
#define INCL_WIN
#define INCL_GPI
#define INCL_WPCLASS
#define INCL_ODFRAME
#define INCL_ODPART
#define INCL_ODAPI
#define INCL_GPIPOLYGON
#define INCL_ODFACET
#include <os2.h>
#ifndef _CNTMRI_
#include "cntmri.h"
#endif
#define WM_FOCUS_PROCESSING WM_USER + 1
#ifndef _ORDCOLL_
#include "OrdColl.h"
#endif
#include "cnnotebk.xih"
#ifndef _CNTNRPRT_
#include "Cntnrprt.xih"
#endif
/*********************************/
/* globals */
/*********************************/
typedef struct _LISTDATA
{
ContainerPart * realPart;
ODPart * partWrapper;
ULONG origColor;
ULONG currColor;
} COLORDATA;
typedef COLORDATA *PCOLORDATA;
#define WM_FOCUS_PROCESSING WM_USER + 1
/*********************************/
/* prototypes */
/*********************************/
extern "C" {
MPARAM EXPENTRY ColorPageDlgProc(
HWND hwnd,
USHORT msg,
MPARAM mp1,
MPARAM mp2);
}
/**********************************************************************\
* FUNCTION: ColorPageDlgProc
*
* DESCRIPTION: Dialog procedure for the Color Page
*
*
\**********************************************************************/
MPARAM EXPENTRY ColorPageDlgProc(
HWND hwnd,
USHORT msg,
MPARAM mp1,
MPARAM mp2)
{
MRESULT mresReply;
PCOLORDATA pColorData;
Environment * ev;
ev = somGetGlobalEnvironment();
ODFrame * displayFrame;
/* Get the data for this notebook
*/
switch(msg)
{
case WM_INITDLG:
{
pColorData = new COLORDATA;
/* a pointer to the notebook is set inside the bookinfo structure which is stored
* in the window words. Get in order to access part methods. Note that the Part
* part wrapper should always be the notebook extensions base.
*/
ODULong initColor = 0;
SOM_TRY
ODSettingsExtension * notebook = (ODSettingsExtension *) mp2;
pColorData->partWrapper = (ODPart *)notebook->GetBase(ev);
pColorData->realPart = (ContainerPart *) pColorData->partWrapper->GetRealPart(ev);
/* Get the original backfround color for undo */
initColor = pColorData->realPart->GetBGColor(ev);
SOM_CATCH_ALL
return 0;
SOM_ENDTRY
if(!initColor)
{
pColorData->origColor = pColorData->currColor = IDMA_COLOR_WHITE;
}
else
{
/* select the appropriate color */
switch(initColor)
{
case CLR_DARKGRAY:
pColorData->origColor = IDMA_COLOR_GRAY;
break;
case CLR_RED:
pColorData->origColor = IDMA_COLOR_RED;
break;
case CLR_GREEN:
pColorData->origColor = IDMA_COLOR_GREEN;
break;
case CLR_YELLOW:
pColorData->origColor = IDMA_COLOR_YELLOW;
break;
case CLR_BLUE:
pColorData->origColor = IDMA_COLOR_BLUE;
break;
case CLR_DARKPINK:
pColorData->origColor = IDMA_COLOR_MAGENTA;
break;
case CLR_CYAN:
pColorData->origColor = IDMA_COLOR_CYAN;
break;
case CLR_WHITE:
default:
pColorData->origColor = IDMA_COLOR_WHITE;
break;
}
pColorData->currColor = pColorData->origColor;
}
/* store the kind name in the listbox reserved memory area */
WinSetWindowULong( hwnd, 0, (ULONG)pColorData);
WinSendMsg(WinWindowFromID(hwnd, pColorData->origColor), BM_CLICK,
MPFROMSHORT(FALSE), 0);
}
case WM_CONTROL:
{
switch (SHORT2FROMMP(mp1))
{
case BN_CLICKED:
{
ODULong whichColor = 0;
USHORT usCheckId = SHORT1FROMMP(mp1);
switch (usCheckId)
{
case IDMA_COLOR_GRAY:
whichColor = IDMA_COLOR_GRAY;
break;
case IDMA_COLOR_RED:
whichColor = IDMA_COLOR_RED;
break;
case IDMA_COLOR_GREEN:
whichColor = IDMA_COLOR_GREEN;
break;
case IDMA_COLOR_YELLOW:
whichColor = IDMA_COLOR_YELLOW;
break;
case IDMA_COLOR_BLUE:
whichColor = IDMA_COLOR_BLUE;
break;
case IDMA_COLOR_MAGENTA:
whichColor = IDMA_COLOR_MAGENTA;
break;
case IDMA_COLOR_CYAN:
whichColor = IDMA_COLOR_CYAN;
break;
case IDMA_COLOR_WHITE:
whichColor = IDMA_COLOR_WHITE;
break;
} /* end switch */
pColorData = (PCOLORDATA)WinQueryWindowULong(hwnd, 0L);
if(whichColor != pColorData->currColor)
{
pColorData->currColor = whichColor;
SOM_TRY
ContainerPartData * somThis = ContainerPartGetData(pColorData->realPart);
displayFrame = (ODFrame *) somThis->fDisplayFrames->First();
pColorData->realPart->HandleColorMenu(ev, displayFrame, whichColor);
displayFrame->Invalidate(ev, kODNULL, kODNULL);
SOM_CATCH_ALL
SOM_ENDTRY
return (MPARAM)0;
}
}
}
break;
}
case WM_COMMAND:
{
switch (SHORT1FROMMP(mp1))
{
case DID_UNDO:
{
pColorData = (PCOLORDATA)WinQueryWindowULong(hwnd, 0L);
WinSendMsg(WinWindowFromID(hwnd, pColorData->origColor), BM_CLICK,
MPFROMSHORT(FALSE), 0);
return (MPARAM)0;
}
case DID_DEFAULT:
{
WinSendMsg(WinWindowFromID(hwnd, IDMA_COLOR_WHITE), BM_CLICK,
MPFROMSHORT(FALSE), 0);
return (MPARAM)0;
}
}
}
case WM_FOCUSCHANGE:
/* On a focus change, we will post a message to process all of the
* changes to stuff. We don't want to do it here, because if a
* method displays an error message, we can't switch focus to the
* message and will hang.
*/
WinPostMsg(hwnd, WM_FOCUS_PROCESSING, mp1, mp2);
return WinDefDlgProc( hwnd, msg, mp1, mp2);
case WM_FOCUS_PROCESSING:
return (MPARAM)0;
case WM_DESTROY:
{
/* save everything, as the post by the WM_FOCUSCHANGE message
* will not get processed before this message kills the dialog.
*/
WinSendMsg(hwnd, WM_FOCUS_PROCESSING, mp1, mp2);
pColorData = (PCOLORDATA)WinQueryWindowULong(hwnd, 0L);
if(pColorData->realPart)
SOM_TRY
pColorData->partWrapper->ReleaseRealPart(ev);
SOM_CATCH_ALL
SOM_ENDTRY
if(pColorData)
delete pColorData;
return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
default:
/* Pass all unprocessed messages to the default dialog proc.
*/
return WinDefDlgProc( hwnd, msg, mp1, mp2);
}
}
SOM_Scope ODULong SOMLINK CNNotebookInsertBackgroundPage(CNNotebook *somSelf,
Environment *ev,
HWND hwndNotebook)
{
CNNotebookData *somThis = CNNotebookGetData(somSelf);
CNNotebookMethodDebug("CNNotebook","CNNotebookInsertBackgroundPage");
/*
* Called by AddNotebookPages to insert the Part-Properties Background
* page. The user can then modify the parts background color.
* It in turn calls InsertNotebookPage.
* Returns: The pageid for the inserted page.
*
* Note: It is helpful to send a pointer to the settings extension in
* the create parameters so that the dialog procedure can
* get access to the part's methods.
*/
PAGEINFO pageinfo;
CHAR LoadError[100];
APIRET rc = DosLoadModule(LoadError, sizeof(LoadError),
"CNTMRI", &_hmodHandle);
memset( (PCH)&pageinfo, 0, sizeof( PAGEINFO ) );
pageinfo.cb = sizeof(PAGEINFO);
pageinfo.usPageStyleFlags = BKA_MAJOR;
pageinfo.usPageInsertFlags = BKA_FIRST;
pageinfo.pfnwp = (PFNWP)ColorPageDlgProc;
pageinfo.resid = _hmodHandle;
pageinfo.dlgid = DL_COLORS;
pageinfo.pszName = "Background";
pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
pageinfo.pCreateParams = (PVOID)somSelf; /* Let dialog know what object */
return somSelf->InsertNotebookPage(ev, hwndNotebook, &pageinfo );
}
SOM_Scope ODULong SOMLINK CNNotebookAddNotebookPages(CNNotebook *somSelf,
Environment *ev,
HWND hwndNotebook,ODULong flPageFlag, ODULong ulReserve)
{
CNNotebookData *somThis = CNNotebookGetData(somSelf);
CNNotebookMethodDebug("CNNotebook","CNNotebookAddNotebookPages");
SOM_TRY
/* This method will add the background page behind the standard pages
*/
somSelf->InsertBackgroundPage(ev, hwndNotebook);
/* insert all pages here to include container pages in proper order. 127364*/
// somSelf->InsertGeneralPage(ev, hwndNotebook);
// somSelf->InsertFilePage2(ev, hwndNotebook);
// somSelf->InsertFilePage1(ev, hwndNotebook);
//
// somSelf->InsertDetailsViewPage(ev, hwndNotebook); // pages for containers
// somSelf->InsertTreeViewPage(ev, hwndNotebook); // "
// somSelf->InsertIconViewPage(ev, hwndNotebook); // "
//
// somSelf->InsertViewPage(ev, hwndNotebook);
// somSelf->InsertTypePage(ev, hwndNotebook);
CNNotebook_parent_ODSettingsExtension_AddNotebookPages(somSelf, ev,
hwndNotebook, flPageFlag|kODFolderViewPages,ulReserve);
// somSelf->RemoveNotebookPages(ev,hwndNotebook, kODViewPage);
SOM_CATCH_ALL
SOM_ENDTRY
return flPageFlag;
}
SOM_Scope void SOMLINK CNNotebooksomInit(CNNotebook *somSelf)
{
CNNotebookData *somThis = CNNotebookGetData(somSelf);
CNNotebookMethodDebug("CNNotebook","CNNotebooksomInit");
CNNotebook_parent_ODSettingsExtension_somInit(somSelf);
_hmodHandle = 0;
}
SOM_Scope void SOMLINK CNNotebooksomUninit(CNNotebook *somSelf)
{
CNNotebookData *somThis = CNNotebookGetData(somSelf);
CNNotebookMethodDebug("CNNotebook","CNNotebooksomUninit");
DosFreeModule(_hmodHandle);
CNNotebook_parent_ODSettingsExtension_somUninit(somSelf);
}