Led 3.0 Class Library Documentation

Module Led_MFC


Classes and Global Functions Index

Module Description:

Led MFC specific wrappers.

As of Led 2.3, MFC is the only well supported way to use Led for Win32 (MS Windows). There are small, but definite MFC assumptions sprinkled throughout the rest of Led. About 99% of them are here. And in future releases ALL will be here (so its easier to use Led on Win32 with other class libraries).

Note that since MFC provides no abstract base classes for implementing editor-like behavior, Led cannot subclass from CEdit or CEditView.

Also - for some purposes, it would be better to inherit from CWnd. And for others, better to inherit from CView. Versions of Led prior to Led 2.3 inherited from CView.

Now - through the magic of templates - Led supports (almost) any MFC base class (at least CView and CWnd) for a Led-based editor, so long as it supports at least the functionality of CWnd/CView.

The current Led sample applications (LedIt! and LedLineIt! all use Led inheriting from a CView, and that is necessary to get the OLE/embedding funcitonality built in. But Led has also been tested as a replacemnt edit control inheriting from CWnd (@LEC).


Class: LED_MFC_HANDLE_COMMAND [public]

Description:

Trivial helper for building MFC message maps.


Class: LED_MFC_HANDLE_COMMAND_RANGE [public]

Description:

Trivial helper for building MFC message maps.


Class: Led_MFC [public]

Base Classes: Led_MFC_CViewHelper < BASECLASS > , where BASECLASS=Led_MFC_OptionalWin32SDKMessageMimicHelper < BASECLASS > , where BASECLASS=@Led_MFC_MimicMFCAPIHelper < BASECLASS > ', where BASECLASS == Led_MFC_Helper < BASECLASS > , where BASECLASS=CView
Description:

This template is provided partly as a convenience, for such a common case. But MOSTLY as backwards compatability for Led 2.2. In Led 2.2, Led_MFC was the SOLE class provided to integrated Led with MFC. Now there is a whole suite of individually selectable templates to provide that interfacing.


Class: Led_MFCReaderDAndDFlavorPackage [public]

Base Classes: ReaderFlavorPackage
Description:

ReaderFlavorPackage which reads from a COleDataObject as its underlying storage. Useful for Drop (Drag and Drop) processing.


Class: Led_MFCWriterDAndDFlavorPackage [public]

Base Classes: WriterFlavorPackage
Description:

A WriterFlavorPackage which writes to a COleDataObject as its underlying storage. Useful for Drag (Drag and Drop) processing.


Class: Led_MFC_COleControlHelper < BASECLASS > [public]

Base Classes: BASECLASS
Description:

NB: BASECLASS must derive (possibly indirectly) from CView.

To use this class, you must also define DoDeclare_Led_MFC_COleControlHelper_MessageMap() to declare the actual message map for the template (unless its already done for yours in Led_MFC.cpp).


Class: Led_MFC_CViewHelper < BASECLASS > [public]

Base Classes: BASECLASS
Description:

NB: BASECLASS must derive (possibly indirectly) from CView.

To use this class, you must also define DoDeclare_Led_MFC_CViewHelper_MessageMap() to declare the actual message map for the template (unless its already done for yours in Led_MFC.cpp).

Member Details

Led_MFC_CViewHelper < BASECLASS > ::CalculatePrintingRect [public]

Led_Rect Led_MFC_CViewHelper < BASECLASS > ::CalculatePrintingRect (CDC* pDC) const

Hook function to change the default size Led will use for printing. Defautlts to FULL page. Override to inset for margins, and/or headers/footers.

Don't call directly. Just called after DC setup from Led_MFC_CViewHelper::OnPrepareDC.

Led_MFC_CViewHelper < BASECLASS > ::DeleteContents [public]

void Led_MFC_CViewHelper < BASECLASS > ::DeleteContents ()

Hook the MFC DeleteContents () routine, and simulate the user having deleted all the text in the buffer.

Led_MFC_CViewHelper < BASECLASS > ::OnBeginPrinting [public]

void Led_MFC_CViewHelper < BASECLASS > ::OnBeginPrinting (CDC* pDC, CPrintInfo* pInfo)

Hook the MFC OnBeginPrinting () method to handle printing in the standard MFC fasion. Also, keep track of some internals we will use later in printing, and setup SetForceAllRowsShowing so when we print the last page, we can see lots of nice whatspace at the end. Don't call this directly.

Led_MFC_CViewHelper < BASECLASS > ::OnDraw [public]

void Led_MFC_CViewHelper < BASECLASS > ::OnDraw (CDC* pDC)

Hook the MFC OnDraw () method to invoke the Led drawing mechanism, and redisplay the window.

Led_MFC_CViewHelper < BASECLASS > ::OnPreparePrinting [public]

BOOL Led_MFC_CViewHelper < BASECLASS > ::OnPreparePrinting (CPrintInfo* pInfo)

Hook the MFC OnPreparePrinting () method to handle printing in the standard MFC fasion. Don't call this directly.

Led_MFC_CViewHelper < BASECLASS > ::UpdateScrollBars [public]

void Led_MFC_CViewHelper < BASECLASS > ::UpdateScrollBars ()

Avoid errors updating sbars while printing.

Class: Led_MFC_DragAndDropWindow < BASECLASS > [public]

Base Classes: BASECLASS
Description:

NB: BASECLASS must derive (possibly indirectly) from CWnd.

To use this class, you must also define DoDeclare_Led_MFC_DragAndDropWindow_MessageMap() to declare the actual message map for the template (unless its already done for yours in Led_MFC.cpp).

Probably eventually migrate more stuff from Led_MFC_CViewHelper here to this class. But for now, I'm risk averse. I don't want to break the class library. And this is all that is needed to move out to meet the immediate complaints.

Member Details

Led_MFC_DragAndDropWindow < BASECLASS > ::GetCommandNames [public]

const Led_MFC_DragAndDropWindow < BASECLASS > ::CommandNames& Led_MFC_DragAndDropWindow < BASECLASS > ::GetCommandNames ()

Returns command name for each of the user-visible commands produced by this module. This name is used used in the constructed Undo command name, as in, "Undo Drag and Drop". You can replace this name with whatever you like.You change this value with WordProcessor::SetCommandNames.

The point of this is to allow for different UI-language localizations, without having to change Led itself.

See also Led_MFC_DragAndDropWindow::CommandNames.

Led_MFC_DragAndDropWindow < BASECLASS > ::GetDragCommandName [public]

const Led_SDK_String& Led_MFC_DragAndDropWindow < BASECLASS > ::GetDragCommandName ()

Returns command name for the 'Drag' command. This name is used used in the constructed Undo command name, as in, "Undo Drag". You can replace this name with whatever you like.You change this value with Led_MFC_DragAndDropWindow::SetDragCommandName.

The point of this is to allow for different UI-language localizations, without having to change Led itself.

Led_MFC_DragAndDropWindow < BASECLASS > ::GetDragNDropCommandName [public]

const Led_SDK_String& Led_MFC_DragAndDropWindow < BASECLASS > ::GetDragNDropCommandName ()

Returns command name for the 'Drag and Drop' command. This name is used used in the constructed Undo command name, as in, "Undo Drag and Drop". You can replace this name with whatever you like.You change this value with Led_MFC_DragAndDropWindow::SetDragNDropCommandName.

The point of this is to allow for different UI-language localizations, without having to change Led itself.

Led_MFC_DragAndDropWindow < BASECLASS > ::GetDropCommandName [public]

const Led_SDK_String& Led_MFC_DragAndDropWindow < BASECLASS > ::GetDropCommandName ()

Returns command name for the 'Drop' command. This name is used used in the constructed Undo command name, as in, "Undo Drop". You can replace this name with whatever you like.You change this value with Led_MFC_DragAndDropWindow::SetDropCommandName.

The point of this is to allow for different UI-language localizations, without having to change Led itself.

Led_MFC_DragAndDropWindow < BASECLASS > ::SetCommandNames [public]

void Led_MFC_DragAndDropWindow < BASECLASS > ::SetCommandNames (const Led_MFC_DragAndDropWindow < BASECLASS > ::CommandNames& cmdNames)

See Led_MFC_DragAndDropWindow::GetCommandNames.

Led_MFC_DragAndDropWindow < BASECLASS > ::SetDragCommandName [public]

void Led_MFC_DragAndDropWindow < BASECLASS > ::SetDragCommandName (const Led_SDK_String& cmdName)

See Led_MFC_DragAndDropWindow::GetDragCommandName.

Led_MFC_DragAndDropWindow < BASECLASS > ::SetDragNDropCommandName [public]

void Led_MFC_DragAndDropWindow < BASECLASS > ::SetDragNDropCommandName (const Led_SDK_String& cmdName)

See Led_MFC_DragAndDropWindow::GetDragNDropCommandName.

Led_MFC_DragAndDropWindow < BASECLASS > ::SetDropCommandName [public]

void Led_MFC_DragAndDropWindow < BASECLASS > ::SetDropCommandName (const Led_SDK_String& cmdName)

See Led_MFC_DragAndDropWindow::GetDropCommandName.

Class: Led_MFC_DragAndDropWindow < BASECLASS > ::CommandNames [public]

Description:

Command names for each of the user-visible commands produced by the TextInteractor module. This name is used used in the constructed Undo command name, as in, "Undo Drag and Drop". You can replace this name with whatever you like. You change this value with TextInteractor::SetCommandNames.

The point of this is to allow for different UI-language localizations, without having to change Led itself.

See also Led_MFC_DragAndDropWindow::GetCommandNames.

See also TextInteractor::CommandNames.

Note - also - this class must be declared lexically inside the outer template -and not outside - do to compiler bugs with MSVC60(SP4). Didn't take the time to trace them down carefully - LGP 2000-08-19.


Class: Led_MFC_ExceptionHandlerHelper < BASECLASS > [public]

Base Classes: BASECLASS = Led_MFC_Helper < MFC_BASE_CLASS,BASE_INTERACTOR >
Description:

This helper is designed to manage exception handling, when the Led class is being used in a context (say OCX) where it cannot throw exceptions in error situations.

This class wraps many messages the control is likely to get, and when there is an exception, it calls a virtual exception-handling method (which by default - beeps), and then returns normally.

To use this class, you must also define DoDeclare_Led_MFC_ExceptionHandlerHelper_MessageMap() to declare the actual message map for the template.

Member Details

Led_MFC_ExceptionHandlerHelper < BASECLASS > ::HandleException [public]

void Led_MFC_ExceptionHandlerHelper < BASECLASS > ::HandleException () const

Override this to provide different exception handling. By default, this calls Led_BeepNotify.

Class: Led_MFC_Helper < MFC_BASE_CLASS,BASE_INTERACTOR > [public]

Base Classes: MFC_BASE_CLASS = CWnd, Led_Win32_Helper < BASE_INTERACTOR > , BASE_INTERACTOR = TextInteractor
Description:

There are two obvious ways to hook into MFC. One is to create a subclass of CWnd. The other is to create a subclass of CView. Because CView inherits from CWnd, but not virtually, you are strongly encouraged to pick one or the other. Alas - neither is really a good choice for ALL applications. For a big, main view, associated with a document, you want to subclass from CView. For a little control (as in a dialog), you want to subclass from CWnd.

This template makes it easier (soon easy, but for now, just easier) to subclass from either one. The default one, and the one Led mainly uses is CView. But soon I'll support (better) subclassing from CWnd.

NB: You must invoke the macro DoDeclare_Led_MFC_Helper_MessageMap(MFC_BASE_CLASS, BASE_INTERACTOR) to generate the code for the message map for this template, unless its already been done so for your particular MFC_BASE_CLASS in Led_MFC.cpp.

Member Details

Led_MFC_Helper < MFC_BASE_CLASS,BASE_INTERACTOR > ::GetWindowRect [public]

Led_Rect Led_MFC_Helper < MFC_BASE_CLASS,BASE_INTERACTOR > ::GetWindowRect () const

Return the Led WindowRect. This name is a somewhat unfortunate choice for Windows, because WindowRect means something vaguely similar, but substantially different in the Win32 SDK.

In the future, I may need to consider changing this name. But for now, I can think of none better.

I provide two overloads of this routine. The one that returns a Led_Rect returns the Led WindowRect. And the one that takes an LPRECT parameter returns the Win32 SDK WindowRect.

Led_MFC_Helper < MFC_BASE_CLASS,BASE_INTERACTOR > ::OnSetCursor [public]

BOOL Led_MFC_Helper < MFC_BASE_CLASS,BASE_INTERACTOR > ::OnSetCursor (CWnd* pWnd, UINT nHitTest, UINT message)

Hook the Win32 SDK WM_SETCURSOR message to handle set the cursor to an I-Beam, as appropriate. When over draggable text, instead use a standard arrow cursor.

Class: Led_MFC_MimicMFCAPIHelper < BASECLASS > [public]

Base Classes: BASECLASS = Led_MFC_Helper < MFC_BASE_CLASS,BASE_INTERACTOR >
Description:

Mimicry of the MFC CEdit methods - to facilitate using this class in place of any existing CEdit usage. These methods simply do send-message calls just as their CEdit counterparts. Then messages are then trapped in the OnMsgXXX handlers.

NB: Use of this class almost ALWAYS requires also mixing in the template Led_MFC_OptionalWin32SDKMessageMimicHelper. since that is what (by default) implements the OnMsgXXX helpers.

NB: You must invoke the macro DoDeclare_Led_MFC_MimicMFCAPIHelper_MessageMap(BASECLASS) somewhere to generate the message map code for this template, unless thats already been done for your particular BASECLASS in Led_MFC.cpp.


Class: Led_MFC_OptionalWin32SDKMessageMimicHelper < BASECLASS > [public]

Base Classes: BASECLASS = Led_MFC_Helper < MFC_BASE_CLASS,BASE_INTERACTOR >
Description:

Mimicry of the starndard Win32 messages sent to an edit control. We cannot mimic ALL the messages. Some just don't make sense (like GETHANDLE). But for those that do, we do our best.

NB: You must declare DoDeclare_Led_MFC_OptionalWin32SDKMessageMimicHelper_MessageMap (BASECLASS) to get the message map for this class generated, unless this has already been done in Led_MFC.cpp (for your particular BASECLASS).


Class: Led_MFC_TabletFromCDC [public]

Description:

Helper class to convert an MFC CDC to a Led_Tablet. Just creates a temporary wrapper.

Caution: You must create a NAMED temporary. A named temporary has lifetime til the end of the enclosing scope. An unnamed temporary has lifetime only til the next sequence point (less or equal to the rest of the current statement - I believe).


Class: Led_MFC_TmpCDCFromTablet [public]

Description:

Helper class to convert a Led_Tablet to an MFC CDC. Just creates a temporary wrapper.

Caution: You must create a NAMED temporary. A named temporary has lifetime til the end of the enclosing scope. An unnamed temporary has lifetime only til the next sequence point (less or equal to the rest of the current statement - I believe).


Class: Led_MFC_TmpCmdUpdater [public]

Description:

Helper used in WordProcessorCommonCommandHelper


Class: Led_MFC_X [public]

Base Classes: ChosenInteractor, Led_MFC
Description:

Utility template to mix together Led_MFC an a ChosenInteractor which already has support for a particular TextImager mixed in.


Class: TextInteractorCommonCommandHelper_MFC < BASECLASS,CMD_INFO,CMD_ENABLER > [public]

Base Classes: BASECLASS
Description:

See also WordProcessorCommonCommandHelper, and WordProcessorCommonCommandHelper_MFC.

To use this class, you must also define DoDeclare_TextInteractorCommonCommandHelper_MFC_MessageMap() to declare the actual message map for the template (unless its already done for yours in Led_MFC.cpp).

NB: This template is important because it hooks in the class library/SDK (in this case MFC) command dispatch metchanism into Led's.


Config Variable: qGenerateStandardMFCExceptions [public]

Description:

MFC apps generally throw AfxMemoryException () etc for internal exceptions. And there are standard MFC catchers for these types. To make Led utilize the Led_Set_OutOfMemoryException_Handler etc mechanism to use the MFC exception types - define this to TRUE. To use more standard Standard C++ or your own types - you may wish to shut this off.

Defaults to ON.


Config Variable: qLedAssertsDefaultToMFCAsserts [public]

Description:

By default when using MFC, make the Led asserts fall-thru into the default MFC assertion code. Some customers have indicated they prefer this (spr#0424).

Originally I made this default to TRUE, as the SPR requested. But I personally find the MFC Assert stuff a major pain in the donkey. Whenever you get an assert due to a display bug, it brings up a dialog, and dimissing that alert triggers (due to extra redisplay) extra re-enters into the same code which had the assert doing displays.

Since it was requested, I'll continue to make it easy for others to turn this on. But I leave it off by default.


Config Variable: qSupportDrawTextGetTextExtent [public]

Description:

Turn OFF by default (because requires including SimpleTextStore and SimpleTextImager and WordWrappedTextImager in your projects - which you may not want to do). See Led_DrawText and Led_GetTextExtent.


AsCPoint [public]

CPoint AsCPoint (Led_Point p)

Convert a Led_Point to an MFC CPoint.

See also AsLedPoint, AsCRect, AsLedRect.


AsCRect [public]

CRect AsCRect (Led_Rect r)

Convert a Led_Rect to an MFC CRect.

See also AsCPoint, AsLedPoint, AsLedRect.


AsCSize [public]

CSize AsCSize (Led_Size s)

Convert a Led_Size to an MFC CSize.

AsLedPoint [public]

Led_Point AsLedPoint (CPoint p)

Convert an MFC CPoint to a Led_Point.

See also AsCPoint, AsCRect, AsLedRect.


AsLedRect [public]

Led_Rect AsLedRect (CRect r)

Convert an MFC CRect to a Led_Rect.

See also AsCPoint, AsLedPoint, AsCRect.


Led_DrawText [public]

void Led_DrawText (CDC* cdc, const Led_tString& text, CRect r, bool wordWrap)

Instantiate Led_DrawText.

See also @qSupportDrawTextGetTextExtent', Led_GetTextExtent, Led_DrawText.


Led_DrawText < TRIVIALWORDWRAPPEDTEXTIMAGER,SIMPLETEXTIMAGER,TEXTSTORE > [public]

template < class TRIVIALWORDWRAPPEDTEXTIMAGER, class SIMPLETEXTIMAGER, class TEXTSTORE >

Trivial wrapper on TrivialImager etc, except it handles case of word wrapping as a parameter. So this is roughly a replacement for the Win32 SDK routine DrawText () - except its implemented by Led (and so UNICODE friendly, for example).

Note - this is done as a template - rather than directly as a function - so as to avoid forcing people who include Led_MFC from also including all these other modules required for this. There is a global function version of this function (Led_DrawText) which will be enabled/included in your program if you define qSupportDrawTextGetTextExtent.

See also Led_GetTextExtent


Led_GetTextExtent [public]

CSize Led_GetTextExtent (CDC* cdc, const Led_tString& text, CRect r, bool wordWrap)

Instantiate Led_GetTextExtent.

See also @qSupportDrawTextGetTextExtent', Led_DrawText, Led_GetTextExtent.


Led_GetTextExtent < TRIVIALWORDWRAPPEDTEXTIMAGER,SIMPLETEXTIMAGER,TEXTSTORE > [public]

template < class TRIVIALWORDWRAPPEDTEXTIMAGER, class SIMPLETEXTIMAGER, class TEXTSTORE >

Trivial wrapper on TrivialImager etc, except it handles case of word wrapping as a parameter. So this is roughly a replacement for the Win32 SDK routine GetTextExtent() - except its implemented by Led (and so UNICODE friendly, for example).

Note - this is done as a template - rather than directly as a function - so as to avoid forcing people who include Led_MFC from also including all these other modules required for this. There is a global function version of this function (Led_GetTextExtent) which will be enabled/included in your program if you define qSupportDrawTextGetTextExtent.

See also Led_DrawText


Return to Led Page Return to Led ClassLib Documentation Index Return to Led Reference Manual Index
Last Updated 2001-10-20