diff --git a/mozilla/lib/mac/UserInterface/CBevelView.cp b/mozilla/lib/mac/UserInterface/CBevelView.cp index 3ef6ae361d6..2473d77972c 100644 --- a/mozilla/lib/mac/UserInterface/CBevelView.cp +++ b/mozilla/lib/mac/UserInterface/CBevelView.cp @@ -46,8 +46,9 @@ CBevelView::CBevelView(LStream *inStream) if (theBevelResID != 0) { - StResource theBevelRes(ResType_BevelDescList, theBevelResID); + StResource theBevelRes(ResType_BevelDescList, theBevelResID, false, false); //don't throw on failure + if (theBevelRes.mResourceH != NULL) { StHandleLocker theLock(theBevelRes); LDataStream theBevelStream(*theBevelRes.mResourceH, ::GetHandleSize(theBevelRes)); diff --git a/mozilla/lib/mac/UserInterface/CButton.cp b/mozilla/lib/mac/UserInterface/CButton.cp index f154a01daca..ba036e2dd2a 100644 --- a/mozilla/lib/mac/UserInterface/CButton.cp +++ b/mozilla/lib/mac/UserInterface/CButton.cp @@ -27,10 +27,6 @@ #include #include -#if defined(QAP_BUILD) -#include -#endif - #include "UGraphicGizmos.h" #include "CButton.h" #include "StSetBroadcasting.h" @@ -53,28 +49,6 @@ // ₯ Class CButton // ₯₯₯ // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ -/* -#if defined(QAP_BUILD) -void -CButton::QapGetContents (PWCINFO pwc, short *pCount, short max) -{ - QapAddViewItem (pwc, pCount, WT_ASSIST_ITEM, WC_PUSH_BUTTON); -} - -void -CButton::QapGetCDescriptorMax (char * cp_buf, short s_max) -{ - Str255 controlTitle; - short sMinLen; - - GetDescriptor(controlTitle); - - memset (cp_buf, 0, s_max); - sMinLen = ((short)controlTitle[0] < s_max ? (short)controlTitle[0] : s_max); - strncpy (cp_buf, (const char *)&controlTitle[1], sMinLen); -} -#endif -*/ // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ // ₯ CButton // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ diff --git a/mozilla/lib/mac/UserInterface/CButton.h b/mozilla/lib/mac/UserInterface/CButton.h index 876d542be46..8e538594d89 100644 --- a/mozilla/lib/mac/UserInterface/CButton.h +++ b/mozilla/lib/mac/UserInterface/CButton.h @@ -22,10 +22,6 @@ #include -#if defined(QAP_BUILD) -#include -#endif - #include "MPaneEnablerPolicy.h" // abstract base class for button controls @@ -52,11 +48,6 @@ class CButton : public LControl, public MPaneEnablerPolicy virtual void SetGraphicID(ResIDT inResID); virtual ResIDT GetGraphicID(void) const; -//#if defined(QAP_BUILD) -// virtual void QapGetContents (PWCINFO pwc, short *pCount, short max); -// virtual void QapGetCDescriptorMax (char * cp_buf, short s_max); -//#endif - virtual void Draw(RgnHandle inSuperDrawRgnH); protected: diff --git a/mozilla/lib/mac/UserInterface/CButtonEnablerReloadStop.cp b/mozilla/lib/mac/UserInterface/CButtonEnablerReloadStop.cp index 03bb60d3681..5b4ce67baf5 100644 --- a/mozilla/lib/mac/UserInterface/CButtonEnablerReloadStop.cp +++ b/mozilla/lib/mac/UserInterface/CButtonEnablerReloadStop.cp @@ -28,7 +28,7 @@ CButtonEnablerReloadStop::CButtonEnablerReloadStop(LStream* inStream) // ta da! } -void CButtonEnablerReloadStop::ExecuteSelf(MessageT inMessage, void *ioParam) +void CButtonEnablerReloadStop::ExecuteSelf(MessageT /* inMessage */, void * /* ioParam */) { LControl* theControl = dynamic_cast(mPane); LCommander* theTarget = LCommander::GetTarget(); diff --git a/mozilla/lib/mac/UserInterface/CContextMenuAttachment.cp b/mozilla/lib/mac/UserInterface/CContextMenuAttachment.cp index 245cf92e802..3dbc9a70f53 100644 --- a/mozilla/lib/mac/UserInterface/CContextMenuAttachment.cp +++ b/mozilla/lib/mac/UserInterface/CContextMenuAttachment.cp @@ -53,6 +53,9 @@ CContextMenuAttachment::EClickState CContextMenuAttachment::WaitMouseAction( return eMouseTimeout; } + if (inDelay == kDefaultDelay) // GetDblTime() can be 48, 32 or 20 ticks + inDelay = MAX(GetDblTime(), 30); // but 20 is too short to display the popup + while (::StillDown()) { Point theCurrentPoint; @@ -176,7 +179,7 @@ UInt16 CContextMenuAttachment::PruneMenu(LMenu* inMenu) void CContextMenuAttachment::DoPopup(const SMouseDownEvent& inMouseDown, EClickState& outResult) //----------------------------------- { - Try_ + try { LMenu* menu = BuildMenu(); MenuHandle menuH = menu->GetMacMenuH(); @@ -192,11 +195,9 @@ void CContextMenuAttachment::DoPopup(const SMouseDownEvent& inMouseDown, EClickS StMercutioMDEFTextState theMercutioMDEFTextState; if (mTextTraitsID) { - mHostView->FocusDraw(); TextTraitsH traitsH = UTextTraits::LoadTextTraits(mTextTraitsID); if (traitsH) { - mHostView->FocusDraw(); ::LMSetSysFontFam((**traitsH).fontNumber); ::LMSetSysFontSize((**traitsH).size); ::LMSetLastSPExtra(-1L); @@ -225,30 +226,25 @@ void CContextMenuAttachment::DoPopup(const SMouseDownEvent& inMouseDown, EClickS if (command) mHostCommander->ObeyCommand(command, (void*)&inMouseDown); } - Catch_(inError) + catch(...) { } - EndCatch_ } // CContextMenuAttachment::DoPopup - -// -// Execute -// +//---------------------------------------------------------------------------------------- +Boolean CContextMenuAttachment::Execute( MessageT inMessage, void *ioParam ) // Overridden to listen for multiple messages (context menu and context menu cursor) -// -Boolean -CContextMenuAttachment :: Execute ( MessageT inMessage, void *ioParam ) +//---------------------------------------------------------------------------------------- { Boolean executeHost = true; - if ((inMessage == msg_ContextMenu) || (inMessage == msg_ContextMenuCursor)) { + if ((inMessage == msg_ContextMenu) || (inMessage == msg_ContextMenuCursor)) + { ExecuteSelf(inMessage, ioParam); executeHost = mExecuteHost; } - return executeHost; -} +} // CContextMenuAttachment::Execute //----------------------------------- @@ -260,57 +256,46 @@ void CContextMenuAttachment::ExecuteSelf( mExecuteHost = true; if (!mHostView || !mHostCommander) return; - - switch ( inMessage ) { + switch ( inMessage ) + { case msg_ContextMenu: + mHostView->FocusDraw(); // so that coordinate computations are correct. SExecuteParams& params = *(SExecuteParams*)ioParam; const SMouseDownEvent& mouseDown = *params.inMouseDown; params.outResult = WaitMouseAction( mouseDown.whereLocal, - mouseDown.macEvent.when, - 2 * GetDblTime()); + mouseDown.macEvent.when); if (params.outResult == eMouseTimeout) DoPopup(mouseDown, params.outResult); break; - case msg_ContextMenuCursor: Assert_(ioParam != NULL); ChangeCursor ( (EventRecord*)ioParam ); break; - } // case of which message - } // CContextMenuAttachment::ExecuteSelf -// -// BuildMenu -// THROWS int on error -// -// Reads in the menu with the id given in the PPob. This can be overridden to read the menu -// from some other place, such as from the back-end. -// - -LMenu* -CContextMenuAttachment :: BuildMenu ( ) +//---------------------------------------------------------------------------------------- +LMenu* CContextMenuAttachment::BuildMenu( ) +// THROWS OSErr on error +// Reads in the menu with the id given in the PPob. This can be overridden to read the +// menu from some other place, such as from the back-end. +//---------------------------------------------------------------------------------------- { LMenu* menu = new LMenu(mMenuID); MenuHandle menuH = menu->GetMacMenuH(); if (!menuH) - throw ResError(); + throw (OSErr)ResError(); ::DetachResource((Handle)menuH); return menu; } // CContextMenuAttachment::BuildMenu - -// -// ChangeCursor -// +//---------------------------------------------------------------------------------------- +void CContextMenuAttachment::ChangeCursor( const EventRecord* inEvent ) // Makes the mouse the contextual menu cursor from OS8 if cmd key is down -// -void -CContextMenuAttachment :: ChangeCursor ( const EventRecord* inEvent ) +//---------------------------------------------------------------------------------------- { if ( inEvent->modifiers & controlKey ) { CursHandle contextCurs = ::GetCursor ( kContextualCursorID ); @@ -319,5 +304,4 @@ CContextMenuAttachment :: ChangeCursor ( const EventRecord* inEvent ) } else ::InitCursor(); - } // ChangeCursor diff --git a/mozilla/lib/mac/UserInterface/CContextMenuAttachment.h b/mozilla/lib/mac/UserInterface/CContextMenuAttachment.h index 4ba0203cef6..5c0969435ce 100644 --- a/mozilla/lib/mac/UserInterface/CContextMenuAttachment.h +++ b/mozilla/lib/mac/UserInterface/CContextMenuAttachment.h @@ -63,16 +63,19 @@ public: EClickState outResult; }; - virtual Boolean Execute ( MessageT inMessage, void *ioParam ) ; + enum { kDefaultDelay = -1}; -protected: - - enum { kContextualCursorID = 6610 } ; - - EClickState WaitMouseAction( + // Public utility method + static EClickState WaitMouseAction( const Point& inInitialPoint, Int32 inWhen, - Int32 inDelay); + Int32 inDelay = kDefaultDelay); +protected: + + enum { kContextualCursorID = 6610 }; + + virtual Boolean Execute( MessageT inMessage, void *ioParam ); + virtual void ExecuteSelf( MessageT inMessage, void* ioParam); @@ -82,9 +85,9 @@ protected: virtual UInt16 PruneMenu(LMenu* inMenu); // override to do something other than read in a menu from the resource fork - virtual LMenu* BuildMenu ( ) ; + virtual LMenu* BuildMenu( ) ; - virtual void ChangeCursor ( const EventRecord* inEvent ) ; + virtual void ChangeCursor( const EventRecord* inEvent ); //---- // Data diff --git a/mozilla/lib/mac/UserInterface/CDrawingState.cp b/mozilla/lib/mac/UserInterface/CDrawingState.cp index 42c61a89ede..dad11ab98ae 100644 --- a/mozilla/lib/mac/UserInterface/CDrawingState.cp +++ b/mozilla/lib/mac/UserInterface/CDrawingState.cp @@ -54,6 +54,8 @@ StMercutioMDEFTextState::SetUpForMercurtioMDEF() ::TextFont(systemFont); ::TextSize(0); +/* duh. this does exactly what we just did. + if (UEnvironment::HasFeature(env_SupportsColor)) { ::GetCWMgrPort(&mWMgrCPort); @@ -63,7 +65,7 @@ StMercutioMDEFTextState::SetUpForMercurtioMDEF() ::TextFont(systemFont); ::TextSize(0); } - +*/ ::SetPort(mPort); } @@ -78,12 +80,14 @@ StMercutioMDEFTextState::Restore() ::TextFont(mWMgrFont); ::TextSize(mWMgrSize); +/* duh. this does exactly what we just did. if (UEnvironment::HasFeature(env_SupportsColor)) { ::SetPort((GrafPtr)mWMgrCPort); ::TextFont(mCWMgrFont); ::TextSize(mCWMgrSize); } +*/ ::SetPort(mPort); } @@ -138,9 +142,9 @@ StSysFontState::Restore() void StSysFontState::SetTextTraits( - ResIDT inTextTraitsID) + ResIDT inTextTraitsID ) { - TextTraitsH traitsH = UTextTraits::LoadTextTraits ( 130 ); + TextTraitsH traitsH = UTextTraits::LoadTextTraits ( inTextTraitsID ); if ( traitsH ) { // Bug #64133 kellys @@ -149,6 +153,7 @@ StSysFontState::SetTextTraits( ::LMSetSysFontFam ( ::GetScriptVariable(::FontToScript(1), smScriptAppFond) ); else ::LMSetSysFontFam ( (**traitsH).fontNumber ); + ::LMSetSysFontSize ( (**traitsH).size ); ::LMSetLastSPExtra ( -1L ); } diff --git a/mozilla/lib/mac/UserInterface/CDrawingState.h b/mozilla/lib/mac/UserInterface/CDrawingState.h index 470196710f5..fbb9e107441 100644 --- a/mozilla/lib/mac/UserInterface/CDrawingState.h +++ b/mozilla/lib/mac/UserInterface/CDrawingState.h @@ -38,11 +38,11 @@ public: private: GrafPtr mPort; GrafPtr mWMgrPort; - CGrafPtr mWMgrCPort; + // CGrafPtr mWMgrCPort; Int16 mWMgrFont; Int16 mWMgrSize; - Int16 mCWMgrFont; - Int16 mCWMgrSize; + //Int16 mCWMgrFont; + //Int16 mCWMgrSize; }; class StSysFontState @@ -54,7 +54,7 @@ public: void Save(); void Restore(); - void SetTextTraits(ResIDT inTextTraitsID); + void SetTextTraits(ResIDT inTextTraitsID = 130); private: Int16 mFont; diff --git a/mozilla/lib/mac/UserInterface/CInlineEditField.cp b/mozilla/lib/mac/UserInterface/CInlineEditField.cp index dd2750f62dd..897198324b2 100644 --- a/mozilla/lib/mac/UserInterface/CInlineEditField.cp +++ b/mozilla/lib/mac/UserInterface/CInlineEditField.cp @@ -64,7 +64,8 @@ void CInlineEditField::SetDescriptor(ConstStr255Param inDescriptor) { - inherited::SetDescriptor(inDescriptor); + Inherited::SetDescriptor(inDescriptor); + if (mGrowableBorder) AdjustFrameWidthToText(); @@ -134,7 +135,7 @@ void CInlineEditField::UpdateEdit(ConstStr255Param inEditText, const SPoint32 *i void CInlineEditField::FinishCreateSelf(void) { - inherited::FinishCreateSelf(); + Inherited::FinishCreateSelf(); Hide(); // Should be invisible to start @@ -156,7 +157,7 @@ void CInlineEditField::ResizeFrameBy(Int16 inWidthDelta, Int16 inHeightDelta, Bo if ( !inWidthDelta && !inHeightDelta ) return; - inherited::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh); + Inherited::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh); if ( inRefresh && mGrowableBorder) { Rect portRect, refreshRect; @@ -215,7 +216,7 @@ Boolean CInlineEditField::HandleKeyPress(const EventRecord &inKeyEvent) { } } - return inherited::HandleKeyPress(inKeyEvent); + return Inherited::HandleKeyPress(inKeyEvent); } @@ -227,7 +228,7 @@ void CInlineEditField::DontBeTarget(void) { StValueChanger change(mGivingUpTarget, true); - inherited::DontBeTarget(); + Inherited::DontBeTarget(); PaneIDT paneID = mPaneID; BroadcastMessage(msg_HidingInlineEditField, &paneID); @@ -254,7 +255,7 @@ void CInlineEditField::HideSelf(void) { void CInlineEditField::TakeOffDuty(void) { - inherited::TakeOffDuty(); + Inherited::TakeOffDuty(); mOnDuty = triState_Off; // Taking our chain off duty means that we are hidden and // should no longer be in the chain of command. diff --git a/mozilla/lib/mac/UserInterface/CInlineEditField.h b/mozilla/lib/mac/UserInterface/CInlineEditField.h index cd8ec1fea95..bbfd448e621 100644 --- a/mozilla/lib/mac/UserInterface/CInlineEditField.h +++ b/mozilla/lib/mac/UserInterface/CInlineEditField.h @@ -59,9 +59,9 @@ class CInlineEditField : public LBroadcasterEditField { -#if !defined(__MWERKS__) || (__MWERKS__ >= 0x2000) - typedef LBroadcasterEditField inherited; -#endif + + typedef LBroadcasterEditField Inherited; + public: diff --git a/mozilla/lib/mac/UserInterface/CMouseDispatcher.cp b/mozilla/lib/mac/UserInterface/CMouseDispatcher.cp index 070caf30a72..6201d99b733 100644 --- a/mozilla/lib/mac/UserInterface/CMouseDispatcher.cp +++ b/mozilla/lib/mac/UserInterface/CMouseDispatcher.cp @@ -49,6 +49,12 @@ void CMouseDispatcher::ExecuteSelf( if (theEvent->what == kHighLevelEvent) return; + // Don't process mouse position for update events (otherwise, tooltip + // panes that are drawn under the mouse position get deleted before + // the update event even gets processed - jrm 98/05/05. + if (theEvent->what == updateEvt) + return; + LPane* theCurrentPane = nil; LPane* theLastPane = LPane::GetLastPaneMoused(); diff --git a/mozilla/lib/mac/UserInterface/CNotificationAttachment.cp b/mozilla/lib/mac/UserInterface/CNotificationAttachment.cp index e63d16ecb58..ee4f116e54f 100644 --- a/mozilla/lib/mac/UserInterface/CNotificationAttachment.cp +++ b/mozilla/lib/mac/UserInterface/CNotificationAttachment.cp @@ -59,7 +59,7 @@ void CNotificationAttachment::ExecuteSelf( void CNotificationAttachment::Post(void) { - OSErr theErr = ::GetIconSuite(&mIconSuite, 170, svAllSmallData); + OSErr theErr = ::GetIconSuite(&mIconSuite, 128, svAllSmallData); ThrowIfOSErr_(theErr); ::HNoPurge(mIconSuite); diff --git a/mozilla/lib/mac/UserInterface/CPaneEnabler.cp b/mozilla/lib/mac/UserInterface/CPaneEnabler.cp index 25be81da699..530e145a4ea 100644 --- a/mozilla/lib/mac/UserInterface/CPaneEnabler.cp +++ b/mozilla/lib/mac/UserInterface/CPaneEnabler.cp @@ -111,7 +111,7 @@ void CPaneEnabler::UpdatePanes() } // CPaneEnabler::UpdatePanes //----------------------------------- -void CPaneEnabler::ExecuteSelf(MessageT inMessage, void*) +void CPaneEnabler::ExecuteSelf(MessageT /* inMessage */, void*) //----------------------------------- { MPaneEnablerPolicy* thePolicy = dynamic_cast(mPane); diff --git a/mozilla/lib/mac/UserInterface/CPatternButton.cp b/mozilla/lib/mac/UserInterface/CPatternButton.cp index 5925c552089..98336a430ca 100644 --- a/mozilla/lib/mac/UserInterface/CPatternButton.cp +++ b/mozilla/lib/mac/UserInterface/CPatternButton.cp @@ -91,7 +91,8 @@ void CPatternButton::DrawButtonContent(void) void CPatternButton::DrawButtonGraphic(void) { - bool useMouseOverIcon = false; + Boolean useMouseOverIcon = false; + mIconTransform = kTransformNone; if (IsEnabled() && IsActive()) @@ -99,23 +100,31 @@ void CPatternButton::DrawButtonGraphic(void) if (!IsBehaviourButton() && (GetValue() == Button_On)) { // do something different if IsTrackInside() - //theNewID += 2; + //theNewID += 1; } - else if (IsTrackInside()) + else if (IsTrackInside()) { + //theNewID += 1; mIconTransform = kTransformSelected; - else if (IsMouseInFrame()) + } + else if (IsMouseInFrame()) { useMouseOverIcon = true; + } } - else + else { + //theNewID += 1; mIconTransform = kTransformDisabled; + } - ResIDT theIconID; - if ( useMouseOverIcon ) { + ResIDT theIconID; + + if (useMouseOverIcon) { theIconID = GetGraphicID(); SetGraphicID(theIconID + 2); } + CToolbarButton::DrawButtonGraphic(); - if ( useMouseOverIcon ) + + if (useMouseOverIcon) SetGraphicID(theIconID); } diff --git a/mozilla/lib/mac/UserInterface/CPatternButtonPopupText.cp b/mozilla/lib/mac/UserInterface/CPatternButtonPopupText.cp index 17a68601046..055faf921a3 100644 --- a/mozilla/lib/mac/UserInterface/CPatternButtonPopupText.cp +++ b/mozilla/lib/mac/UserInterface/CPatternButtonPopupText.cp @@ -24,6 +24,8 @@ #include "CSharedPatternWorld.h" #include "CTargetedUpdateMenuRegistry.h" +#include "PascalString.h" + // This class overrides CPatternButtonPopup to provide a popup menu which // changes the descriptor based on the menu selection // assumes left-justified text in DrawButtonTitle() @@ -141,7 +143,11 @@ CPatternButtonPopupText::DrawButtonTitle(void) if (IsTrackInside()) ::RGBForeColor(&UGAColorRamp::GetWhiteColor()); - UGraphicGizmos::PlaceStringInRect(mTitle, mCachedTitleFrame, teFlushLeft, teCenter); + CStr255 truncTitle(mTitle); + + ::TruncString( mFrameSize.width - (gsPopup_ArrowButtonWidth + 5), truncTitle, smTruncEnd); + + UGraphicGizmos::PlaceStringInRect(truncTitle, mCachedTitleFrame, teFlushLeft, teCenter); DrawPopupArrow(); } diff --git a/mozilla/lib/mac/UserInterface/CPatternProgressBar.cp b/mozilla/lib/mac/UserInterface/CPatternProgressBar.cp index 7847729296d..8c68b08df95 100644 --- a/mozilla/lib/mac/UserInterface/CPatternProgressBar.cp +++ b/mozilla/lib/mac/UserInterface/CPatternProgressBar.cp @@ -34,6 +34,8 @@ const ResIDT cOfflineListID = 16010; const Int16 cOfflineStrIndex = 3; +#define PLAIN_PROGRESS_BAR + // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ // #pragma mark --- CPatternProgressBar --- @@ -129,8 +131,15 @@ void CPatternProgressBar::DrawIndefiniteBar(const Rect& inBounds) CGrafPtr thePort; ::GetPort(&(GrafPtr)thePort); mPatternWorld->Fill(thePort, inBounds, theAlignment); + +#ifndef PLAIN_PROGRESS_BAR UGraphicGizmos::BevelTintRect(theBoundsCopy, -1, 0x4000, 0x4000); ::InsetRect(&theBoundsCopy, 1, 1); +#else + ::InsetRect(&theBoundsCopy, 1, 1); + UGraphicGizmos::BevelTintRect(theBoundsCopy, -1, 0x4000, 0x4000); +#endif //PLAIN_PROGRESS_BAR + UGraphicGizmos::LowerColorVolume(theBoundsCopy, 0x2000); // Get our drawing port, and save the origin state. @@ -223,9 +232,14 @@ void CPatternProgressBar::DrawPercentageBar(const Rect& inBounds) if (RectWidth(theLeftBox) >= 5) { +#ifndef PLAIN_PROGRESS_BAR UGraphicGizmos::BevelTintRect(theLeftBox, 1, 0x4000, 0x6000); ::InsetRect(&theLeftBox, 1, 1); UGraphicGizmos::LowerColorVolume(theLeftBox, 0x1000); +#else + UGraphicGizmos::LowerColorVolume(theLeftBox, 0x0000); +#endif + } else theRightBox.left = theLeftBox.left; @@ -256,16 +270,6 @@ void CPatternProgressBar::SetValue(Int32 inValue) } } -// ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ -// ₯ -// ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ -#if 0 -void CPatternProgressBar::SetValueRange(const Range32T& inRange) -{ - mValueRange = inRange; -} -#endif - // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ // ₯ // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ @@ -336,6 +340,11 @@ void CPatternProgressBar::RecalcPoleMasks(void) Rect theFrame; CalcLocalFrameRect(theFrame); ::InsetRect(&theFrame, 1, 1); + +#ifdef PLAIN_PROGRESS_BAR + theFrame.top ++; +#endif + theFrame.right += RectHeight(theFrame) * 2; theFrame.left -= RectHeight(theFrame) * 2; @@ -355,17 +364,12 @@ void CPatternProgressBar::RecalcPoleMasks(void) StRegion theStampRgn; ::OpenRgn(); -// 97-05-11 pkc -- reverse indefinite bar slant to comply with MacOS standard + ::MoveTo(theStamp.left, theStamp.top); ::LineTo(theStamp.left + theHalfHeight, theStamp.top); ::LineTo(theStamp.right - 1, theStamp.bottom - 1); ::LineTo(theStamp.right - (1 + theHalfHeight), theStamp.bottom - 1); ::LineTo(theStamp.left, theStamp.top); -// ::MoveTo(theStamp.left, theStamp.bottom - 1); -// ::LineTo(theStamp.left + theHalfHeight, theStamp.top); -// ::LineTo(theStamp.right - 1, theStamp.top); -// ::LineTo(theStamp.right - (1 + theHalfHeight), theStamp.bottom - 1); -// ::LineTo(theStamp.left, theStamp.bottom - 1); ::CloseRgn(theStampRgn); GWorldPtr theMacWorld = theMaskWorld.GetMacGWorld(); @@ -387,18 +391,20 @@ void CPatternProgressBar::RecalcPoleMasks(void) theStamp = theFrame; theStamp.right = theStamp.left + RectHeight(theStamp) + theHalfHeight; + // the light shade if (theMaskWorld.BeginDrawing()) { ::EraseRect(&theFrame); while (theStamp.left < theFrame.right) { - // 97-05-11 pkc -- reverse indefinite bar slant to comply with MacOS standard +#ifndef PLAIN_PROGRESS_BAR ::MoveTo(theStamp.left, theStamp.top); ::LineTo(theStamp.left + theHalfHeight, theStamp.top); ::LineTo(theStamp.right - 1, theStamp.bottom - 1); -// ::MoveTo(theStamp.left, theStamp.bottom - 1); -// ::LineTo(theStamp.left + theHalfHeight, theStamp.top); -// ::LineTo(theStamp.right - 1, theStamp.top); +#else + ::MoveTo(theStamp.left + theHalfHeight, theStamp.top); + ::LineTo(theStamp.right - 1, theStamp.bottom - 1); +#endif ::OffsetRect(&theStamp,theHeight, 0); } @@ -410,18 +416,20 @@ void CPatternProgressBar::RecalcPoleMasks(void) theStamp = theFrame; theStamp.right = theStamp.left + RectHeight(theStamp) + theHalfHeight; + // the dark shade if (theMaskWorld.BeginDrawing()) { ::EraseRect(&theFrame); while (theStamp.left < theFrame.right) { - // 97-05-11 pkc -- reverse indefinite bar slant to comply with MacOS standard +#ifndef PLAIN_PROGRESS_BAR ::MoveTo(theStamp.right - 1, theStamp.bottom - 1); ::LineTo(theStamp.right - (1 + theHalfHeight), theStamp.bottom - 1); ::LineTo(theStamp.left, theStamp.top); -// ::MoveTo(theStamp.right - 1, theStamp.top); -// ::LineTo(theStamp.right - (1 + theHalfHeight), theStamp.bottom - 1); -// ::LineTo(theStamp.left, theStamp.bottom - 1); +#else + ::MoveTo(theStamp.right - (2 + theHalfHeight), theStamp.bottom - 2); + ::LineTo(theStamp.left, theStamp.top); +#endif ::OffsetRect(&theStamp, theHeight, 0); } @@ -500,6 +508,8 @@ void CPatternProgressCaption::DrawSelf(void) // UGraphicGizmos::BevelTintRect(theFrame, -1, 0x4000, 0x6000); ::InsetRect(&theFrame, 5, 0); + theFrame.right -= 5; //tweaking magic + theFrame.bottom --; Int16 theJust = UTextTraits::SetPortTextTraits(mTraitsID); if (mText.Length() > 0) diff --git a/mozilla/lib/mac/UserInterface/CPatternProgressBar.h b/mozilla/lib/mac/UserInterface/CPatternProgressBar.h index 73079f187c3..2517aba7bcc 100644 --- a/mozilla/lib/mac/UserInterface/CPatternProgressBar.h +++ b/mozilla/lib/mac/UserInterface/CPatternProgressBar.h @@ -43,7 +43,6 @@ class CPatternProgressBar : public LPane virtual void SetValue(Int32 inValue); virtual Int32 GetValue(void) const; -// virtual void SetValueRange(const Range32T& inRange); virtual void SetToIndefinite(void); virtual void SetSeamless(void); diff --git a/mozilla/lib/mac/UserInterface/CPatternTabControl.cp b/mozilla/lib/mac/UserInterface/CPatternTabControl.cp index 7dad2fe2db3..b4d9c223a83 100644 --- a/mozilla/lib/mac/UserInterface/CPatternTabControl.cp +++ b/mozilla/lib/mac/UserInterface/CPatternTabControl.cp @@ -49,7 +49,7 @@ CPatternTabControl::~CPatternTabControl() //----------------------------------- void CPatternTabControl::DrawOneTabBackground( RgnHandle inRegion, - Boolean inCurrentTab) + Boolean /* inCurrentTab */) //----------------------------------- { Point theAlignment; @@ -60,7 +60,7 @@ void CPatternTabControl::DrawOneTabBackground( } // CPatternTabControl::DrawOneTabBackground //----------------------------------- -void CPatternTabControl::DrawOneTabFrame(RgnHandle inRegion, Boolean inCurrentTab) +void CPatternTabControl::DrawOneTabFrame(RgnHandle inRegion, Boolean /* inCurrentTab */) //----------------------------------- { ::FrameRgn(inRegion); diff --git a/mozilla/lib/mac/UserInterface/CProgressBar.cp b/mozilla/lib/mac/UserInterface/CProgressBar.cp index 70a18b5e86e..7a4cf384a32 100644 --- a/mozilla/lib/mac/UserInterface/CProgressBar.cp +++ b/mozilla/lib/mac/UserInterface/CProgressBar.cp @@ -61,7 +61,6 @@ void CProgressBar::FinishCreateSelf(void) PixMapHandle theMap = (**mPolePattern).patMap; mPatWidth = RectWidth((*theMap)->bounds); -// SetValueRange(Range32T(0,100)); mValueRange = 100; } @@ -123,7 +122,9 @@ void CProgressBar::DrawSelf(void) ::GetAuxWin(thePort, &theAuxHandle); CTabHandle theColorTable = (**theAuxHandle).awCTable; - RGBColor theWindowBack = UGraphicGizmos::FindInColorTable(theColorTable, wContentColor); + RGBColor theWindowBack; + + UGraphicGizmos::FindInColorTable(theColorTable, wContentColor, theWindowBack); RGBColor theBodyColor, theFrameColor, theBarColor; #if 0 @@ -261,13 +262,3 @@ void CProgressBar::SetValue(Int32 inValue) Draw(NULL); } } - -// ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ -// ₯ -// ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ -#if 0 -void CProgressBar::SetValueRange(const Range32T& inRange) -{ - mValueRange = inRange; -} -#endif diff --git a/mozilla/lib/mac/UserInterface/CSimpleDividedView.cp b/mozilla/lib/mac/UserInterface/CSimpleDividedView.cp index a483c4e32f0..9c8cabfb434 100644 --- a/mozilla/lib/mac/UserInterface/CSimpleDividedView.cp +++ b/mozilla/lib/mac/UserInterface/CSimpleDividedView.cp @@ -206,9 +206,9 @@ void CSimpleDividedView::FinishCreateSelf() // ₯ AdaptToSuperFrameSize // --------------------------------------------------------------------------- // Do not want to move the view around -void CSimpleDividedView::AdaptToSuperFrameSize(Int32 inSurrWidthDelta, - Int32 inSurrHeightDelta, - Boolean inRefresh) +void CSimpleDividedView::AdaptToSuperFrameSize(Int32 /* inSurrWidthDelta */, + Int32 /* inSurrHeightDelta */, + Boolean /* inRefresh */) { ReadjustConstraints(); } @@ -291,7 +291,7 @@ void CSimpleDividedView::ClickSelf(const SMouseDownEvent &inMouseDown) // --------------------------------------------------------------------------- // Standard vert/horizontal sliders -void CSimpleDividedView::AdjustCursorSelf(Point inPortPt, const EventRecord& inMacEvent ) +void CSimpleDividedView::AdjustCursorSelf(Point /* inPortPt */, const EventRecord& /* inMacEvent */ ) { ResIDT cursID = fIsVertical ? VERT_CURSOR : HORI_CURSOR; CursHandle h = GetCursor (cursID); diff --git a/mozilla/lib/mac/UserInterface/CSimpleTextView.cp b/mozilla/lib/mac/UserInterface/CSimpleTextView.cp index f7189850f1c..86fe61b326a 100644 --- a/mozilla/lib/mac/UserInterface/CSimpleTextView.cp +++ b/mozilla/lib/mac/UserInterface/CSimpleTextView.cp @@ -26,16 +26,14 @@ //#include //#include -//#include #include #include "CSpellChecker.h" - -#include "resgui.h" +#include "resgui.h" // for emSignature //#include "Textension.h" -#pragma global_optimizer off +//#pragma global_optimizer off //why??? Boolean CSimpleTextView::sInitialized = false; @@ -57,6 +55,7 @@ CSimpleTextView::CSimpleTextView() Assert_( false ); // Must use parameters + mTabIntoFieldSelectsAll = true; //default behaviour } @@ -69,6 +68,9 @@ CSimpleTextView::CSimpleTextView( LStream *inStream ) if ( !sInitialized ) Initialize(); + + mTabIntoFieldSelectsAll = true; //default behaviour + /* mTextParms = NULL; @@ -156,7 +158,7 @@ CSimpleTextView::FinishCreateSelf( void ) } */ - CWASTEEdit::FinishCreateSelf(); + Inherited::FinishCreateSelf(); } @@ -232,6 +234,7 @@ void CSimpleTextView::NoteOverNewThing(LManipulator *inThing) Boolean CSimpleTextView::ObeyCommand( CommandT inCommand, void *ioParam ) { + Boolean cmdHandled = true; switch (inCommand) { @@ -243,10 +246,22 @@ CSimpleTextView::ObeyCommand( CommandT inCommand, void *ioParam ) break; #endif // MOZ_SPELLCHK + // handle msg_TabSelect ourselves, because we don't want the CWASTEEdit + // select all behaviour + case msg_TabSelect: + if ( ! mTabIntoFieldSelectsAll ) + { + // do nothing + break; + } + // else + // fallthrough for default behaviour + default: - return CWASTEEdit::ObeyCommand(inCommand, ioParam); + cmdHandled = Inherited::ObeyCommand(inCommand, ioParam); } + return cmdHandled; } @@ -261,7 +276,7 @@ CSimpleTextView::ClickSelf( const SMouseDownEvent &inMouseDown ) if ( !IsTarget() ) SwitchTarget( this ); - CWASTEEdit::ClickSelf( inMouseDown ); + Inherited::ClickSelf( inMouseDown ); } @@ -282,7 +297,17 @@ CSimpleTextView::BeTarget() } - CWASTEEdit::BeTarget(); + //Inherited::BeTarget(); + // ugly copy and paste because I don't want to change CWASTEEdit + // but want to override its scroller activation behaviour + + if (FocusDraw()) { // Show active selection + WEActivate( GetWEHandle() ); + } + + StartIdling(); + + ProtectSelection(); } @@ -303,7 +328,14 @@ CSimpleTextView::DontBeTarget() } - CWASTEEdit::DontBeTarget(); + // Inherited::DontBeTarget(); + // ugly copy and paste because I don't want to change CWASTEEdit + // but want to override its scroller activation behaviour + + if (FocusDraw()) { // Show inactive selection + WEDeactivate( GetWEHandle() ); + } + StopIdling(); // Stop flashing the cursor } @@ -324,12 +356,31 @@ void CSimpleTextView::FindCommandStatus( CommandT inCommand, #endif // MOZ_SPELLCHK default: - CWASTEEdit::FindCommandStatus(inCommand, outEnabled, + Inherited::FindCommandStatus(inCommand, outEnabled, outUsesMark, outMark, outName); } } +Boolean CSimpleTextView::HandleKeyPress( const EventRecord & inKeyEvent) + { + Boolean commandKeyDown = (inKeyEvent.modifiers & cmdKey) != 0; + Int16 theKey = inKeyEvent.message & charCodeMask; + + if (commandKeyDown && ( theKey == char_Tab) ) + { + // strip out the command key modifier so the tab group handles it + const_cast(& inKeyEvent)->modifiers &= ~cmdKey; + + // send it up to the supercommander (the window) to handle + return LCommander::HandleKeyPress( inKeyEvent ); + + } + else + { + return Inherited::HandleKeyPress( inKeyEvent ); + } + } void CSimpleTextView::Save( const FSSpec &inFileSpec ) { @@ -359,11 +410,10 @@ void CSimpleTextView::Save( const FSSpec &inFileSpec ) } -pascal void -CSimpleTextView::TSMPreUpdate( WEReference inWE ) +pascal void CSimpleTextView::TSMPreUpdate( WEReference ) { -// AHHHH!!! Why didn't these wankers allow us to pass in a context +// AHHHH!!! Why didn't they allow us to pass in a context // pointer? Now I have to maintain this stupid sTargetView item. Assert_( sTargetView != NULL ); diff --git a/mozilla/lib/mac/UserInterface/CSimpleTextView.h b/mozilla/lib/mac/UserInterface/CSimpleTextView.h index 586833cc807..5ff2936b65c 100644 --- a/mozilla/lib/mac/UserInterface/CSimpleTextView.h +++ b/mozilla/lib/mac/UserInterface/CSimpleTextView.h @@ -72,6 +72,8 @@ class CSimpleTextView : public CWASTEEdit // friend class LTextEditHandler; // this will be going away! private: + typedef CWASTEEdit Inherited; + CSimpleTextView(); // Must use parameters @@ -109,9 +111,13 @@ class CSimpleTextView : public CWASTEEdit virtual void SetInitialTraits(ResIDT inTextTraitsID); virtual void SetInitialText(ResIDT inTextID); - virtual Boolean IsReadOnly(); + virtual Boolean IsReadOnly(); virtual void SetReadOnly( const Boolean inFlag ); + virtual void SetTabSelectsAll ( const Boolean inTabIntoFieldSelectsAll ) + { + mTabIntoFieldSelectsAll = inTabIntoFieldSelectsAll; + }; // Commands void Save( const FSSpec &inFileSpec ); @@ -119,6 +125,8 @@ class CSimpleTextView : public CWASTEEdit protected: virtual void ClickSelf( const SMouseDownEvent &inMouseDown); + virtual Boolean HandleKeyPress( const EventRecord & inKeyEvent); + virtual void BeTarget(); virtual void DontBeTarget(); @@ -132,6 +140,9 @@ class CSimpleTextView : public CWASTEEdit static WETSMPreUpdateUPP sPreUpdateUPP; static CSimpleTextView *sTargetView; + private: + + Boolean mTabIntoFieldSelectsAll; }; diff --git a/mozilla/lib/mac/UserInterface/CTabControl.cp b/mozilla/lib/mac/UserInterface/CTabControl.cp index a0be8da7311..19563353110 100644 --- a/mozilla/lib/mac/UserInterface/CTabControl.cp +++ b/mozilla/lib/mac/UserInterface/CTabControl.cp @@ -143,6 +143,30 @@ void CTabControl::DoLoadTabs(ResIDT inTabDescResID) SetValue(mValue); } +// ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ +// ₯ +// ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ + +void CTabControl::SetTabEnable(ResIDT inPageResID, Boolean inEnable) +{ + CTabInstance* theTab; + LArrayIterator theIter(mTabs, LArrayIterator::from_Start); + while (theIter.Next(&theTab)) + { + if (theTab->mMessage == inPageResID) + { + if (theTab->mEnabled != inEnable) + { + theTab->mEnabled = inEnable; + FocusDraw(); + DrawSelf(); // because it's not sufficient to DrawOneTab(theTab) + break; + } + } + } +} + + // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ // ₯ // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ @@ -605,7 +629,7 @@ void CTabControl::DrawTopBevel(CTabInstance* inTab) // ₯ DrawBottomBevel // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ -void CTabControl::DrawBottomBevel(CTabInstance* inTab, Boolean inCurrentTab) +void CTabControl::DrawBottomBevel(CTabInstance* inTab, Boolean /* inCurrentTab */) { const Rect& theTabFrame = inTab->mFrame; switch (mOrientation) @@ -725,6 +749,12 @@ Int16 CTabControl::FindHotSpot(Point inPoint) const if (theTab == mCurrentTab) continue; + if (! theTab->mEnabled) + { + ::SysBeep(1); + break; + } + if (::PtInRgn(inPoint, theTab->mMask)) { theHotSpot = mTabs.FetchIndexOf(&theTab); @@ -901,6 +931,7 @@ void CTabControl::DeactivateSelf(void) CTabInstance::CTabInstance() { mMask = NULL; + mEnabled = true; } CTextTabInstance::CTextTabInstance(const STabDescriptor& inDesc) @@ -933,6 +964,9 @@ void CTextTabInstance::DrawTitle(CTabInstance* inCurrentTab, ResIDT inTitleTrait ::OffsetRect(&theFrame, 0, 1); } + if (! mEnabled) + (**theTraitsHandle).mode |= grayishTextOr; + { StHandleLocker theLocker((Handle)theTraitsHandle); UTextTraits::SetPortTextTraits(*theTraitsHandle); @@ -967,6 +1001,9 @@ void CIconTabInstance::DrawTitle(CTabInstance* inCurrentTab, ResIDT /*inTitleTra { ::OffsetRect(&theFrame, 0, 1); } + if (! mEnabled) + transform |= kTransformDisabled; + ::PlotIconID(&theFrame, kAlignAbsoluteCenter, transform, mIconID); } diff --git a/mozilla/lib/mac/UserInterface/CTabControl.h b/mozilla/lib/mac/UserInterface/CTabControl.h index 57121e59e51..186c0872c20 100644 --- a/mozilla/lib/mac/UserInterface/CTabControl.h +++ b/mozilla/lib/mac/UserInterface/CTabControl.h @@ -67,7 +67,7 @@ class CTabControl : public LControl Boolean inRefresh); virtual void DoLoadTabs(ResIDT inTabDescResID); - + virtual void SetTabEnable(ResIDT inPageResID, Boolean inEnable); protected: @@ -151,6 +151,7 @@ class CTabInstance Rect mShadeFrame; Int16 mWidth; TString mTitle; + Boolean mEnabled; }; class CTextTabInstance: public CTabInstance diff --git a/mozilla/lib/mac/UserInterface/CTextTable.h b/mozilla/lib/mac/UserInterface/CTextTable.h index bed9ed9c67e..315a378eb4e 100644 --- a/mozilla/lib/mac/UserInterface/CTextTable.h +++ b/mozilla/lib/mac/UserInterface/CTextTable.h @@ -24,15 +24,15 @@ #pragma import on #endif -#include +#include "CTextColumn.h" #include -class CTextTable : public LTextColumn, public LCommander +class CTextTable : public CTextColumn, public LCommander { public: enum { class_ID = 'Txtb' }; - typedef LTextColumn super; + typedef CTextColumn super; CTextTable( LStream* inStream); diff --git a/mozilla/lib/mac/UserInterface/CToolTipAttachment.cp b/mozilla/lib/mac/UserInterface/CToolTipAttachment.cp index 38d59bdd0b4..701b8b356b7 100644 --- a/mozilla/lib/mac/UserInterface/CToolTipAttachment.cp +++ b/mozilla/lib/mac/UserInterface/CToolTipAttachment.cp @@ -376,7 +376,16 @@ void CToolTipPane::ForceInPortFrame( theHOffset = theWindowPortFrame.left - ioTipFrame.left; // bump it to the right if (ioTipFrame.bottom > theWindowPortFrame.bottom) - theVOffset = theWindowPortFrame.bottom - ioTipFrame.bottom; // bump it up + { + Point mouseLocal; + GetMouse(&mouseLocal); + theVOffset = mouseLocal.v - 1 - ioTipFrame.bottom; // bump it up +// WAS: theVOffset = theWindowPortFrame.bottom - ioTipFrame.bottom; // bump it up +// The original version left the mouse within the tooltip frame. This +// led to the tooltip being deleted every null event, because CMouseDispatcher +// would calculate that the pane that the mouse was in was the tooltip pane +// itself. Solution: move the pane up above the mouse position. + } else if (ioTipFrame.top < theWindowPortFrame.top) theVOffset = theWindowPortFrame.top - ioTipFrame.top; // bump it down diff --git a/mozilla/lib/mac/UserInterface/CToolbarButton.cp b/mozilla/lib/mac/UserInterface/CToolbarButton.cp index c4acaa7a869..ecff61d37f9 100644 --- a/mozilla/lib/mac/UserInterface/CToolbarButton.cp +++ b/mozilla/lib/mac/UserInterface/CToolbarButton.cp @@ -17,6 +17,7 @@ */ #include "CToolbarButton.h" +#include "CToolbarModeManager.h" #include "UGraphicGizmos.h" // "Magic" constants @@ -26,7 +27,7 @@ const Int16 cTextOnlyHeight = 21; CToolbarButton::CToolbarButton(LStream* inStream) : CButton(inStream), - mCurrentMode(defaultMode), + mCurrentMode(CToolbarModeManager::defaultToolbarMode), mOriginalWidth(0), mOriginalHeight(0) { @@ -60,10 +61,10 @@ void CToolbarButton::DrawSelf() DrawButtonContent(); - if (mCurrentMode != eMode_IconsOnly && mTitle.Length() > 0) + if (mCurrentMode != eTOOLBAR_ICONS && mTitle.Length() > 0) DrawButtonTitle(); - if (mCurrentMode != eMode_TextOnly && GetGraphicID() != 0) + if (mCurrentMode != eTOOLBAR_TEXT && GetGraphicID() != 0) DrawButtonGraphic(); if (!IsEnabled() || !IsActive()) @@ -88,17 +89,17 @@ Boolean CToolbarButton::ChangeMode(Int8 inNewMode, SDimension16& outDimensionDel switch (inNewMode) { - case eMode_IconsOnly: + case eTOOLBAR_ICONS: outDimensionDeltas.width = cIconOnlyWidth - oldDimensions.width; outDimensionDeltas.height = cIconOnlyHeight - oldDimensions.height; break; - case eMode_TextOnly: + case eTOOLBAR_TEXT: outDimensionDeltas.width = mOriginalWidth - oldDimensions.width; outDimensionDeltas.height = cTextOnlyHeight - oldDimensions.height; break; - case eMode_IconsAndText: + case eTOOLBAR_TEXT_AND_ICONS: outDimensionDeltas.width = mOriginalWidth - oldDimensions.width; outDimensionDeltas.height = mOriginalHeight - oldDimensions.height; break; @@ -114,7 +115,7 @@ Boolean CToolbarButton::ChangeMode(Int8 inNewMode, SDimension16& outDimensionDel void CToolbarButton::DrawButtonTitle(void) { - if (mCurrentMode == eMode_TextOnly && (!IsActive() || !IsEnabled())) + if (mCurrentMode == eTOOLBAR_TEXT && (!IsActive() || !IsEnabled())) ::TextMode(grayishTextOr); // this is so light you cant see it. CButton::DrawButtonTitle(); @@ -148,7 +149,7 @@ void CToolbarButton::CalcTitleFrame(void) mCachedTitleFrame.right = mCachedTitleFrame.left + ::StringWidth(mTitle);; mCachedTitleFrame.bottom = mCachedTitleFrame.top + theInfo.ascent + theInfo.descent + theInfo.leading;; - if (mCurrentMode != eMode_TextOnly) + if (mCurrentMode != eTOOLBAR_TEXT) { UGraphicGizmos::AlignRectOnRect(mCachedTitleFrame, mCachedButtonFrame, mTitleAlignment); UGraphicGizmos::PadAlignedRect(mCachedTitleFrame, mTitlePadPixels, mTitleAlignment); diff --git a/mozilla/lib/mac/UserInterface/CToolbarButton.h b/mozilla/lib/mac/UserInterface/CToolbarButton.h index 897dbca333c..2aa9a53aac5 100644 --- a/mozilla/lib/mac/UserInterface/CToolbarButton.h +++ b/mozilla/lib/mac/UserInterface/CToolbarButton.h @@ -33,14 +33,9 @@ class CToolbarButton : public CButton { public: - enum { - eMode_IconsOnly = 0, - eMode_TextOnly, - eMode_IconsAndText - }; - - enum { defaultMode = eMode_IconsAndText }; + // button types enum is in CToolbarModeManager.h + enum { class_ID = 'TbBt' }; CToolbarButton(LStream* inStream); diff --git a/mozilla/lib/mac/UserInterface/LCustomizeMenu.cp b/mozilla/lib/mac/UserInterface/LCustomizeMenu.cp index 7f5088eefbb..b6bb5f54501 100644 --- a/mozilla/lib/mac/UserInterface/LCustomizeMenu.cp +++ b/mozilla/lib/mac/UserInterface/LCustomizeMenu.cp @@ -35,7 +35,7 @@ LCustomizeMenu::LCustomizeMenu() // // Size // -void LCustomizeMenu::Size(MenuHandle menu, MenuDefUPP* root, Rect *rect, Point hitPt, short *item) +void LCustomizeMenu::Size(MenuHandle menu, MenuDefUPP* /* root */, Rect * /* rect */, Point /* hitPt */, short * /* item */) { fItemCount = ::CountMItems(menu); int maxWidth = fTextMargin + 4; @@ -105,7 +105,7 @@ short LCustomizeMenu::MeasureItemCommand(short command) // // Draw // -void LCustomizeMenu::Draw(MenuHandle menu, MenuDefUPP* root, Rect *rect, Point hitPt, short *item) +void LCustomizeMenu::Draw(MenuHandle menu, MenuDefUPP* /* root */, Rect *rect, Point /* hitPt */, short * /* item */) { Assert_(fItemCount != 0); Assert_(fItemHeight != 0); @@ -130,7 +130,7 @@ void LCustomizeMenu::DrawItemSeperator(Rect& itemrect ) // DrawItemIcon // ₯₯ΚUnsupport Yet // -void LCustomizeMenu::DrawItemIcon(Rect& itemrect, short iconindex) +void LCustomizeMenu::DrawItemIcon(Rect& /* itemrect */, short /* iconindex */) { Assert_(FALSE); // We current do not support Icon @@ -138,7 +138,7 @@ void LCustomizeMenu::DrawItemIcon(Rect& itemrect, short iconindex) // // DrawItemCommand // -void LCustomizeMenu::DrawItemCommand(Rect& itemrect, short cmd) +void LCustomizeMenu::DrawItemCommand(Rect& /* itemrect */, short cmd) { ::DrawChar(17); ::DrawChar(cmd); @@ -147,7 +147,7 @@ void LCustomizeMenu::DrawItemCommand(Rect& itemrect, short cmd) // DrawItemSubmenuIndicator // ₯₯ΚUnsupport Yet // -void LCustomizeMenu::DrawItemSubmenuIndicator(Rect& itemrect) +void LCustomizeMenu::DrawItemSubmenuIndicator(Rect& /* itemrect */) { Assert_(FALSE); // We current do not support SubmenuIndicator @@ -230,14 +230,14 @@ void LCustomizeMenu::MoveToItemMarkPosition(Rect& itemrect) // // DrawItemText // -void LCustomizeMenu::DrawItemText(Rect& itemrect, Str255 itemtext ) +void LCustomizeMenu::DrawItemText(Rect& /* itemrect */, Str255 itemtext ) { ::DrawString(itemtext); } // // DrawItemMark // -void LCustomizeMenu::DrawItemMark(Rect& itemrect, short mark ) +void LCustomizeMenu::DrawItemMark(Rect& /* itemrect */, short mark ) { ::DrawChar(mark); } @@ -306,7 +306,7 @@ void LCustomizeMenu::DrawItem(MenuHandle menu, int item, Rect& itemrect ) // // Choose // -void LCustomizeMenu::Choose(MenuHandle menu, MenuDefUPP* root, Rect *rect, Point hitPt, short *item) +void LCustomizeMenu::Choose(MenuHandle menu, MenuDefUPP* /* root */, Rect *rect, Point hitPt, short *item) { int olditem = *item; *item = 0; diff --git a/mozilla/lib/mac/UserInterface/Tables/CStandardFlexTable.cp b/mozilla/lib/mac/UserInterface/Tables/CStandardFlexTable.cp index 89fc3b462f2..1c0f90f61b4 100755 --- a/mozilla/lib/mac/UserInterface/Tables/CStandardFlexTable.cp +++ b/mozilla/lib/mac/UserInterface/Tables/CStandardFlexTable.cp @@ -55,6 +55,62 @@ #include "cstring.h" #include "CInlineEditField.h" +#include "CPasteSnooper.h" +#include "UDeferredTask.h" + +#pragma mark - + +//======================================================================================== +class CDeferredInlineEditTask +//======================================================================================== +: public CDeferredTask +{ + public: + CDeferredInlineEditTask( + CStandardFlexTable* inView, + const STableCell &inCell, + Rect & inTextRect); + protected: + virtual ExecuteResult ExecuteSelf(); +// data + protected: + CStandardFlexTable* mTable; + Rect mTextRect; + STableCell mCell; + UInt32 mEarliestExecuteTime; +}; // class CDeferredInlineEditTask + +//---------------------------------------------------------------------------------------- +CDeferredInlineEditTask::CDeferredInlineEditTask( + CStandardFlexTable* inView, + const STableCell &inCell, + Rect & inTextRect) +//---------------------------------------------------------------------------------------- +: mTable(inView) +, mCell(inCell) +, mTextRect(inTextRect) +, mEarliestExecuteTime(::TickCount() + GetDblTime()) +{ +} + +//---------------------------------------------------------------------------------------- +CDeferredTask::ExecuteResult CDeferredInlineEditTask::ExecuteSelf() +//---------------------------------------------------------------------------------------- +{ + // Current policy 98/04/07: start inline editing only if mouse stays over area and + // host view remains on duty past the double-click time. + mTable->FocusDraw(); + Point mouseLocal; + ::GetMouse(&mouseLocal); + if (!::PtInRect(mouseLocal, &mTextRect)) + return eDoneDelete; // if mouse left area, cancel inline editing without executing. + if (!mTable->IsOnDuty()) + return eDoneDelete; // if host view is deactivated, cancel inline editing. + if (::TickCount() < mEarliestExecuteTime) + return eWaitStayFront; // still waiting to see + mTable->DoInlineEditing(mCell, mTextRect); + return eDoneDelete; // remove from queue +} // CDeferredInlineEditTask::ExecuteSelf #pragma mark --- CTableHeaderListener @@ -70,29 +126,24 @@ void CTableHeaderListener::ListenToMessage(MessageT inMessage, void *ioParam) #pragma mark --- CTableHeaderListener - -// -// ListenToMessage -// +//---------------------------------------------------------------------------------------- +void CInlineEditorListener::ListenToMessage(MessageT inMessage, void * /*ioParam*/) // Respond to changes in the inline editor -// -void -CInlineEditorListener::ListenToMessage ( MessageT inMessage, void * /*ioParam*/ ) +//---------------------------------------------------------------------------------------- { - switch ( inMessage ) { - + switch ( inMessage ) + { case CInlineEditField::msg_InlineEditFieldChanged: mTable->InlineEditorTextChanged(); - break; - + break; case CInlineEditField::msg_HidingInlineEditField: mTable->InlineEditorDone(); mTable->mRowBeingEdited = LArray::index_Bad; + mTable->SetHiliteDisabled(false); break; - } // case of which message -} // ListenToMessage +} // CInlineEditorListener::ListenToMessage #pragma mark --- CClickTimer @@ -105,7 +156,12 @@ public: CStandardFlexTable* inTable, const STableCell& inCell, const SMouseDownEvent& inMouseDown); +protected: + // The destructor is protected because the right way to delete is is to call either + // NoteSingleClick() or NoteDoubleClick(); virtual ~CClickTimer(); + +public: void NoteDoubleClick(); void NoteSingleClick(); TableIndexT GetClickedRow() { return mCell.row; } @@ -119,6 +175,7 @@ protected: CStandardFlexTable* mTable; STableCell mCell; SMouseDownEvent mMouseDown; // Can't be a reference, orig. is on the stack & dies + Boolean mBusyDeleting; }; // class CClickTimer //---------------------------------------------------------------------------------------- @@ -130,6 +187,7 @@ CClickTimer::CClickTimer( : mTable(inTable) , mCell(inCell) , mMouseDown(inMouseDown) +, mBusyDeleting(false) { mTable->mClickTimer = this; ReverseTheHilite(); // fake a new selection (temporarily). @@ -164,14 +222,23 @@ void CClickTimer::NoteDoubleClick() void CClickTimer::NoteSingleClick() //---------------------------------------------------------------------------------------- { + // Avoid reentrancy when we call mTable->ClickSelect(). + if (mBusyDeleting) + return; + mBusyDeleting = true; try { - // ReverseTheHilite(); // Show the selection again +#if 0 + //ReverseTheHilite(); // Show the selection again // The hiliting is now correct. Turn off hiliting to avoid a double flash. mTable->SetHiliteDisabled(true); mTable->SetFancyDoubleClick(false); mTable->ClickSelect(mCell, mMouseDown); mTable->SetFancyDoubleClick(true); +#else + mTable->SetHiliteDisabled(true); + mTable->LTableView::ClickSelect(mCell, mMouseDown); +#endif } catch (...) { @@ -215,7 +282,7 @@ CStandardFlexTable::CStandardFlexTable(LStream *inStream) , LDragAndDrop(GetMacPort(), this) , LCommander() , LBroadcaster() -//, CQAPartnerTableMixin(this) +, CQAPartnerTableMixin(this) , mTableHeaderListener(this) , mTableHeader(NULL) , mSelectionList(NULL) @@ -225,6 +292,7 @@ CStandardFlexTable::CStandardFlexTable(LStream *inStream) , mDropRow(LArray::index_Bad) , mIsInternalDrop(false) , mIsDropBetweenRows(false) +, mAllowDropAfterLastRow(true) , mNameEditor(NULL) , mRowBeingEdited(0) , mInlineListener(this) @@ -240,7 +308,8 @@ CStandardFlexTable::CStandardFlexTable(LStream *inStream) CStandardFlexTable::~CStandardFlexTable() //---------------------------------------------------------------------------------------- { - delete mClickTimer; + if (mClickTimer) + mClickTimer->NoteSingleClick(); } // CStandardFlexTable::~CStandardFlexTable //---------------------------------------------------------------------------------------- @@ -271,9 +340,11 @@ void CStandardFlexTable::FinishCreateSelf() // If an editor for in-place editing exists, find it. Don't worry if one can't be found. mNameEditor = dynamic_cast(FindPaneByID(paneID_InlineEdit)); - if ( mNameEditor ) { - mNameEditor->AddListener ( &mInlineListener ); + if (mNameEditor) + { + mNameEditor->AddListener(&mInlineListener); mNameEditor->SetGrowableBorder(true); + mNameEditor->AddAttachment(new CPasteSnooper(MAKE_RETURNS_SPACES)); } } // CStandardFlexTable::FinishCreateSelf @@ -379,11 +450,12 @@ void CStandardFlexTable::SetUpTableHelpers() { SetTableGeometry( new LFlexTableGeometry(this, mTableHeader) ); SetTableSelector( new LTableRowSelector(this)); - // NOTE: There is a dependency between LTableRowSelector and CThreadView - // because CThreadView::DoSelectThread() needs to select several rows at once. + // NOTE: There is a dependency between LTableRowSelector and + // CThreadView because CThreadView::DoSelectThread() needs to + // select several rows at once. // standard keyboard navigation. - AddAttachment( new CTableKeyAttachment(this) ); + AddAttachment( new CTableRowKeyAttachment(this) ); // We don't need table storage. It's safe to have a null one. // It is NOT safe, to call SetTableStorage(NULL), as its // implementation in LTableView does not check against NULL. @@ -428,7 +500,7 @@ void CStandardFlexTable::DrawSelf() } // CStandardFlexTable::DrawSelf //---------------------------------------------------------------------------------------- -TableIndexT CStandardFlexTable::CountExtraRowsControlledByCell(const STableCell& /*inCell*/) const +TableIndexT CStandardFlexTable::CountExtraRowsControlledByCell(const STableCell&) const //---------------------------------------------------------------------------------------- { return 0; @@ -501,8 +573,13 @@ Boolean CStandardFlexTable::GetHiliteTextRect( return false; cell.col = mCols; Rect cellRect; - if (!GetLocalCellRect(cell, cellRect)) - return false; + // Its inadequate to just use the mCols of the right most cell since if it is not visible + // GetLocalCellRect will return false + while (!GetLocalCellRect(cell, cellRect)) + { + cell.col--; + Assert_( cell.col > 0 ); + } outRect.right = cellRect.right; return true; } // CStandardFlexTable::GetHiliteTextRect @@ -515,6 +592,8 @@ Boolean CStandardFlexTable::GetIconRect( //---------------------------------------------------------------------------------------- { GetDropFlagRect(inLocalRect, outRect); + if (outRect.right > outRect.left) // have a drop flag + outRect.right -= kDropIconWastedSpace; outRect.left = outRect.right + kIconMargin + kIndentPerLevel * GetNestedLevel(inCell.row); outRect.right = outRect.left + kIconWidth; @@ -557,24 +636,24 @@ void CStandardFlexTable::HiliteRow( } // CStandardFlexTable::HiliteRow //---------------------------------------------------------------------------------------- -void CStandardFlexTable :: DoHiliteRgn( RgnHandle inHiliteRgn ) const +void CStandardFlexTable::DoHiliteRgn( RgnHandle inHiliteRgn ) const // Hilite the given area using the system hilite color. Override this to do // something different (like not use the hilite color). //---------------------------------------------------------------------------------------- { UDrawingUtils::SetHiliteModeOn(); // Don't use hilite color, except for inline editing. ::InvertRgn(inHiliteRgn); -} // CStandardFlexTable :: DoHiliteRgn +} // CStandardFlexTable: DoHiliteRgn //---------------------------------------------------------------------------------------- -void CStandardFlexTable :: DoHiliteRect( const Rect & inHiliteRect ) const +void CStandardFlexTable::DoHiliteRect( const Rect & inHiliteRect ) const // Hilite the given area using the system hilite color. Override this to do // something different (like not use the hilite color). //---------------------------------------------------------------------------------------- { UDrawingUtils::SetHiliteModeOn(); // Don't use hilite color, except for inline editing. ::InvertRect(&inHiliteRect); -} // CStandardFlexTable :: DoHiliteRect +} // CStandardFlexTable::DoHiliteRect //---------------------------------------------------------------------------------------- void CStandardFlexTable::Click(SMouseDownEvent &inMouseDown) @@ -598,7 +677,7 @@ void CStandardFlexTable::Click(SMouseDownEvent &inMouseDown) Boolean CStandardFlexTable::ClickDropFlag( const STableCell &inCell, const SMouseDownEvent &inMouseDown) -// Handle drop-flag ("twistee icon") clicks. Return true if handled. +// Handle drop-flag ("twistie icon") clicks. Return true if handled. //---------------------------------------------------------------------------------------- { Boolean isCellExpanded; @@ -607,51 +686,33 @@ Boolean CStandardFlexTable::ClickDropFlag( Rect cellRect, flagRect; GetLocalCellRect(inCell, cellRect); GetDropFlagRect(cellRect, flagRect); - if (::PtInRect(inMouseDown.whereLocal, &flagRect)) + if (::PtInRect(inMouseDown.whereLocal, &flagRect) && FocusDraw()) { - ApplyForeAndBackColors(); - if (FocusDraw() && LDropFlag::TrackClick(flagRect, inMouseDown.whereLocal, isCellExpanded)) + Rect clipRect = flagRect; + clipRect.right -= kDropIconWastedSpace; + StClipRgnState clip(clipRect); + if (LDropFlag::TrackClick(flagRect, inMouseDown.whereLocal, isCellExpanded)) SetCellExpansion(inCell, !isCellExpanded); return true; } } return false; -} +} // CStandardFlexTable::ClickDropFlag //---------------------------------------------------------------------------------------- -Boolean CStandardFlexTable::ClickSelect( +Boolean CStandardFlexTable::HandleFancyDoubleClick( const STableCell &inCell, const SMouseDownEvent &inMouseDown) +// Fancy double-click behavior. There are two reasons for this new feature of 4.5: +// ₯ Double-clicking a thread in a message thread view (for example) should +// not select the new item, because then the selected message would load in +// the message pane of the thread window as well as in the newly-opened message +// window. The user would prefer to maintain the message displayed in the current +// window, and open the double-clicked, different message in the separate window. +// ₯ Selecting a new row can be expensive, because it causes the message/folder +// to load. This loading usually unwanted after a double-click. //---------------------------------------------------------------------------------------- { - Rect cellRect; - GetLocalCellRect(inCell, cellRect); - - FocusDraw(); //to be on the safe side - - // compute the text and icon rectangles and if the click is in them - Rect textRect, iconRect; - GetHiliteTextRect ( inCell.row, textRect ); - GetIconRect ( inCell, cellRect, iconRect ); - bool clickIsInIcon = ::PtInRect(inMouseDown.whereLocal, &iconRect); - bool clickIsInTitle = ::PtInRect(inMouseDown.whereLocal, &textRect); - - // If the click is outside of the icon/title, or if it is in the title (and in-place editing is on), - // then temporarily turn off the fancy double-click stuff since we don't want it to happen. - bool savedFancyDoubleClick = mFancyDoubleClick; - if ( !clickIsInIcon && !clickIsInTitle ) - mFancyDoubleClick = false; // click was outside icon&title - if ( clickIsInTitle && mNameEditor ) - mFancyDoubleClick = false; // click was in title and we're doing inplace editing - - // Fancy double-click behavior. There are two reasons for this new feature of 5.0: - // ₯ Double-clicking a thread in a message thread view (for example) should - // not select the new item, because then the selected message would load in - // the message pane of the thread window as well as in the newly-opened message - // window. The user would prefer to maintain the message displayed in the current - // window, and open the double-clicked, different message in the separate window. - // ₯ Selecting a new row can be expensive, because it causes the message/folder - // to load. This loading usually unwanted after a double-click. if (mFancyDoubleClick && !CellIsSelected(inCell) && (inMouseDown.macEvent.modifiers & shiftKey) == 0 @@ -674,8 +735,45 @@ Boolean CStandardFlexTable::ClickSelect( mClickTimer->NoteDoubleClick(); OpenRow(inCell.row); } - return false; + return true; } + return false; +} // CStandardFlexTable::HandleFancyDoubleClick + +//---------------------------------------------------------------------------------------- +Boolean CStandardFlexTable::ClickSelect( + const STableCell &inCell, + const SMouseDownEvent &inMouseDown) +//---------------------------------------------------------------------------------------- +{ + Rect cellRect; + GetLocalCellRect(inCell, cellRect); + + FocusDraw(); // To be on the safe side + + // Compute the text and icon rectangles and if the click is in them + Rect textRect, iconRect; + GetHiliteTextRect(inCell.row, textRect); + GetIconRect(inCell, cellRect, iconRect); + Boolean clickIsInIcon = ::PtInRect(inMouseDown.whereLocal, &iconRect); + Boolean clickIsInTitle = ::PtInRect(inMouseDown.whereLocal, &textRect); + + // If the click is outside of the icon/title, or if it is in the title + // (and in-place editing is on), then temporarily turn off the fancy double-click + // stuff since we don't want it to happen. Use a StValueChanger stack object, + // which will restore the state even on an exception or return statement. + StValueChanger changer(mFancyDoubleClick, mFancyDoubleClick); + if (!clickIsInIcon && !clickIsInTitle) + mFancyDoubleClick = false; // click was outside icon&title + if (clickIsInTitle && mNameEditor) + mFancyDoubleClick = false; // click was in title and we're doing inplace editing + +#define CHECK_DRAGS_BEFORE_DOUBLECLICK 1 +#if !CHECK_DRAGS_BEFORE_DOUBLECLICK + // The way it was before 98/04/03 + if (HandleFancyDoubleClick(inCell, inMouseDown)) + return false; +#endif // 0, 1, >=2 rows selected are the values that change command-enabling configurations. int selectedRowCountForCommandStatus = GetSelectedRowCount(); @@ -683,13 +781,132 @@ Boolean CStandardFlexTable::ClickSelect( selectedRowCountForCommandStatus = 2; Boolean result = false; - // - // There are two cases here: user clicks in the hilite column and they don't click in the - // hilite column. If they do, only select if the click is in the icon or the icon text. Any - // other click w/in that column unselects or start a marquee selection. If they click outside - // the hilite column, process as normal. - // - if ( (inCell.col != GetHiliteColumn()) || clickIsInIcon || clickIsInTitle ) { + // There are two cases here: user clicks in the hilite column and they don't click in + // the hilite column. If they do, only select if the click is in the icon or the icon + // text. Any other click w/in that column unselects or start a marquee selection. If + // they click outside the hilite column, process as normal. + + if (inCell.col != GetHiliteColumn() || clickIsInIcon || clickIsInTitle) + { +#if CHECK_DRAGS_BEFORE_DOUBLECLICK + // Experimental, new way 98/04/03. The restraints are: + // ₯ Drags should be checked first. + // ₯ In the spirit of fancy double click, drags of unselected items + // should be allowed if fancyDoubleClick is in force. + // ₯ Fancy double-click must be checked before calling LTableView::ClickSelect + // (because the FDC detector calls it eventually as appropriate). + // ₯ Selection must occur before context menus are informed of the click. + // This is because context menus perform commands on the current selection. + // Therefore, + // DRAG before DOUBLE-CLICK DETECTION before SELECTION before CONTEXT MENUS. + + // Preflight to determine drag/click/contextmenu. + CContextMenuAttachment::EClickState mouseResult + = CContextMenuAttachment::WaitMouseAction( + inMouseDown.whereLocal, + inMouseDown.macEvent.when); + + if (! CellInitiatesDrag(inCell) && mouseResult == CContextMenuAttachment::eMouseDragging) + mouseResult = CContextMenuAttachment::eMouseTimeout; + switch (mouseResult) + { + case CContextMenuAttachment::eMouseDragging: + // We are dragging, and may be dragging a non-selected item, which is + // permissible now. + // First cancel any previous double-click in progress. This will select + // the cell previously clicked, by the way. + if (mClickTimer) + mClickTimer->NoteSingleClick(); + if (!mFancyDoubleClick) + { + // Normal case + LTableView::ClickSelect(inCell, inMouseDown); + DragSelection(inCell, inMouseDown); + result = true; + } + else if (CellIsSelected(inCell)) + { + DragSelection(inCell, inMouseDown); + // cell and the other selected cells + result = false; + } + else if (userCanceledErr == DragRow(inCell.row, inMouseDown)) + { + // We tried to drag the unselected row. + // userCanceledErr means the drag did not really occur. Select the + // item in this case. + LTableView::ClickSelect(inCell, inMouseDown); + result = true; + } + goto cmd_status; // because we changed the selection. + + case CContextMenuAttachment::eMouseTimeout: + // We are showing the context menu + // First cancel any previous double-click in progress. This will select + // the cell previously clicked, by the way. + if (mClickTimer) + mClickTimer->NoteSingleClick(); + + CContextMenuAttachment::SExecuteParams params; + params.inMouseDown = &inMouseDown; + + // First call ClickSelect to select the cell before showing the menu + LTableView::ClickSelect(inCell, inMouseDown); + + // If the preflight test is a sane strategy, then the call we will now + // make should always show the popup menu. However, the user may + // examine the popup menu and track out. The call should then return + // true, and we should handle it like a click by falling through: + if (!ExecuteAttachments( + CContextMenuAttachment::msg_ContextMenu, + (void*)¶ms)) + { + break; + } + // else fall through and handle the click + + case CContextMenuAttachment::eMouseUpEarly: + + // CLICK! + if (HandleFancyDoubleClick(inCell, inMouseDown)) + return false; + if (!LTableView::ClickSelect(inCell, inMouseDown)) + return false; + // become target + if (!IsTarget()) + SwitchTarget(this); + + // Check if the click is in the title of the icon. If so, and an editor is + // present and we're not doing a shift-selection extension and it's not a + // double click then invoke the inline editor. Otherwise process the click + // normally. (whew!) + // + // The reason for not inline editing on a double-click is that it allows the + // user to double-click anywhere on the item to open it, like in the Finder. + // Doing a double-click to edit an item doesn't make sense and the user + // would get confused. + // ₯₯₯Double click check doesn't work right now.....will fix later....₯₯₯ + // open selection if we've got the right click count + if (clickIsInTitle + && mNameEditor + && !(inMouseDown.macEvent.modifiers & shiftKey) + && GetClickCount() != 2) + CDeferredTaskManager::Post1( + new CDeferredInlineEditTask(this, inCell, textRect), + this); + if (GetClickCount() == mClickCountToOpen) + { + // Cancel inline editing. Probably redundant. + if (mNameEditor) + mNameEditor->UpdateEdit(nil, nil, nil); + OpenSelection(); + } + result = true; + + break; + } // switch + +#else if (LTableView::ClickSelect(inCell, inMouseDown)) { // Handle it ourselves if the popup attachment doesn't want it. @@ -706,19 +923,23 @@ Boolean CStandardFlexTable::ClickSelect( if (!IsTarget()) SwitchTarget(this); - // check if the click is in the title of the icon. If so, and an editor is + // Check if the click is in the title of the icon. If so, and an editor is // present and we're not doing a shift-selection extension and it's not a - // double click then invoke the inline editor. Otherwise process the click normally. - // (whew!) + // double click then invoke the inline editor. Otherwise process the click + // normally. (whew!) // // The reason for not inline editing on a double-click is that it allows the - // user to double-click anywhere on the item to open it, like in the Finder. Doing - // a double-click to edit an item doesn't make sense and the user would get - // confused. ₯₯₯Double click check doesn't work right now.....will fix later....₯₯₯ - if ( clickIsInTitle && mNameEditor && !(inMouseDown.macEvent.modifiers & shiftKey) - && GetClickCount() != 2 ) - DoInlineEditing ( inCell, textRect ); - else { + // user to double-click anywhere on the item to open it, like in the Finder. + // Doing a double-click to edit an item doesn't make sense and the user + // would get confused. + // ₯₯₯Double click check doesn't work right now.....will fix later....₯₯₯ + if (clickIsInTitle + && mNameEditor + && !(inMouseDown.macEvent.modifiers & shiftKey) + && GetClickCount() != 2) + DoInlineEditing(inCell, textRect); + else + { // open selection if we've got the right click count if (GetClickCount() == mClickCountToOpen) OpenSelection(); @@ -727,14 +948,18 @@ Boolean CStandardFlexTable::ClickSelect( result = true; } } +#endif // CHECK_DRAGS_BEFORE_DOUBLECLICK } // if click in icon or text - else { + else + { // since the click is not in the icon and not in the text, the selection should be // cleared before we try to show any context menus. This is possibly faster than // calling UnselectAllCells() because it only iterates over the selection, not the whole table. static const Rect empty = { 0, 0, 0, 0 }; UnselectCellsNotInSelectionOutline(empty); + if (mClickTimer) + mClickTimer->NoteSingleClick(); CContextMenuAttachment::SExecuteParams params; params.inMouseDown = &inMouseDown; if (ExecuteAttachments(CContextMenuAttachment::msg_ContextMenu, (void*)¶ms)) @@ -742,7 +967,6 @@ Boolean CStandardFlexTable::ClickSelect( } cmd_status: - mFancyDoubleClick = savedFancyDoubleClick; int newSelectedRowCountForCommandStatus = GetSelectedRowCount(); if (newSelectedRowCountForCommandStatus > 2) newSelectedRowCountForCommandStatus = 2; @@ -767,10 +991,10 @@ void CStandardFlexTable::ClickSelf(const SMouseDownEvent &inMouseDown) if (ClickDropFlag(hitCell, inMouseDown)) return; - // See if the cell selects. If so go ahead and process it (could be a drag or selection - // outline). If the cell does not select, the cell may still really want the click (like - // the "marked read message" column in mail/news. If it does, give it the click, otherwise - // start doing a marquee selection. + // See if the cell selects. If so go ahead and process it (could be a drag or + // selection outline). If the cell does not select, the cell may still really want + // the click (like the "marked read message" column in mail/news. If it does, give + // it the click, otherwise start doing a marquee selection. if ( CellSelects(hitCell) ) { if ( ClickSelect(hitCell, inMouseDown) ) ClickCell(hitCell, inMouseDown); @@ -782,10 +1006,12 @@ void CStandardFlexTable::ClickSelf(const SMouseDownEvent &inMouseDown) HandleSelectionTracking(inMouseDown); } } - else { - // since the click is not in any cell, the selection should be cleared before we try to - // show the context menus. This is possibly faster than calling UnselectAllCells() because - // it only iterates over the selection, not the whole table. + else + { + // since the click is not in any cell, the selection should be cleared before + // we try to show the context menus. This is possibly faster than calling + // UnselectAllCells() because it only iterates over the selection, not the + // whole table. static const Rect empty = { 0, 0, 0, 0 }; UnselectCellsNotInSelectionOutline(empty); @@ -793,52 +1019,51 @@ void CStandardFlexTable::ClickSelf(const SMouseDownEvent &inMouseDown) params.inMouseDown = &inMouseDown; if ( ExecuteAttachments(CContextMenuAttachment::msg_ContextMenu, (void*)¶ms) ) HandleSelectionTracking(inMouseDown); - } - + } } // CStandardFlexTable::ClickSelf - -// -// DoInlineEditing -// +//---------------------------------------------------------------------------------------- +void CStandardFlexTable::DoInlineEditing( const STableCell &inCell ) // Perform the necessary setup for inline editing of a row's main text and then show the edit field. // This version of the routine is public and does not require any external knowledge of table internals // besides the cell that we should edit. Most of the work is done by calling the routine below -// -void -CStandardFlexTable::DoInlineEditing ( const STableCell &inCell ) +//---------------------------------------------------------------------------------------- { Rect textRect; - GetHiliteTextRect ( inCell.row, textRect ); - DoInlineEditing ( inCell, textRect ); - + GetHiliteTextRect( inCell.row, textRect ); + DoInlineEditing( inCell, textRect ); } // DoInlineEditing -// -// DoInlineEditing -// -// Perform the necessary setup for inline editing of a row's main text and then show the edit field -// -void -CStandardFlexTable::DoInlineEditing ( const STableCell &inCell, Rect & inTextRect ) +//---------------------------------------------------------------------------------------- +void CStandardFlexTable::DoInlineEditing(const STableCell &inCell, Rect& inTextRect) +// Perform the necessary setup for inline editing of a row's main text and then show +// the edit field +//---------------------------------------------------------------------------------------- { - mRowBeingEdited = inCell.row; - if ( !CanDoInlineEditing() ) { // bail if inline editing is temporarily turned off + mRowBeingEdited = inCell.row; // do this first so derived classes can check it. + if (!CanDoInlineEditing()) // bail if inline editing is temporarily turned off + { mRowBeingEdited = LArray::index_Bad; return; } -#if 0 - // erase the text rectangle so that when the text field shrinks, you won't see the old name - // behind it. This is kinda skanky, but we need to make sure we draw the background color - // correctly. - //₯₯₯This doesn't work. + // Erase the text rectangle so that when the text field shrinks, you won't see the + // old name behind it. This is kinda skanky, but we need to make sure we draw the + // background color correctly. + // I also believe it is unnecessary, because it didn't solve the problem of the cell + // being redrawn on a refresh, so and so that had to be done anyway. A better way + // is to invalidate the rectangle, and make the table smart about not drawing the + // text when editing is going on. - jrm 98/04/02 + #if 1 + ::InvalRect(&inTextRect); // table, which is inline-edit aware, will erase the text. + SetHiliteDisabled(true); // Don't draw hilite rects, either. + #else RGBColor backColor; - ::GetCPixel ( inTextRect.right - 1, inTextRect.top - 1, &backColor ); + ::GetCPixel(inTextRect.right - 1, inTextRect.top, &backColor); ::RGBBackColor(&backColor); - ::EraseRect ( &inTextRect ); -#endif + ::EraseRect(&inTextRect); + #endif SPoint32 imagePoint; LocalToImagePoint(topLeft(inTextRect), imagePoint); @@ -851,16 +1076,19 @@ CStandardFlexTable::DoInlineEditing ( const STableCell &inCell, Rect & inTextRec SelectCell(STableCell(mRowBeingEdited, GetHiliteColumn())); SetNotifyOnSelectionChange(true); - char nameString[256]; - GetHiliteText(mRowBeingEdited, nameString, 255, &inTextRect); - - mNameEditor->UpdateEdit(LStr255(nameString), &imagePoint, nil); + // Need 512 bytes for the text result, because of the &*(&^% way GetHiliteText + // works now. + char nameString[512]; + GetHiliteText(mRowBeingEdited, nameString, sizeof(nameString), &inTextRect); + InsetRect(&inTextRect, -2, -2); + inTextRect.bottom += 2; + mNameEditor->ResizeFrameTo(inTextRect.right - inTextRect.left, + inTextRect.bottom - inTextRect.top, true); + mNameEditor->UpdateEdit(CStr255(nameString), &imagePoint, nil); SelectionChanged(); - } // DoInlineEditing - //---------------------------------------------------------------------------------------- Boolean CStandardFlexTable::CellSelects(const STableCell& /*inCell*/) const // Determines if a cell is allowed to select the row. @@ -869,18 +1097,20 @@ Boolean CStandardFlexTable::CellSelects(const STableCell& /*inCell*/) const return true; } // CStandardFlexTable::CellSelects - //---------------------------------------------------------------------------------------- void CStandardFlexTable::HandleSelectionTracking ( const SMouseDownEvent & inMouseDown ) // Set up everything to start tracking a selection marquee //---------------------------------------------------------------------------------------- { + if (mClickTimer) + mClickTimer->NoteSingleClick(); + // bail if the table specifically doesn't want the tracking. if ( !TableDesiresSelectionTracking() ) return; // Click is outside of any Cell. Unselect everything if the shift key is up. - if ( !(inMouseDown.macEvent.modifiers & shiftKey) ) + if ( !(inMouseDown.macEvent.modifiers & shiftKey) && !(inMouseDown.macEvent.modifiers & cmdKey)) UnselectAllCells(); // track the mouse for doing drag selection @@ -897,34 +1127,44 @@ void CStandardFlexTable::TrackSelection( const SMouseDownEvent & inMouseDown ) { Point originalLoc = inMouseDown.whereLocal; - Rect selectionRect = { 0, 0, 0, 0 }, iconHotSpotRect = { 0, 0, 0, 0 }; - Rect cellHotSpotRect = { 0, 0, 0, 0 }; + Rect selectionRect = { 0, 0, 0, 0 }; + Rect cellHotSpotRect = { 0, 0, 0, 0 }, iconHotSpotRect = { 0, 0, 0, 0 }; + + Boolean shiftKeyDown = (inMouseDown.macEvent.modifiers & shiftKey) != 0; + Boolean cmdKeyDown = (inMouseDown.macEvent.modifiers & cmdKey) != 0; Point lastMousePoint = { 0, 0 }, curMousePoint = { 0, 0 }, curOrigin = { 0, 0 }; - UInt32 currentRow = 0L, currentCol = 0L, maxRows = 0L, maxColumns = 0L; + TableIndexT currentRow = 0L, currentCol = 0L, maxRows = 0L, maxColumns = 0L; - STableCell topLeftCell( 0, 0 ); - STableCell botRightCell( 0, 0 ); - STableCell currentCell( 0, 0 ); + // may get a null selector for some tables not using the table row selector + LTableRowSelector *theSelector = dynamic_cast(GetTableSelector()); + StRegion previousSelection; - StColorPenState oldPenState; + if (theSelector != nil) + theSelector->MakeSelectionRegion(previousSelection, GetHiliteColumn()); //LTableRowSelector inherits from LArray, so can call copy constructor + + StColorPenState oldPenState; + + mTableView->GetTableSize( maxRows, maxColumns ); + + STableCell topLeftCell( 0, 0 ); + STableCell botRightCell( 0, 0 ); + STableCell oldTopLeftCell( maxRows, 0 ); // initial values important for optimization below + STableCell oldBotRightCell( 1, 0 ); + + FocusDraw(); - // mTableView->GetTableSize( maxRows, maxColumns ); - SetNotifyOnSelectionChange(false); - while ( ::StillDown() ) { - + while ( ::StillDown() ) + { ::GetMouse( &curMousePoint ); - if ( (curMousePoint.v != lastMousePoint.v) || (curMousePoint.h != lastMousePoint.h) ) { - - currentCell.row = 0; - currentCell.col = 0; - + if (curMousePoint.v != lastMousePoint.v || curMousePoint.h != lastMousePoint.h) + { ::PenPat( &qd.gray ); ::PenMode( patXor ); - ::PenSize( 2, 2 ); + ::PenSize( 1, 1 ); if ( !::EmptyRect(&selectionRect) ) ::FrameRect( &selectionRect ); @@ -950,29 +1190,120 @@ void CStandardFlexTable::TrackSelection( const SMouseDownEvent & inMouseDown ) if ( AutoScrollImage(curMousePoint) ) FocusDraw(); - UnselectCellsNotInSelectionOutline(selectionRect); + FetchIntersectingCells( selectionRect, topLeftCell, botRightCell ); + + STableCell theCell(0, GetHiliteColumn()); + + //Do this inline now, because we need to get a some more local variables + //UnselectCellsNotInSelectionOutline(selectionRect); + + if (!shiftKeyDown && !cmdKeyDown) + { + // Deselect cells not in selection rect + while ( GetNextSelectedRow(theCell.row) ) + { + if ( !HitCellHotSpot( theCell, selectionRect) ) + UnselectCell( theCell ); + } + } else if (shiftKeyDown) + { + // Only deselect cells that have left the current selection marquee, + // i.e. those that are neither in the marquee, nor the previous selection + while ( GetNextSelectedRow(theCell.row) ) + { + Point thePt; + theCell.ToPoint(thePt); + if ( !HitCellHotSpot( theCell, selectionRect) && !::PtInRgn(thePt, previousSelection)) { + UnselectCell( theCell ); + } + } + + } else if (cmdKeyDown) + { + // Put the selection back to its previous state for cells that are no longer + // covered by the marquee + + // optimization to reduce the amount of looping here + TableIndexT extentTop = MIN(topLeftCell.row, oldTopLeftCell.row); + TableIndexT extentBottom = MAX(botRightCell.row, oldBotRightCell.row); + + if (extentBottom > mRows) + extentBottom = mRows; + + theCell.row = extentTop; + + while ( theCell.row <= extentBottom) + { + if ( !HitCellHotSpot( theCell, selectionRect) ) + { + Point thePt; + theCell.ToPoint(thePt); + Boolean alreadySelected = CellIsSelected( theCell ); + if (::PtInRgn(thePt, previousSelection)) { + if ( !alreadySelected) SelectCell( theCell ); + } else { + if ( alreadySelected ) UnselectCell( theCell ); + } + } + theCell.row ++; + } + } + // find what cells are in w/in the rectangle and select them if the rectangle // encloses/touches the cell hot spot (usually the icon or icon text). - FetchIntersectingCells( selectionRect, topLeftCell, botRightCell ); - for ( currentRow = topLeftCell.row; currentRow <= botRightCell.row; currentRow++ ) { - for ( currentCol = topLeftCell.col; currentCol <= botRightCell.col; currentCol++ ) { - + + for ( currentRow = topLeftCell.row; currentRow <= botRightCell.row; currentRow++ ) + { + STableCell currentCell( currentRow, GetHiliteColumn() ); + + // We are assuming now that all descendents from CStandardFlex table + // have row-based selection. Since this assumption is also made elsewhere + // (e.g. in xxxxx) we should be safe. The class hierarchy should make it + // explicit though. + /* + for ( currentCol = topLeftCell.col; currentCol <= botRightCell.col; currentCol++ ) + { currentCell.row = currentRow; currentCell.col = currentCol; - - if ( !CellIsSelected(currentCell) && HitCellHotSpot(currentCell, selectionRect) ) { + if (!CellIsSelected(currentCell) && HitCellHotSpot(currentCell, selectionRect)) SelectCell( currentCell ); + } // for each column + */ + + if (cmdKeyDown) + { + // When the marquee hits a cell, toggle the select for that cell + + if ( HitCellHotSpot(currentCell, selectionRect) ) + { + Point thePt; + currentCell.ToPoint(thePt); + + if ( ::PtInRgn(thePt, previousSelection) ) + UnselectCell( currentCell ); + else + SelectCell( currentCell ); } - } // for each column + } else + { + if (!CellIsSelected(currentCell) && HitCellHotSpot(currentCell, selectionRect)) + SelectCell( currentCell ); + } + } // for each row + FocusDraw(); + + oldTopLeftCell = topLeftCell; + oldBotRightCell = botRightCell; + oldPenState.Save(); ::PenPat( &qd.gray ); ::PenMode( patXor ); - ::PenSize( 2, 2 ); + ::PenSize( 1, 1 ); ::FrameRect( &selectionRect ); } // if mouse has moved @@ -983,8 +1314,17 @@ void CStandardFlexTable::TrackSelection( const SMouseDownEvent & inMouseDown ) SelectionChanged(); if ( !::EmptyRect(&selectionRect) ) + { + FocusDraw(); // who knows what went on inside "SelectionChanged()"? + + ::PenPat( &qd.gray ); + ::PenMode( patXor ); + ::PenSize( 1, 1 ); ::FrameRect( &selectionRect ); + oldPenState.Normalize(); + } + } // TrackSelection //---------------------------------------------------------------------------------------- @@ -1012,6 +1352,24 @@ void CStandardFlexTable::UnselectCellsNotInSelectionOutline( const Rect & inSele } // UnselectCellsNotInSelectionOutline +//---------------------------------------------------------------------------------------- +void CStandardFlexTable::GetLocalCellRectAnywhere( const STableCell &inCell, Rect &outCellRect) const +// Unlike GetLocalCellRect(), this returns a valid rectangle whether or not this cell +// is in view +//---------------------------------------------------------------------------------------- +{ + Int32 cellLeft, cellTop, cellRight, cellBottom; + mTableGeometry->GetImageCellBounds(inCell, cellLeft, cellTop, cellRight, cellBottom); + + SPoint32 imagePt; + imagePt.h = cellLeft; + imagePt.v = cellTop; + ImageToLocalPoint(imagePt, topLeft(outCellRect)); + outCellRect.right = outCellRect.left + (cellRight - cellLeft); + outCellRect.bottom = outCellRect.top + (cellBottom - cellTop); + +} + //---------------------------------------------------------------------------------------- Boolean CStandardFlexTable::HitCellHotSpot( const STableCell &inCell, const Rect &inTotalSelectionRect ) @@ -1020,25 +1378,33 @@ Boolean CStandardFlexTable::HitCellHotSpot( const STableCell &inCell, const Rect Boolean result = false; TableIndexT hiliteCol = GetHiliteColumn(); - FocusDraw(); //to be on the safe side + //FocusDraw(); //to be on the safe side, but it's too slow - if ( hiliteCol ) { + if ( hiliteCol ) + { if ( hiliteCol == inCell.col ) { Rect cellRect; - GetLocalCellRect(inCell, cellRect); + GetLocalCellRectAnywhere(inCell, cellRect); + Rect textRect, iconRect; - GetHiliteTextRect ( inCell.row, textRect ); - GetIconRect ( inCell, cellRect, iconRect ); + GetHiliteTextRect( inCell.row, textRect ); + GetIconRect( inCell, cellRect, iconRect ); if ( ::SectRect(&textRect, &inTotalSelectionRect, &textRect) || ::SectRect(&iconRect, &inTotalSelectionRect, &iconRect) ) result = true; } } - else { - Rect cellRect = { 0, 0, 0, 0 }; - GetLocalCellRect( inCell, cellRect ); - result = ::SectRect( &cellRect, &inTotalSelectionRect, &cellRect ); + else // check for any overlap with the row + { + Rect leftCellRect = { 0, 0, 0, 0 }, rightCellRect = { 0, 0, 0, 0 }; + + STableCell leftCell(inCell.row, 1); + STableCell rightCell(inCell.row, mCols); + GetLocalCellRectAnywhere( leftCell, leftCellRect ); + GetLocalCellRectAnywhere( rightCell, rightCellRect ); + leftCellRect.right = rightCellRect.right; + result = ::SectRect( &leftCellRect, &inTotalSelectionRect, &leftCellRect ); } return result; @@ -1066,6 +1432,43 @@ void CStandardFlexTable::DontBeTarget() LCommander::DontBeTarget(); } // CStandardFlexTable::DontBeTarget +// ===== BEGINCEXTable Refugees + +//---------------------------------------------------------------------------------------- +void CStandardFlexTable::RefreshRowRange(TableIndexT inStartRow, TableIndexT inEndRow) +//---------------------------------------------------------------------------------------- +{ + TableIndexT topRow, botRow; + if ( inStartRow < inEndRow ) { + topRow = inStartRow; botRow = inEndRow; + } else { + topRow = inEndRow; botRow = inStartRow; + } + RefreshCellRange(STableCell(topRow, 1), STableCell(botRow, mCols)); +} + +//---------------------------------------------------------------------------------------- +void CStandardFlexTable::ReadSavedTableStatus(LStream *inStatusData) +//---------------------------------------------------------------------------------------- +{ + if ( inStatusData != nil ) + { + + Assert_(mTableHeader != nil); + + mTableHeader->ReadColumnState(inStatusData); + } +} + +//---------------------------------------------------------------------------------------- +void CStandardFlexTable::WriteSavedTableStatus(LStream *outStatusData) +//---------------------------------------------------------------------------------------- +{ + Assert_(mTableHeader != nil); + mTableHeader->WriteColumnState(outStatusData); +} +// ===== END CEXTable Refugee functions + //---------------------------------------------------------------------------------------- PaneIDT CStandardFlexTable::GetCellDataType(const STableCell &inCell) const //---------------------------------------------------------------------------------------- @@ -1249,45 +1652,38 @@ TableIndexT CStandardFlexTable::GetHiliteColumn() const return LArray::index_Bad; // default is to hilite the whole row. } // CStandardFlexTable::GetHiliteColumn - -// -// ComputeItemDropAreas -// -// When a drag goes over a cell that contains a non-folder, divide the node in half. The top -// half will represent dropping above the item, the bottom after. -// -void -CStandardFlexTable :: ComputeItemDropAreas ( const Rect & inLocalCellRect, Rect & oTop, - Rect & oBottom ) +//---------------------------------------------------------------------------------------- +void CStandardFlexTable::ComputeItemDropAreas( + const Rect& inLocalCellRect, + Rect& outTop, + Rect& outBottom ) +// When a drag goes over a cell that contains a non-folder, divide the node in half. The +// top half will represent dropping above the item, the bottom after. +//---------------------------------------------------------------------------------------- { - oBottom = oTop = inLocalCellRect; - uint16 midPt = (oTop.bottom - oTop.top) / 2; - oTop.bottom = oTop.top + midPt; - oBottom.top = oTop.bottom + 1; - + outBottom = outTop = inLocalCellRect; + uint16 midPt = (outTop.bottom - outTop.top) / 2; + outTop.bottom = outTop.top + midPt; + outBottom.top = outTop.bottom + 1; } // ComputeItemDropAreas // ComputeItemDropAreas - -// -// ComputeFolderDropAreas -// -// When a drag goes over a cell that contains a folder, divide the cell area into 3 parts. The middle -// area, which corresponds to a drop on the folder takes up the majority of the cell space with the -// top and bottom areas (corresponding to drop before and drop after, respectively) taking up the rest -// at the ends. -// -void -CStandardFlexTable :: ComputeFolderDropAreas ( const Rect & inLocalCellRect, Rect & oTop, - Rect & oBottom ) +//---------------------------------------------------------------------------------------- +void CStandardFlexTable::ComputeFolderDropAreas( + const Rect& inLocalCellRect, + Rect& outTop, + Rect& outBottom ) +// When a drag goes over a cell that contains a folder, divide the cell area into 3 parts. +// The middle area, which corresponds to a drop on the folder takes up the majority of +// the cell space with the top and bottom areas (corresponding to drop before and drop +// after, respectively) taking up the rest at the ends. +//---------------------------------------------------------------------------------------- { const Uint8 capAreaHeight = 3; - - oBottom = oTop = inLocalCellRect; - oTop.bottom = oTop.top + capAreaHeight; - oBottom.top = oBottom.bottom - capAreaHeight; - -} // ComputeFolderDropAreas + outBottom = outTop = inLocalCellRect; + outTop.bottom = outTop.top + capAreaHeight; + outBottom.top = outBottom.bottom - capAreaHeight; +} // ComputeFolderDropAreas //---------------------------------------------------------------------------------------- void CStandardFlexTable::InsideDropArea(DragReference inDragRef) @@ -1316,7 +1712,7 @@ void CStandardFlexTable::InsideDropArea(DragReference inDragRef) // Find the index of where we want to drop the item and if it is between two rows // of if it is on a row (can only happen if row is a container). - bool newIsDropBetweenRows = false; + Boolean newIsDropBetweenRows = false; TableIndexT newDropRow = LArray::index_Bad; if ( rowMouseIsOver >= 1 ) { @@ -1371,15 +1767,20 @@ void CStandardFlexTable::InsideDropArea(DragReference inDragRef) HiliteDropRow(oldDropRow, mIsDropBetweenRows); mIsDropBetweenRows = newIsDropBetweenRows; - if (newDropRow > LArray::index_Bad) + if (newDropRow > LArray::index_Bad && newDropRow <= mRows) { mDropRow = newDropRow; // so that we'll hilite HiliteDropRow(newDropRow, mIsDropBetweenRows); } else + { mDropRow = LArray::index_Bad; + } } + if (! mAllowDropAfterLastRow) + mCanAcceptCurrentDrag = (mDropRow != LArray::index_Bad); + } // CStandardFlexTable::InsideDropArea //---------------------------------------------------------------------------------------- @@ -1471,6 +1872,7 @@ void CStandardFlexTable::DrawCell( localRect = insetRect; ::EraseRect(&inLocalRect); + // Save pen state ApplyTextStyle(inCell.row); if ( mRowBeingEdited != inCell.row ) DrawCellContents(inCell, insetRect); @@ -1619,30 +2021,31 @@ void CStandardFlexTable::ScrollImageBy( } // CStandardFlexTable::ScrollImageBy //---------------------------------------------------------------------------------------- -void CStandardFlexTable::DragSelection( +OSErr CStandardFlexTable::DragSelection( const STableCell& inCell, const SMouseDownEvent& inMouseDown ) //---------------------------------------------------------------------------------------- { #pragma unused(inCell) + if (!FocusDraw()) + return userCanceledErr; + DragReference dragRef = 0; - - if (!FocusDraw()) return; - + OSErr trackResult = noErr; try { StRegion dragRgn; OSErr err = ::NewDrag(&dragRef); ThrowIfOSErr_(err); AddSelectionToDrag(dragRef, dragRgn); - if (inMouseDown.macEvent.modifiers & optionKey != 0) + if ((inMouseDown.macEvent.modifiers & optionKey) != 0) { - CursHandle copyDragCursor = ::GetCursor(6608); // finder's copy-drag cursor + CursHandle copyDragCursor = ::GetCursor(curs_CopyDrag); // finder's copy-drag cursor if (copyDragCursor != nil) ::SetCursor(*copyDragCursor); } - (void) ::TrackDrag(dragRef, &(inMouseDown.macEvent), dragRgn); + trackResult = ::TrackDrag(dragRef, &(inMouseDown.macEvent), dragRgn); } catch( ... ) { @@ -1650,8 +2053,47 @@ void CStandardFlexTable::DragSelection( if (dragRef != 0) ::DisposeDrag(dragRef); + return trackResult; } // CStandardFlexTable::DragSelection +//---------------------------------------------------------------------------------------- +OSErr CStandardFlexTable::DragRow( + TableIndexT inRow, + const SMouseDownEvent& inMouseDown ) +//---------------------------------------------------------------------------------------- +{ + if (!FocusDraw()) + return userCanceledErr; + + DragReference dragRef = 0; + OSErr trackResult = noErr; + try + { + StRegion dragRgn; + OSErr err = ::NewDrag(&dragRef); + ThrowIfOSErr_(err); + AddRowToDrag(inRow, dragRef, dragRgn); + if ((inMouseDown.macEvent.modifiers & optionKey) != 0) + { + CursHandle copyDragCursor = ::GetCursor(curs_CopyDrag); // finder's copy-drag cursor + if (copyDragCursor != nil) + ::SetCursor(*copyDragCursor); + } + trackResult = ::TrackDrag(dragRef, &(inMouseDown.macEvent), dragRgn); + } + catch(OSErr err) + { + trackResult = err; + } + catch( ... ) + { + } + + if (dragRef != 0) + ::DisposeDrag(dragRef); + return trackResult; +} // CStandardFlexTable::DragRow + //---------------------------------------------------------------------------------------- void CStandardFlexTable::AddSelectionToDrag(DragReference inDragRef, RgnHandle inDragRgn) //---------------------------------------------------------------------------------------- @@ -1678,6 +2120,28 @@ void CStandardFlexTable::AddSelectionToDrag(DragReference inDragRef, RgnHandle i ::OffsetRgn(inDragRgn, p.h, p.v); } // CStandardFlexTable::AddSelectionToDrag +//---------------------------------------------------------------------------------------- +void CStandardFlexTable::AddRowToDrag( + TableIndexT inRow, + DragReference inDragRef, + RgnHandle inDragRgn) +//---------------------------------------------------------------------------------------- +{ + AddRowDataToDrag(inRow, inDragRef); + GetRowDragRgn(inRow, inDragRgn); + + StRegion tempRgn; + ::CopyRgn(inDragRgn, tempRgn); + ::InsetRgn(tempRgn, 1, 1); + ::DiffRgn(inDragRgn, tempRgn, inDragRgn); + + // Convert the region to global coordinates + Point p; + p.h = p.v = 0; + ::LocalToGlobal(&p); + ::OffsetRgn(inDragRgn, p.h, p.v); +} // CStandardFlexTable::AddRowToDrag + //---------------------------------------------------------------------------------------- void CStandardFlexTable::ChangeSort(const LTableHeader::SortChange* /*inSortChange*/) //---------------------------------------------------------------------------------------- @@ -1695,7 +2159,7 @@ void CStandardFlexTable::GetDropFlagRect( outFlagRect.top = inLocalCellRect.top + vDiff; outFlagRect.bottom = outFlagRect.top + 12; - outFlagRect.left = inLocalCellRect.left + 3; + outFlagRect.left = inLocalCellRect.left + 2; // was 3 outFlagRect.right = outFlagRect.left + 16; } // CStandardFlexTable::GetDropFlagRect @@ -1930,12 +2394,14 @@ void CStandardFlexTable::QapGetListInfo(PQAPLISTINFO pInfo) LScroller *myScroller = dynamic_cast(GetSuperView()); if (myScroller != NULL) { - if (myScroller->GetVScrollbar() != NULL) - macVScroll = myScroller->GetVScrollbar()->GetMacControl(); + LStdControl* vScrollPane = dynamic_cast + (myScroller->FindPaneByID(PaneIDT_VerticalScrollBar)); + if (vScrollPane) + macVScroll = vScrollPane->GetMacControl(); } pInfo->itemCount = (short)outRows; - pInfo->topIndex = topLeftCell.row; + pInfo->topIndex = topLeftCell.row - 1; // must start at 0 even though in QAP-script, Select("#1") selects the first line pInfo->itemHeight = GetRowHeight(0); pInfo->visibleCount = botRightCell.row - topLeftCell.row + 1; pInfo->vScroll = macVScroll; diff --git a/mozilla/lib/mac/UserInterface/Tables/CStandardFlexTable.h b/mozilla/lib/mac/UserInterface/Tables/CStandardFlexTable.h index 356cd6e310c..ca0a3276c0b 100755 --- a/mozilla/lib/mac/UserInterface/Tables/CStandardFlexTable.h +++ b/mozilla/lib/mac/UserInterface/Tables/CStandardFlexTable.h @@ -29,8 +29,9 @@ #include #include -//#include +#include +#include "NetscapeDragFlavors.h" #include "LTableViewHeader.h" // Need LTableHeader here, need the whole thing in the .cp file. // Might as well go the whole hog. @@ -39,7 +40,6 @@ class CStandardFlexTable; class CClickTimer; class CInlineEditField; - //======================================================================================== class CTableHeaderListener : public LListener //======================================================================================== @@ -55,7 +55,7 @@ protected: class CInlineEditorListener : public LListener { public: - CInlineEditorListener ( CStandardFlexTable* inTable ) : mTable(inTable) { } + CInlineEditorListener( CStandardFlexTable* inTable ) : mTable(inTable) { } protected: void ListenToMessage(MessageT inMessage, void *ioParam); CStandardFlexTable* mTable; @@ -72,13 +72,14 @@ class CStandardFlexTable , public LCommander , public LBroadcaster , public CKeyUpReceiver -//, public CQAPartnerTableMixin +, public CQAPartnerTableMixin { private: typedef CSpecialTableView Inherited; friend class CTableHeaderListener; friend class CClickTimer; friend class CInlineEditorListener; + friend class CDeferredInlineEditTask; public: enum { class_ID = 'sfTb', @@ -100,17 +101,19 @@ public: virtual Boolean GetNotifyOnSelectionChange(); void SetRightmostVisibleColumn(UInt16 inLastDesiredColumn); - // an externally public way to tell the table to begin an inplace edit. This is - // useful when handling menu commands, etc and not mouse clicks in the table. void DoInlineEditing ( const STableCell & inCell ) ; + // a public way to tell the table to begin an in-place edit. This is + // useful when handling menu commands, etc and not mouse clicks in the table. - virtual void RefreshCellRange( - const STableCell &inTopLeft, - const STableCell &inBotRight); // Overridden to fix a bug in PP. - protected: - enum { kMinRowHeight = 18, kDistanceFromIconToText = 5, kIconMargin = 4, kIndentPerLevel = 10, - kIconWidth = 16 }; + enum { + kMinRowHeight = 18 + , kDistanceFromIconToText = 5 + , kDropIconWastedSpace = 4 + , kIconMargin = 1 + , kIndentPerLevel = 14 + , kIconWidth = 16 + }; // for in-place editing, give the CInlineEditor this paneID. enum { paneID_InlineEdit = 'EDIT' } ; @@ -130,36 +133,66 @@ protected: virtual void DrawSelf(); virtual Boolean HandleKeyPress(const EventRecord &inKeyEvent); + virtual void RefreshCellRange( + const STableCell &inTopLeft, + const STableCell &inBotRight); // Overridden to fix a bug in PP. virtual void Click(SMouseDownEvent &inMouseDown); virtual void BeTarget(); virtual void DontBeTarget(); +// ------------------------------------------------------------ +// CEXTable Refugees +// ------------------------------------------------------------ +public: + void SelectScrollCell(const STableCell &inCell) + { + SelectCell(inCell); + ScrollCellIntoFrame(inCell); + } + + void RefreshRowRange(TableIndexT inStartRow, TableIndexT inEndRow); + void ReadSavedTableStatus(LStream *inStatusData); + void WriteSavedTableStatus(LStream *outStatusData); // ------------------------------------------------------------ // Sorting // ------------------------------------------------------------ +protected: virtual void ChangeSort(const LTableHeader::SortChange* inSortChange); // ------------------------------------------------------------ // Selection, MouseDowns // ------------------------------------------------------------ +public: + void SetFancyDoubleClick(Boolean inFancy) { mFancyDoubleClick = inFancy; } + +protected: virtual Boolean ClickSelect( const STableCell &inCell, const SMouseDownEvent &inMouseDown); + virtual void ClickSelf(const SMouseDownEvent &inMouseDown); + + Boolean HandleFancyDoubleClick( + const STableCell &inCell, + const SMouseDownEvent &inMouseDown); + virtual Boolean ClickDropFlag( const STableCell &inCell, const SMouseDownEvent &inMouseDown); virtual Boolean CellSelects(const STableCell& inCell) const; - virtual Boolean CellWantsClick ( const STableCell & /*inCell*/ ) const { return false; } - void SetFancyDoubleClick(Boolean inFancy) { mFancyDoubleClick = inFancy; } + virtual Boolean CellWantsClick( const STableCell & /*inCell*/ ) const { return false; } void SetHiliteDisabled(Boolean inDisable) { mHiliteDisabled = inDisable; } - virtual void HandleSelectionTracking ( const SMouseDownEvent & inMouseDown ) ; - virtual void TrackSelection ( const SMouseDownEvent & inMouseDown ) ; - virtual Boolean HitCellHotSpot ( const STableCell &inCell, + virtual void HandleSelectionTracking( const SMouseDownEvent & inMouseDown ) ; + virtual void TrackSelection( const SMouseDownEvent & inMouseDown ) ; + virtual Boolean HitCellHotSpot( const STableCell &inCell, const Rect &inTotalSelectionRect ) ; - virtual void UnselectCellsNotInSelectionOutline ( const Rect & selectionRect ) ; + + // the the cell rect in local coords even if scrolled out the the view + virtual void GetLocalCellRectAnywhere( const STableCell &inCell, Rect &outCellRect) const; + + virtual void UnselectCellsNotInSelectionOutline( const Rect & selectionRect ) ; // override to turn off selection outline tracking - virtual Boolean TableDesiresSelectionTracking ( ) { return true; } + virtual Boolean TableDesiresSelectionTracking( ) { return true; } virtual const TableIndexT* GetUpdatedSelectionList(TableIndexT& outSelectionSize); // Returns a ONE-BASED list of TableIndexT, as it should. @@ -169,6 +202,7 @@ protected: public: Boolean GetNextSelectedRow(TableIndexT& inOutAfterRow) const; Boolean GetLastSelectedRow(TableIndexT& inOutBeforeRow) const; + protected: void SelectRow(TableIndexT inRow); void ScrollRowIntoFrame(TableIndexT inRow); @@ -195,7 +229,7 @@ protected: virtual void InlineEditorTextChanged( ) { } virtual void InlineEditorDone( ) { } virtual void DoInlineEditing( const STableCell &inCell, Rect & inTextRect ); - virtual bool CanDoInlineEditing( ) { return true; } + virtual Boolean CanDoInlineEditing( ) { return true; } virtual void DrawCell( const STableCell &inCell, @@ -242,7 +276,7 @@ protected: // ------------------------------------------------------------ protected: virtual void SetCellExpansion(const STableCell& /* inCell */, Boolean /* inExpand */) {} - virtual Boolean CellHasDropFlag(const STableCell& /* inCell */, Boolean& /* outIsExpanded */) const { return true; } + virtual Boolean CellHasDropFlag(const STableCell& /* inCell */, Boolean& /* outIsExpanded */) const { return false; } virtual Boolean CellInitiatesDrag(const STableCell& /* inCell */) const { return false; } virtual void GetDropFlagRect( const Rect& inLocalCellRect, Rect& outFlagRect) const; @@ -252,9 +286,21 @@ protected: // ------------------------------------------------------------ // Drag Support // ------------------------------------------------------------ - virtual void DragSelection(const STableCell& inCell, const SMouseDownEvent &inMouseDown); - virtual void AddSelectionToDrag(DragReference inDragRef, RgnHandle inDragRgn); - virtual void AddRowDataToDrag( TableIndexT /* inRow */, + virtual OSErr DragSelection( + const STableCell& inCell, + const SMouseDownEvent &inMouseDown); + virtual OSErr DragRow( + TableIndexT inRow, + const SMouseDownEvent& inMouseDown); + virtual void AddSelectionToDrag( + DragReference inDragRef, + RgnHandle inDragRgn); + virtual void AddRowToDrag( + TableIndexT inRow, + DragReference inDragRef, + RgnHandle inDragRgn); + virtual void AddRowDataToDrag( + TableIndexT /* inRow */, DragReference /* inDragRef */ ) {}; virtual void InsideDropArea(DragReference inDragRef); virtual void EnterDropArea(DragReference inDragRef, Boolean inDragHasLeftSender); @@ -274,9 +320,16 @@ protected: virtual Boolean RowCanAcceptDropBetweenAbove( DragReference inDragRef, TableIndexT inDropRow); - virtual Boolean RowIsContainer ( const TableIndexT & /* inRow */ ) const { return false; } - void ComputeItemDropAreas ( const Rect & inLocalCellRect, Rect & oTop, Rect & oBottom ) ; - void ComputeFolderDropAreas ( const Rect & inLocalCellRect, Rect & oTop, Rect & oBottom ) ; + virtual Boolean RowIsContainer( + const TableIndexT & /* inRow */ ) const { return false; } + void ComputeItemDropAreas( + const Rect& inLocalCellRect, + Rect& outTop, + Rect& outBottom ); + void ComputeFolderDropAreas( + const Rect & inLocalCellRect, + Rect& outTop, + Rect& outBottom ); // ------------------------------------------------------------ // Miscellany @@ -329,7 +382,7 @@ public: // ------------------------------------------------------------ #if defined(QAP_BUILD) public: - virtual void QapGetListInfo (PQAPLISTINFO pInfo); + virtual void QapGetListInfo(PQAPLISTINFO pInfo); virtual Ptr QapAddCellToBuf(Ptr pBuf, Ptr pLimit, const STableCell& sTblCell); virtual void GetQapRowText(TableIndexT inRow, char* outText, UInt16 inMaxBufferLength) const; #endif @@ -354,6 +407,7 @@ protected: RGBColor mDropColor; Boolean mIsInternalDrop; // a drop of one row on another ? Boolean mIsDropBetweenRows; // changing order + Boolean mAllowDropAfterLastRow; // true to allow drops in the whitespace after the table CInlineEditField* mNameEditor; // used for inline editing TableIndexT mRowBeingEdited; diff --git a/mozilla/lib/mac/UserInterface/Tables/CTableKeyAttachment.cp b/mozilla/lib/mac/UserInterface/Tables/CTableKeyAttachment.cp index 27e82fbc6a4..bfa1edebc21 100644 --- a/mozilla/lib/mac/UserInterface/Tables/CTableKeyAttachment.cp +++ b/mozilla/lib/mac/UserInterface/Tables/CTableKeyAttachment.cp @@ -19,7 +19,8 @@ #include "CTableKeyAttachment.h" #include -#include +#include "StSetBroadcasting.h" +#include "CSpecialTableView.h" //testing #include "XP_Trace.h" @@ -30,6 +31,9 @@ CTableKeyAttachment::CTableKeyAttachment(CSpecialTableView* inView) { mTableView = dynamic_cast(mViewToScroll); Assert_(mTableView); + + // set getting keyups to bullet-proof us from someone messing with the System Event Mask + mGettingKeyUps = (::LMGetSysEvtMask() & keyUpMask); } CTableKeyAttachment::~CTableKeyAttachment() @@ -64,14 +68,22 @@ void CTableKeyAttachment::ExecuteSelf( TableIndexT theRowCount, theColCount; mTableView->GetTableSize(theRowCount, theColCount); - if (theKey == char_DownArrow || theKey == char_UpArrow) { - if (eventParam->what == keyDown || eventParam->what == autoKey) { - mTableView->SetNotifyOnSelectionChange(false); - } else if (eventParam->what == keyUp) + if (mGettingKeyUps) + { + if (theKey == char_DownArrow || theKey == char_UpArrow) { - mTableView->SetNotifyOnSelectionChange(true); - mTableView->SelectionChanged(); - return; + if (eventParam->what == keyDown || eventParam->what == autoKey) { + mTableView->SetNotifyOnSelectionChange(false); + } else if (eventParam->what == keyUp) + { + mTableView->SetNotifyOnSelectionChange(true); + mTableView->SelectionChanged(); + return; + } + } else { + // the only key-ups we want are arrows, and we've already done all we need with them + if (eventParam->what == keyUp) + return; } } @@ -154,12 +166,152 @@ CTableKeyAttachment::SelectCell( const STableCell& inCell, Boolean multiple) { if (!multiple) { - Boolean oldNotify = mTableView->GetNotifyOnSelectionChange(); - - mTableView->SetNotifyOnSelectionChange(false); + StSetBroadcasting saveBroadcastState((CStandardFlexTable *)mTableView, false); mTableView->UnselectAllCells(); - mTableView->SetNotifyOnSelectionChange(oldNotify); } mTableView->ScrollCellIntoFrame(inCell); // Do this before selecting (avoids turds) mTableView->SelectCell(inCell); } + + +#pragma mark - + + +CTableRowKeyAttachment::CTableRowKeyAttachment(CSpecialTableView* inView) + : CTableKeyAttachment(inView) +{ +} + +CTableRowKeyAttachment::~CTableRowKeyAttachment() +{ +} + + +void CTableRowKeyAttachment::ExecuteSelf(MessageT inMessage, void *ioParam) +{ + // In communicator, keyup events are turned on. This is for the benefit of Java + // applets, and we don't want to handle them for key scrolling in tables. + + // Well, we do actually. If we get a keyDown event, or autokey events, we don't + // want to update the list until the user lets go. So we turn off broadcasting + // until we get a keyUp. We also don't want to change the selection on the keyup, + // since we've already done that for the corresponding keyDown/autoKey. + + if (inMessage != msg_KeyPress) + return; + + EventRecord* eventParam = (EventRecord *)ioParam; + + mExecuteHost = false; + Int16 theKey = eventParam->message & charCodeMask; + Boolean bShiftDown = (eventParam->modifiers & shiftKey) != 0; + Boolean bControlDown = (eventParam->modifiers & controlKey) != 0; + // get the table dimensions + TableIndexT theRowCount, theColCount; + mTableView->GetTableSize(theRowCount, theColCount); + + if (mGettingKeyUps) + { + if (theKey == char_DownArrow || theKey == char_UpArrow) + { + if (eventParam->what == keyDown || eventParam->what == autoKey) { + mTableView->SetNotifyOnSelectionChange(false); + } else if (eventParam->what == keyUp) + { + mTableView->SetNotifyOnSelectionChange(true); + mTableView->SelectionChanged(); + return; + } + } else { + // the only key-ups we want are arrows, and we've already done all we need with them + if (eventParam->what == keyUp) + return; + } + } + + switch (theKey) + { + case char_PageUp: + case char_PageDown: + LKeyScrollAttachment::ExecuteSelf(inMessage, ioParam); + break; + case char_DownArrow: + if (!bControlDown) + { + // Get the last currently selected row + TableIndexT rows, cols; + + mTableView->GetTableSize(rows, cols); + + STableCell theCell(rows, 1); + // We don't want to use GetNextCell() here, because we don't want + // the overhead of stepping through each cell on the row. We know + // that all the cells in a selected row are selected. + while (mTableView->IsValidRow(theCell.row)) + { + if ( mTableView->CellIsSelected(theCell) ) + break; + + theCell.row --; + } + + if (mTableView->IsValidRow(theCell.row) ) // get the one after the selected cell + theCell.row ++; + else // select the last cell + { + theCell.row = rows; + theCell.col = 1; + } + if (mTableView->IsValidCell(theCell)) + SelectCell(theCell, bShiftDown); + break; + } + // else falls through + + case char_End: + { + STableCell theLastCell(theRowCount, 1); // still the first column + SelectCell(theLastCell, bShiftDown); + } + break; + + case char_UpArrow: + if (!bControlDown) + { + // Get the first currently selected row + STableCell theCell(1, 1); + + while (mTableView->IsValidRow(theCell.row)) + { + if ( mTableView->CellIsSelected(theCell) ) + break; + + theCell.row ++; + } + + if (mTableView->IsValidRow(theCell.row) ) // get the one before the selected cell + theCell.row --; + else // select the first cell + { + theCell.row = 1; + theCell.col = 1; + } + if (mTableView->IsValidCell(theCell)) + SelectCell(theCell, bShiftDown); + break; + } + // else falls through + + case char_Home: + { + STableCell theFirstCell(1, 1); + if (mTableView->IsValidCell(theFirstCell)) + SelectCell(theFirstCell, bShiftDown); + } + break; + + default: + mExecuteHost = true; // Some other key, let host respond + break; + } +} diff --git a/mozilla/lib/mac/UserInterface/Tables/CTableKeyAttachment.h b/mozilla/lib/mac/UserInterface/Tables/CTableKeyAttachment.h index 8bac434ae6e..4277f805a2e 100644 --- a/mozilla/lib/mac/UserInterface/Tables/CTableKeyAttachment.h +++ b/mozilla/lib/mac/UserInterface/Tables/CTableKeyAttachment.h @@ -37,4 +37,20 @@ class CTableKeyAttachment : public LKeyScrollAttachment void *ioParam); CSpecialTableView* mTableView; // safe cast of the view in the base class. + + Boolean mGettingKeyUps; // true if the app is receiving keyups +}; + +// a key attachment class that is optimized for row-selection tables +class CTableRowKeyAttachment : public CTableKeyAttachment +{ + public: + CTableRowKeyAttachment(CSpecialTableView* inView); + virtual ~CTableRowKeyAttachment(); + + protected: + + virtual void ExecuteSelf( + MessageT inMessage, + void *ioParam); }; \ No newline at end of file diff --git a/mozilla/lib/mac/UserInterface/Tables/LTableHeader.cp b/mozilla/lib/mac/UserInterface/Tables/LTableHeader.cp index ea3112c9daf..494f980ad32 100644 --- a/mozilla/lib/mac/UserInterface/Tables/LTableHeader.cp +++ b/mozilla/lib/mac/UserInterface/Tables/LTableHeader.cp @@ -64,7 +64,7 @@ LTableHeader::LTableHeader( LStream *inStream ) ResIDT theBevelTraitsID; mColumnData = NULL; - mColumnCount = mLastVisibleColumn = 0; + mColumnCount = mLastShowableColumn = mLastVisibleColumn = 0; *inStream >> mHeaderFlags; @@ -134,6 +134,11 @@ void LTableHeader::DrawSelf() Rect sect; LocateColumn(i, r); + + // Hack to tidy up 1-pixel offset of last header + if (i == mLastVisibleColumn) + r.right ++; + SColumnData* cData = GetColumnData(i); // Checking against the update rgn is necessary because we sometimes @@ -172,7 +177,7 @@ void LTableHeader::DrawSelf() DrawColumnBackground(r, false); } CalcLocalFrameRect(r); - r.left = r.right - kColumnHidingWidgetWidth; + r.left = r.right - kColumnHidingWidgetWidth + 1; DrawColumnBackground(r, false); // Draw the column hiding widget @@ -183,12 +188,12 @@ void LTableHeader::DrawSelf() r.bottom -= 1; // Hate this, but the position had to be adjusted. - jrm. r.left -= 1; if (mLastVisibleColumn <= 1) - if (mColumnCount == 1) - iconID = kColumnHiderDisabledIcon; + if (mLastShowableColumn == 1) + iconID = kColumnHiderDisabledIcon; // neither hide nor show possible else - iconID = kColumnHiderHideDisabledIcon; + iconID = kColumnHiderHideDisabledIcon; // show is possible else - if (mLastVisibleColumn == mColumnCount) + if (mLastVisibleColumn == mLastShowableColumn) iconID = kColumnHiderShowDisabledIcon; else iconID = kColumnHiderEnabledIcon; @@ -254,11 +259,11 @@ Boolean LTableHeader::IsInHorizontalSizeArea( SInt16 left = inLocalPt.h + 2; SInt16 right = inLocalPt.h - 2; - // Start at the division between the first and second columns + // start at the division between the first and second columns // Go up to the division between the last visible and the following one, // if there is one. SInt16 lastColumnToCheck = mLastVisibleColumn; - if (mColumnCount > mLastVisibleColumn) + if (mLastShowableColumn > mLastVisibleColumn) lastColumnToCheck++; SColumnData* cRightNeigbor = *mColumnData + 1; for (outLeftColumn = 1; @@ -300,7 +305,7 @@ void LTableHeader::Click(SMouseDownEvent &inEvent) // Handle clicks in the column hiding widget if (CanHideColumns() && (inEvent.whereLocal.h > GetHeaderWidth())) { - if (mColumnCount == 1 && mLastVisibleColumn == 1) + if (mLastShowableColumn == 1 && mLastVisibleColumn == 1) return; // no hiding/showing possible. // The right arrow hides the rightmost column and the left arrow // shows it. @@ -310,7 +315,7 @@ void LTableHeader::Click(SMouseDownEvent &inEvent) : leftSide; if (mLastVisibleColumn > 1 && side == rightSide) ShowHideRightmostColumn(false); // hide - else if (mLastVisibleColumn < mColumnCount && side == leftSide) + else if (mLastVisibleColumn < mLastShowableColumn && side == leftSide) ShowHideRightmostColumn(true); // show. } else @@ -546,7 +551,7 @@ void LTableHeader::ResizeColumn( else if (inLeftColumnDelta < 0) { // Move as many columns onscreen as will fit - while (mLastVisibleColumn + 1 <= mColumnCount + while (mLastVisibleColumn + 1 <= mLastShowableColumn && GetWidthOfRange(inLeftColumn + 1, mLastVisibleColumn + 1) <= newSpace) { mLastVisibleColumn++; @@ -640,7 +645,7 @@ void LTableHeader::ShowHideRightmostColumn(Boolean inShow) // mLastVisibleColumn is the rightmost visible column. //----------------------------------- { - Assert_((inShow && mLastVisibleColumn < mColumnCount) || + Assert_((inShow && mLastVisibleColumn < mLastShowableColumn) || (!inShow && mLastVisibleColumn > 1)); ColumnIndexT savedLastVisibleColumn = mLastVisibleColumn; @@ -785,6 +790,8 @@ Boolean LTableHeader::RedistributeSpace( static int rovingIndex = 0; const Int16 initialError = roundingError; const int initialIndex = rovingIndex; + Int16 panicCount = 0; + while (roundingError) { rovingIndex++; @@ -801,6 +808,9 @@ Boolean LTableHeader::RedistributeSpace( cData->columnWidth += signedUnit; roundingError -= signedUnit; } + + if (++panicCount > 100) + break; } return true; } // LTableHeader::RedistributeSpace @@ -1276,6 +1286,14 @@ Boolean LTableHeader::CanColumnSort(ColumnIndexT inColumn) const return GetColumnData(inColumn)->CanSort(); } +//----------------------------------- +Boolean LTableHeader::CanColumnShow(ColumnIndexT inColumn) const +//----------------------------------- +{ + CheckLegal(inColumn); + return GetColumnData(inColumn)->CanShow(); +} + //----------------------------------- LTableHeader::ColumnIndexT LTableHeader::GetSortedColumn(PaneIDT &outHeaderPane) const //----------------------------------- @@ -1361,6 +1379,16 @@ void LTableHeader::ReadColumnState( LStream * inStream, Boolean inMoveHeaders) StHandleLocker locker((Handle)mColumnData); inStream->GetBytes(*mColumnData, dataSize); + // find the last showable column + for (UInt16 i = 1; i <= mColumnCount; i++) + { + // non-showing cols must be at the end + Assert_( CanColumnShow(i) ? true : i > mLastVisibleColumn); + + if (CanColumnShow(i)) + mLastShowableColumn = i; + } + ConvertWidthsToAbsolute(); ComputeColumnPositions(); diff --git a/mozilla/lib/mac/UserInterface/Tables/LTableHeader.h b/mozilla/lib/mac/UserInterface/Tables/LTableHeader.h index 583d8afb50b..87ec6b7ddbd 100644 --- a/mozilla/lib/mac/UserInterface/Tables/LTableHeader.h +++ b/mozilla/lib/mac/UserInterface/Tables/LTableHeader.h @@ -138,14 +138,20 @@ public: { return (flags & kColumnDoesNotDisplayTitle) == 0; } + Boolean CanShow() const + { + return (flags & kColumnDoesNotShow) == 0; + } + private: enum { - kColumnDoesNotSort = 1<<0 - , kColumnDoesNotResize = 1<<1 - , kColumnSuppressSortIcon = 1<<2 - , kColumnDoesNotMove = 1<<3 - , kColumnDoesNotDisplayTitle = 1<<4 + kColumnDoesNotSort = 1<<0 + , kColumnDoesNotResize = 1<<1 + , kColumnSuppressSortIcon = 1<<2 + , kColumnDoesNotMove = 1<<3 + , kColumnDoesNotDisplayTitle = 1<<4 + , kColumnDoesNotShow = 1<<5 }; public: enum { kMinWidth = 16 }; @@ -216,6 +222,7 @@ protected: // Boolean CanColumnResize(ColumnIndexT inColumn) const; Boolean CanColumnSort(ColumnIndexT inColumn) const; + Boolean CanColumnShow(ColumnIndexT inColumn) const; Boolean ColumnHasSortIcon(ColumnIndexT inColumn) const; Boolean CanHideColumns() const; @@ -238,7 +245,7 @@ protected: enum { kColumnMargin = 2, - kColumnHidingWidgetWidth = 15 + kColumnHidingWidgetWidth = 16 }; HeaderFlags mHeaderFlags; @@ -247,6 +254,7 @@ protected: SBevelColorDesc mSortedBevel; ColumnIndexT mColumnCount; // 1-based count of all columns + ColumnIndexT mLastShowableColumn; // 1-based count of cols that can show ColumnIndexT mLastVisibleColumn; // 1-based index of rightmost visible column ColumnIndexT mSortedColumn; // 1-based index of sorted columns Boolean mSortedBackwards; diff --git a/mozilla/lib/mac/UserInterface/Tables/LTableRowSelector.cp b/mozilla/lib/mac/UserInterface/Tables/LTableRowSelector.cp index 0d8a1d9b252..f92415f9965 100644 --- a/mozilla/lib/mac/UserInterface/Tables/LTableRowSelector.cp +++ b/mozilla/lib/mac/UserInterface/Tables/LTableRowSelector.cp @@ -143,6 +143,16 @@ LTableRowSelector::DoSelect( const TableIndexT inRow, if (inRow < 1 || inRow > GetCount()) return; + // Make sure for a single selector only 1 row is selected + if ( inSelect && !mAllowMultiple ) + { + if ( mSelectedRowCount > 0 ) + { + DoSelectAll(false, false); + mSelectedRowCount = 0; // to be safe + } + } + char oldRowValue; FetchItemAt(inRow, &oldRowValue); char newRowValue = (inSelect) ? 1 : 0; @@ -211,7 +221,7 @@ LTableRowSelector::DoSelectAll(Boolean inSelect, Boolean inNotify) UInt32 nCols, nRows; mTableView->GetTableSize(nRows, nCols); - if (nRows) // Prevents bug: DoSelectRange won't check! + if (nRows > 0) // Prevents bug: DoSelectRange won't check! DoSelectRange(1, nRows, inSelect, inNotify); else { @@ -462,3 +472,68 @@ LTableRowSelector::RemoveRows( Uint32 inHowMany, if (selectionChanged) mTableView->SelectionChanged(); } + +void +LTableRowSelector::MakeSelectionRegion(RgnHandle ioRgnHandle, TableIndexT hiliteColumn) +{ + Assert_(ioRgnHandle); + + ::SetEmptyRgn(ioRgnHandle); + + Boolean inSelection = false; + TableIndexT selectionStart; + TableIndexT nRows = GetCount(); + + StRegion tempRgn; + + for (TableIndexT row = 1; row <= nRows; row ++) + { + Boolean rowSelected; + + FetchItemAt(row, &rowSelected); + + // I'm trying to reduce the number of region operations here + if (rowSelected && !inSelection) // start of selection group + { + selectionStart = row; + inSelection = true; + + } else if (!rowSelected && inSelection) // end of selection group + { + Rect selectRect = {selectionStart, hiliteColumn, row, hiliteColumn + 1}; + + ::RectRgn(tempRgn, &selectRect); + ::UnionRgn(tempRgn, ioRgnHandle, ioRgnHandle); + inSelection = false; + } + } + // do the last group if necessary + if (inSelection) + { + Rect selectRect = {selectionStart, hiliteColumn, nRows + 1, hiliteColumn + 1}; + + ::RectRgn(tempRgn, &selectRect); + ::UnionRgn(tempRgn, ioRgnHandle, ioRgnHandle); + } +} + + +void +LTableRowSelector::SetSelectionFromRegion(RgnHandle inRgnHandle) +{ + Assert_(inRgnHandle); + + TableIndexT nRows = GetCount(); + + UnselectAllCells(); + + STableCell theCell(1, 1); + + for (theCell.row = 1; theCell.row <= nRows; theCell.row ++) + { + Point thePoint = { /* cast */theCell.row, 1}; //v, h + + if ( ::PtInRgn(thePoint, inRgnHandle) ) + DoSelect(theCell.row, true, true, true); + } +} \ No newline at end of file diff --git a/mozilla/lib/mac/UserInterface/Tables/LTableRowSelector.h b/mozilla/lib/mac/UserInterface/Tables/LTableRowSelector.h index 0dfe06f0c43..8b68e23f5f2 100644 --- a/mozilla/lib/mac/UserInterface/Tables/LTableRowSelector.h +++ b/mozilla/lib/mac/UserInterface/Tables/LTableRowSelector.h @@ -66,6 +66,9 @@ public: TableIndexT GetSelectedRowCount() const { return mSelectedRowCount; } virtual void DoSelect(TableIndexT inRow, Boolean inSelect, Boolean inHilite, Boolean inNotify = false); + virtual void MakeSelectionRegion(RgnHandle ioRgnHandle, TableIndexT hiliteColumn); + virtual void SetSelectionFromRegion(RgnHandle inRgnHandle); + protected: virtual void DoSelectAll(Boolean inSelect, Boolean inNotify); void DoSelectRange(TableIndexT inFrom, TableIndexT inTo, Boolean inSelect, Boolean inNotify); @@ -78,9 +81,5 @@ protected: TableIndexT mExtensionRow; Boolean mAllowMultiple; TableIndexT mSelectedRowCount; - RgnHandle mAddToSelection; - RgnHandle mRemoveFromSelection; - RgnHandle mInvertSelection; - }; diff --git a/mozilla/lib/mac/UserInterface/UGraphicGizmos.cp b/mozilla/lib/mac/UserInterface/UGraphicGizmos.cp index ecd124f9330..1f06d0e8a4b 100644 --- a/mozilla/lib/mac/UserInterface/UGraphicGizmos.cp +++ b/mozilla/lib/mac/UserInterface/UGraphicGizmos.cp @@ -1205,7 +1205,7 @@ Boolean UGraphicGizmos::GetTingeColorsFromColorTable ( // ₯ FindInColorTable // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ -RGBColor UGraphicGizmos::FindInColorTable(CTabHandle inColorTable, Int16 inColorID) +void UGraphicGizmos::FindInColorTable(CTabHandle inColorTable, Int16 inColorID, RGBColor &outColor) { RGBColor theFoundColor = { 0, 0, 0 }; @@ -1218,17 +1218,18 @@ RGBColor UGraphicGizmos::FindInColorTable(CTabHandle inColorTable, Int16 inColor } } - return theFoundColor; + outColor = theFoundColor; } // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ // ₯ MixColor // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ -RGBColor UGraphicGizmos::MixColor( +void UGraphicGizmos::MixColor( const RGBColor& inLightColor, const RGBColor& inDarkColor, - Int16 inShade) + Int16 inShade, + RGBColor& outColor) { RGBColor theMixedColor; @@ -1241,7 +1242,7 @@ RGBColor UGraphicGizmos::MixColor( theMixedColor.green = (Int32) (inLightColor.green - inDarkColor.green) * inShade / 15 + inDarkColor.green; theMixedColor.blue = (Int32) (inLightColor.blue - inDarkColor.blue) * inShade / 15 + inDarkColor.blue; - return theMixedColor; + outColor = theMixedColor; } // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ diff --git a/mozilla/lib/mac/UserInterface/UGraphicGizmos.h b/mozilla/lib/mac/UserInterface/UGraphicGizmos.h index fbbd987bf4c..50612d751ca 100644 --- a/mozilla/lib/mac/UserInterface/UGraphicGizmos.h +++ b/mozilla/lib/mac/UserInterface/UGraphicGizmos.h @@ -193,14 +193,16 @@ class UGraphicGizmos RGBColor &outLightTinge, RGBColor &outDarkTinge); - static RGBColor FindInColorTable( - CTabHandle inColorTable, - Int16 inColorID); + static void FindInColorTable( + CTabHandle inColorTable, + Int16 inColorID, + RGBColor& outColor); - static RGBColor MixColor( + static void MixColor( const RGBColor& inLightColor, const RGBColor& inDarkColor, - Int16 inShade); + Int16 inShade, + RGBColor& outColor); static void DrawArithPattern( const Rect& inFrame, diff --git a/mozilla/lib/mac/UserInterface/UStdDialogs.cp b/mozilla/lib/mac/UserInterface/UStdDialogs.cp index 56ae70db3a5..1df918e5929 100644 --- a/mozilla/lib/mac/UserInterface/UStdDialogs.cp +++ b/mozilla/lib/mac/UserInterface/UStdDialogs.cp @@ -37,8 +37,6 @@ const PaneIDT okAlertBtnID = 900; const PaneIDT cancelAlertBtnID = 901; - - // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ // ₯ StStdDialogHandler // ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ @@ -233,6 +231,20 @@ void StStdDialogHandler::SetText(PaneIDT id, ConstStr255Param value) GetPane(id)->SetDescriptor(value); } +void StStdDialogHandler::CopyNumberValue(PaneIDT fromPaneId, PaneIDT toPaneId) +{ + GetPane(toPaneId)->SetValue(GetControl(fromPaneId)->GetValue()); +} + +void StStdDialogHandler::CopyTextValue(PaneIDT fromPaneId, PaneIDT toPaneId) +{ + Str255 theValueText; + + GetPane(fromPaneId)->GetDescriptor(theValueText); + GetPane(toPaneId)->SetDescriptor(theValueText); +} + + void StStdDialogHandler::SetNumberText(PaneIDT id, SInt32 value) { Str255 s; diff --git a/mozilla/lib/mac/UserInterface/UStdDialogs.h b/mozilla/lib/mac/UserInterface/UStdDialogs.h index df0d8639544..1318b1b5bda 100644 --- a/mozilla/lib/mac/UserInterface/UStdDialogs.h +++ b/mozilla/lib/mac/UserInterface/UStdDialogs.h @@ -107,6 +107,8 @@ class StStdDialogHandler : public StDialogHandler void SetNumberText(PaneIDT id, SInt32 value); void GetText(PaneIDT id, Str255 value); SInt32 GetNumberText(PaneIDT id); + void CopyTextValue(PaneIDT fromPaneId, PaneIDT toPaneId); + void CopyNumberValue(PaneIDT fromPaneId, PaneIDT toPaneId); protected: diff --git a/mozilla/lib/mac/UserInterface/UTearOffPalette.cp b/mozilla/lib/mac/UserInterface/UTearOffPalette.cp index 29ba82587e6..9352c2684bd 100644 --- a/mozilla/lib/mac/UserInterface/UTearOffPalette.cp +++ b/mozilla/lib/mac/UserInterface/UTearOffPalette.cp @@ -1040,7 +1040,7 @@ void CTearOffManager::CloseFloatingWindow(ResIDT inWinID) // Opens the Floating Window void CTearOffManager::OpenFloatingWindow( ResIDT inWinID, - Point inTopLeft, + Point /* inTopLeft */, Boolean inSideways, UInt8 visibility, Str255 &title)