зеркало из https://github.com/mozilla/pjs.git
Pass correct data to HT on drag and drop, fixes in d&d, check with HT before loading URL.
This commit is contained in:
Родитель
c890745799
Коммит
8df73fc586
|
@ -57,7 +57,7 @@ Uint32 CPersonalToolbarTable :: mMinToolbarButtonChars = LArray::index_Last;
|
||||||
CPersonalToolbarTable :: CPersonalToolbarTable ( LStream* inStream )
|
CPersonalToolbarTable :: CPersonalToolbarTable ( LStream* inStream )
|
||||||
: LSmallIconTable(inStream), LDragAndDrop ( GetMacPort(), this ),
|
: LSmallIconTable(inStream), LDragAndDrop ( GetMacPort(), this ),
|
||||||
mDropCol(LArray::index_Bad), mHiliteCol(LArray::index_Bad), mDropOn(false), mButtonList(NULL),
|
mDropCol(LArray::index_Bad), mHiliteCol(LArray::index_Bad), mDropOn(false), mButtonList(NULL),
|
||||||
mIsInitialized(false)
|
mIsInitialized(false), mInlineFeedbackOn(true)
|
||||||
{
|
{
|
||||||
// setup our window into the RDF world and register this class as the one to be notified
|
// setup our window into the RDF world and register this class as the one to be notified
|
||||||
// when the personal toolbar changes.
|
// when the personal toolbar changes.
|
||||||
|
@ -418,6 +418,9 @@ CPersonalToolbarTable :: FillInToolbar ( )
|
||||||
void
|
void
|
||||||
CPersonalToolbarTable :: MouseLeave ( )
|
CPersonalToolbarTable :: MouseLeave ( )
|
||||||
{
|
{
|
||||||
|
if ( !IsActive() )
|
||||||
|
return;
|
||||||
|
|
||||||
STableCell refresh(1, mHiliteCol);
|
STableCell refresh(1, mHiliteCol);
|
||||||
mHiliteCol = LArray::index_Bad;
|
mHiliteCol = LArray::index_Bad;
|
||||||
|
|
||||||
|
@ -438,6 +441,9 @@ CPersonalToolbarTable :: MouseLeave ( )
|
||||||
void
|
void
|
||||||
CPersonalToolbarTable :: MouseWithin ( Point inPortPt, const EventRecord& )
|
CPersonalToolbarTable :: MouseWithin ( Point inPortPt, const EventRecord& )
|
||||||
{
|
{
|
||||||
|
if ( !IsActive() )
|
||||||
|
return;
|
||||||
|
|
||||||
// get the previous selection
|
// get the previous selection
|
||||||
STableCell old(1, mHiliteCol);
|
STableCell old(1, mHiliteCol);
|
||||||
SPoint32 imagePt;
|
SPoint32 imagePt;
|
||||||
|
@ -577,8 +583,10 @@ CPersonalToolbarTable :: ClickCell(const STableCell &inCell, const SMouseDownEve
|
||||||
if ( data.IsFolder() ) {
|
if ( data.IsFolder() ) {
|
||||||
SysBeep(1);
|
SysBeep(1);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
|
if ( !URDFUtilities::LaunchNode(data.GetHTResource()) )
|
||||||
CFrontApp::DoGetURL( data.GetURL().c_str() );
|
CFrontApp::DoGetURL( data.GetURL().c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
} // else just a click
|
} // else just a click
|
||||||
|
|
||||||
|
@ -595,13 +603,16 @@ CPersonalToolbarTable :: ClickCell(const STableCell &inCell, const SMouseDownEve
|
||||||
void
|
void
|
||||||
CPersonalToolbarTable :: RedrawCellWithHilite ( const STableCell inCell, bool inHiliteOn )
|
CPersonalToolbarTable :: RedrawCellWithHilite ( const STableCell inCell, bool inHiliteOn )
|
||||||
{
|
{
|
||||||
|
if ( inCell.col == LArray::index_Bad )
|
||||||
|
return;
|
||||||
|
|
||||||
Rect localCellRect;
|
Rect localCellRect;
|
||||||
GetLocalCellRect ( inCell, localCellRect );
|
GetLocalCellRect ( inCell, localCellRect );
|
||||||
|
|
||||||
// since mDropOn is used as the flag in DrawCell() for whether or not we want to
|
// since mDropOn is used as the flag in DrawCell() for whether or not we want to
|
||||||
// draw the hiliting on the cell, save its value and set it to what was passed in
|
// draw the hiliting on the cell, save its value and set it to what was passed in
|
||||||
// before calling DrawCell().
|
// before calling DrawCell().
|
||||||
StValueChanger<Boolean> oldHilite(mDropOn, inHiliteOn); //¥¥¥ won't link with bool type =(
|
StValueChanger<bool> oldHilite(mDropOn, inHiliteOn);
|
||||||
|
|
||||||
// if the hiliting is being turned off, erase the cell so it draws normally again
|
// if the hiliting is being turned off, erase the cell so it draws normally again
|
||||||
if ( !inHiliteOn ) {
|
if ( !inHiliteOn ) {
|
||||||
|
@ -618,8 +629,8 @@ CPersonalToolbarTable :: RedrawCellWithHilite ( const STableCell inCell, bool in
|
||||||
//
|
//
|
||||||
// DrawCell
|
// DrawCell
|
||||||
//
|
//
|
||||||
// Override to draw differently when this is the selected cell. Otherwise, pass it back
|
// Override to draw differently when this is the selected cell and for drop feedback
|
||||||
// to the inherited routine to draw normally.
|
// during a drop on a folder.
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
CPersonalToolbarTable :: DrawCell ( const STableCell &inCell, const Rect &inLocalRect )
|
CPersonalToolbarTable :: DrawCell ( const STableCell &inCell, const Rect &inLocalRect )
|
||||||
|
@ -683,20 +694,25 @@ CPersonalToolbarTable :: DoDragSendData( FlavorType inFlavor, ItemReference inIt
|
||||||
//
|
//
|
||||||
// HiliteDropArea
|
// HiliteDropArea
|
||||||
//
|
//
|
||||||
// Show that this toolbar is a drop site for urls
|
// Show that this toolbar is a drop site for urls, but only if there aren't any items
|
||||||
|
// in the bar already. If there are, the drop feedback should take care of it.
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
CPersonalToolbarTable :: HiliteDropArea ( DragReference inDragRef )
|
CPersonalToolbarTable :: HiliteDropArea ( DragReference inDragRef )
|
||||||
{
|
{
|
||||||
|
if ( mCols && mInlineFeedbackOn ) // let in-line drop feedback do the job
|
||||||
|
return;
|
||||||
|
|
||||||
Rect frame;
|
Rect frame;
|
||||||
CalcLocalFrameRect ( frame );
|
CalcLocalFrameRect ( frame );
|
||||||
|
|
||||||
// show the drag hilite in drop area
|
// show the drag hilite in drop area
|
||||||
RgnHandle rgn = ::NewRgn();
|
try {
|
||||||
ThrowIfNil_(rgn);
|
StRegion rgn;
|
||||||
::RectRgn ( rgn, &frame );
|
::RectRgn ( rgn, &frame );
|
||||||
::ShowDragHilite ( inDragRef, rgn, true );
|
::ShowDragHilite ( inDragRef, rgn, true );
|
||||||
::DisposeRgn ( rgn );
|
}
|
||||||
|
catch ( ... ) { }
|
||||||
|
|
||||||
} // HiliteDropArea
|
} // HiliteDropArea
|
||||||
|
|
||||||
|
@ -712,6 +728,17 @@ CPersonalToolbarTable :: InsideDropArea ( DragReference inDragRef )
|
||||||
{
|
{
|
||||||
FocusDraw();
|
FocusDraw();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// If the container is sorted, don't let the user drop in any given location. Just
|
||||||
|
// hilight the entire area
|
||||||
|
//¥¥¥can't do this here, else you won't be able to drop on folders!
|
||||||
|
if ( ! HT_ContainerSupportsNaturalOrderSort(HT_TopNode(GetHTView())) ) {
|
||||||
|
StValueChanger<bool> old ( mInlineFeedbackOn, false );
|
||||||
|
HiliteDropArea(inDragRef);
|
||||||
|
return;
|
||||||
|
} // if container is sorted
|
||||||
|
#endif
|
||||||
|
|
||||||
Point mouseLoc;
|
Point mouseLoc;
|
||||||
SPoint32 imagePt;
|
SPoint32 imagePt;
|
||||||
::GetDragMouse(inDragRef, &mouseLoc, NULL);
|
::GetDragMouse(inDragRef, &mouseLoc, NULL);
|
||||||
|
@ -752,6 +779,20 @@ CPersonalToolbarTable :: InsideDropArea ( DragReference inDragRef )
|
||||||
newDropCol = mCols + 1;
|
newDropCol = mCols + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we now know where the drop SHOULD go, now check if it CAN go there
|
||||||
|
HT_Resource targetNode = NULL;
|
||||||
|
if ( newDropOn ) {
|
||||||
|
const CUserButtonInfo & info = GetInfoForPPColumn(newDropCol);
|
||||||
|
targetNode = info.GetHTResource();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
targetNode = HT_TopNode(GetHTView());
|
||||||
|
mCanAcceptCurrentDrag = NodeCanAcceptDrop ( inDragRef, targetNode );
|
||||||
|
if ( !mCanAcceptCurrentDrag ) {
|
||||||
|
newDropOn = false;
|
||||||
|
newDropCol = LArray::index_Bad;
|
||||||
|
}
|
||||||
|
|
||||||
// if something has changed, redraw as necessary
|
// if something has changed, redraw as necessary
|
||||||
if ( newDropCol != mDropCol || newDropOn != mDropOn ) {
|
if ( newDropCol != mDropCol || newDropOn != mDropOn ) {
|
||||||
|
|
||||||
|
@ -766,8 +807,8 @@ CPersonalToolbarTable :: InsideDropArea ( DragReference inDragRef )
|
||||||
mDropOn = newDropOn;
|
mDropOn = newDropOn;
|
||||||
|
|
||||||
// hilight new one
|
// hilight new one
|
||||||
if ( mDropOn )
|
if ( newDropOn )
|
||||||
RedrawCellWithHilite ( STableCell(1, mDropCol), true );
|
RedrawCellWithHilite ( STableCell(1, newDropCol), true );
|
||||||
else
|
else
|
||||||
DrawDividingLine ( newDropCol );
|
DrawDividingLine ( newDropCol );
|
||||||
|
|
||||||
|
@ -853,6 +894,9 @@ CPersonalToolbarTable :: ComputeFolderDropAreas ( const Rect & inLocalCellRect,
|
||||||
void
|
void
|
||||||
CPersonalToolbarTable :: DrawDividingLine( TableIndexT inCol )
|
CPersonalToolbarTable :: DrawDividingLine( TableIndexT inCol )
|
||||||
{
|
{
|
||||||
|
if ( inCol == LArray::index_Bad )
|
||||||
|
return;
|
||||||
|
|
||||||
Uint32 numItems = mButtonList->size();
|
Uint32 numItems = mButtonList->size();
|
||||||
if ( !numItems ) // don't draw anything if toolbar empty
|
if ( !numItems ) // don't draw anything if toolbar empty
|
||||||
return;
|
return;
|
||||||
|
@ -883,10 +927,10 @@ CPersonalToolbarTable :: DrawDividingLine( TableIndexT inCol )
|
||||||
|
|
||||||
// Save the draw state and clip the list view rect.
|
// Save the draw state and clip the list view rect.
|
||||||
StColorPenState theDrawState;
|
StColorPenState theDrawState;
|
||||||
|
StColorState::Normalize();
|
||||||
StClipRgnState theClipState( theFrame );
|
StClipRgnState theClipState( theFrame );
|
||||||
|
|
||||||
// Setup the color and pen state then draw the line
|
// Setup the color and pen state then draw the line
|
||||||
::ForeColor( blackColor );
|
|
||||||
::PenMode( patXor );
|
::PenMode( patXor );
|
||||||
::PenSize( 2, 2 );
|
::PenSize( 2, 2 );
|
||||||
::MoveTo( cellBounds.left, cellBounds.top );
|
::MoveTo( cellBounds.left, cellBounds.top );
|
||||||
|
@ -914,14 +958,20 @@ CPersonalToolbarTable :: ReceiveDragItem ( DragReference inDragRef, DragAttribut
|
||||||
//
|
//
|
||||||
// ItemIsAcceptable
|
// ItemIsAcceptable
|
||||||
//
|
//
|
||||||
// If FindBestFlavor() finds an acceptable flavor, then this item can be accepted. If not, it
|
// Determine if the current item can be dropped in this pane. Check to see if the
|
||||||
// can't. We don't really care at this point what that flavor is.
|
// pane as a whole accepts drops (history, for example, will not). The data, at this
|
||||||
|
// point, is fairly moot and will be checked in RowCanAcceptDrop*() routines.
|
||||||
|
//
|
||||||
//
|
//
|
||||||
Boolean
|
Boolean
|
||||||
CPersonalToolbarTable :: ItemIsAcceptable ( DragReference inDragRef, ItemReference inItemRef )
|
CPersonalToolbarTable :: ItemIsAcceptable ( DragReference inDragRef, ItemReference inItemRef )
|
||||||
{
|
{
|
||||||
FlavorType ignored;
|
FlavorType ignored;
|
||||||
return FindBestFlavor ( inDragRef, inItemRef, ignored );
|
|
||||||
|
bool paneAllowsDrop = HT_CanDropURLOn ( HT_TopNode(GetHTView()), "http://foo.com" );
|
||||||
|
bool acceptableFlavorFound = FindBestFlavor ( inDragRef, inItemRef, ignored );
|
||||||
|
|
||||||
|
return paneAllowsDrop && acceptableFlavorFound;
|
||||||
|
|
||||||
} // ItemIsAcceptable
|
} // ItemIsAcceptable
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,7 @@ class CPersonalToolbarTable : public LSmallIconTable, public LDragAndDrop,
|
||||||
bool mDropOn; // are they on a folder?
|
bool mDropOn; // are they on a folder?
|
||||||
Rect mTextHiliteRect; // cached rect drawn behind selected folder title
|
Rect mTextHiliteRect; // cached rect drawn behind selected folder title
|
||||||
TableIndexT mHiliteCol; // which column is mouse hovering over?
|
TableIndexT mHiliteCol; // which column is mouse hovering over?
|
||||||
|
bool mInlineFeedbackOn; // do we draw the inline feedback or frame entire area?
|
||||||
|
|
||||||
HT_View mToolbarView;
|
HT_View mToolbarView;
|
||||||
HT_Resource mToolbarRoot;
|
HT_Resource mToolbarRoot;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче