home *** CD-ROM | disk | FTP | other *** search
- // ===========================================================================
- // CFastTextEdit.cp ⌐1993 Metrowerks Inc. All rights reserved.
- // ===========================================================================
- //
- // ### Still under moderate construction
- // * Doesn't autoscroll while typing or selecting
- // * Doesn't adjust to display whole lines
- // * Doesn't undo
-
- #ifdef PowerPlant_PCH
- #include PowerPlant_PCH
- #endif
-
- #include "CFastTextEdit.h"
-
- #include <LStream.h>
- #include <UTextTraits.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <UKeyFilters.h>
- #include <PP_KeyCodes.h>
- #include <PP_Messages.h>
-
- #ifndef __SCRAP__
- #include <Scrap.h>
- #endif
-
- #ifndef __SCRIPT__
- #include <Script.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
-
- // ---------------------------------------------------------------------------
- // Ñ CreateTextEditStream
- // ---------------------------------------------------------------------------
- // Create a new TextEdit object from the data in a Stream
-
- CFastTextEdit*
- CFastTextEdit::CreateFastTextEditStream(
- LStream *inStream)
- {
- return (new CFastTextEdit(inStream));
- }
-
-
- // ---------------------------------------------------------------------------
- // Ñ CFastTextEdit
- // ---------------------------------------------------------------------------
- // Default Contructor
-
- CFastTextEdit::CFastTextEdit()
- : LTextEdit()
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // Ñ CFastTextEdit
- // ---------------------------------------------------------------------------
- // Construct from input parameters
-
- CFastTextEdit::CFastTextEdit(
- const SPaneInfo &inPaneInfo,
- const SViewInfo &inViewInfo,
- Uint16 inTextAttributes,
- ResIDT inTextTraitsID)
- : LTextEdit( inPaneInfo, inViewInfo, inTextAttributes, inTextTraitsID )
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // Ñ CFastTextEdit(LStream*)
- // ---------------------------------------------------------------------------
- // Contruct an TextEdit from the data in a Stream
-
- CFastTextEdit::CFastTextEdit(
- LStream *inStream)
- : LTextEdit(inStream)
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // Ñ ~CFastTextEdit
- // ---------------------------------------------------------------------------
- // Destructor
-
- CFastTextEdit::~CFastTextEdit()
- {
- }
-
-
- Boolean
- CFastTextEdit::FocusDraw()
- {
- Boolean focused = LView::FocusDraw();
- if (focused) {
- StColorPenState::Normalize();
- UTextTraits::SetPortTextTraits(mTextTraitsID);
- }
-
- return focused;
- }
-
-
- // ---------------------------------------------------------------------------
- // Ñ DrawSelf
- // ---------------------------------------------------------------------------
- // Draw a TextEdit
-
- void
- CFastTextEdit::DrawSelf()
- {
- Rect frame;
- CalcLocalFrameRect(frame);
-
- // A Mac TERec stores a pointer to its owner port We have to
- // change it to the current port in case we are drawing into
- // a port that is not the owner port. This happens when we are
- // printing or drawing into an offscreen port.
-
- GrafPtr savePort = (**mTextEditH).inPort;
- (**mTextEditH).inPort = UQDGlobals::GetCurrentPort();
-
- ::TEUpdate(&frame, mTextEditH);
-
- (**mTextEditH).inPort = savePort;
- }
-
-
-
-
- // ---------------------------------------------------------------------------
- // Ñ ScrollImageBy
- // ---------------------------------------------------------------------------
- // Scroll the Text
-
- void
- CFastTextEdit::ScrollImageBy(
- Int32 inLeftDelta, // Pixels to scroll horizontally
- Int32 inTopDelta, // Pixels to scroll vertically
- Boolean inRefresh)
- {
- OffsetRect(&(**mTextEditH).viewRect, inLeftDelta, inTopDelta);
-
- LView::ScrollImageBy(inLeftDelta, inTopDelta, false);
-
- if( inRefresh )
- Draw(nil);
- }
-
-
-
-
- // ---------------------------------------------------------------------------
- // Ñ SpendTime
- // ---------------------------------------------------------------------------
- // Idle time: Flash the insertion cursor
-
- void
- CFastTextEdit::SpendTime(
- const EventRecord& /* inMacEvent */)
- {
- if (FocusDraw() && IsVisible() && HasAttribute(textAttr_Selectable)) {
- ::TEIdle(mTextEditH);
- }
- }
-
-