SGDisplayLayer Class Reference

This DisplayTree node is used by the Layer SuperGallery It is responsible for providing the ability to handle/redraw one Layer displayed in said gallery. More...

#include <sglayer.h>

Inheritance diagram for SGDisplayLayer:

SGDisplayItem SGDisplayNode CCObject SimpleCCObject SGDisplayFrame List of all members.

Public Member Functions

 SGDisplayLayer ()
 SGDisplayLayer constructor DON'T call this constructor. It ERROR3's. Call the other constructor.
 SGDisplayLayer (Layer *LayerToDisplay)
 SGDisplayLayer constructor.
 ~SGDisplayLayer ()
 SGDisplayLayer destructor.
virtual BOOL HandleEvent (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
 Handles a SuperGallery DisplayTree event.
virtual void MoveBefore (SGDisplayNode *NodeToMove)
 MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.
virtual void MoveAfter (SGDisplayNode *NodeToMove)
 Called when the Locked button is clicked in a layer gallery item. Changes the lockedness of the displayed layer.MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.
virtual void MoveLayer (SGDisplayNode *NodeToMove, BOOL Before, BOOL ToggleBackground)
 This moves the given layer either before or after this layer, in an undoable way.
LayerGetDisplayedLayer (void)
 To find out the Layer this object is responsible for displaying.

Protected Member Functions

virtual void CalculateMyRect (SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo)
 Shared code for Layer items to calculate where they will appear in the grand scheme of things.
virtual void HandleRedraw (SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo)
 SGDisplayLayer item redraw method - removed from the main HandleEvent method merely to make the code tidier.
virtual void DoChangeState (OpLayerGalReason Reason, BOOL NewState)
 Called when a flag changes for a layer gallery item.
virtual void ChangeRangeState (SGDisplayLayer *Start, SGDisplayLayer *End, BOOL Range, INT32 WhichButton, SGMiscInfo *MiscInfo)
 To handle extension-clicks on layers, we set the state of a range of layers rather than just the one clicked. The range usually extends to the layer which was previously clicked.

Static Protected Member Functions

static void CalculateButtonRects (SGMiscInfo *MiscInfo, DocRect *MyRect, DocRect *VisibleBtn, DocRect *LockedBtn, DocRect *SnapButton=NULL)
 Shared method to determine where the visible/locked buttons will be displayed.

Protected Attributes

LayerTheLayer

Private Member Functions

 CC_DECLARE_DYNAMIC (SGDisplayLayer)

Static Private Attributes

static SGDisplayLayerLastClickedLayer = NULL

Friends

class SGLayerGroup

Detailed Description

This DisplayTree node is used by the Layer SuperGallery It is responsible for providing the ability to handle/redraw one Layer displayed in said gallery.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
Date:
27/01/95
See also:
LayerSGallery; SuperGallery; SGDisplayItem

Definition at line 138 of file sglayer.h.


Constructor & Destructor Documentation

SGDisplayLayer::SGDisplayLayer  ) 
 

SGDisplayLayer constructor DON'T call this constructor. It ERROR3's. Call the other constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)

Definition at line 348 of file sglayer.cpp.

00349 {
00350     ERROR3("Illegal call on default SGDisplayLayer constructor - call the other one!");
00351     TheLayer = NULL;
00352 }

SGDisplayLayer::SGDisplayLayer Layer LayerToDisplay  ) 
 

SGDisplayLayer constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
LayerToDisplay - The Layer this item will display [INPUTS]

Definition at line 369 of file sglayer.cpp.

00370 {
00371     ERROR3IF(LayerToDisplay == NULL,
00372                 "SGDisplayLayer - trying to construct me with a NULL parameter is bad");
00373 
00374     TheLayer = LayerToDisplay;
00375 }

SGDisplayLayer::~SGDisplayLayer  ) 
 

SGDisplayLayer destructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Notes: Ensures the LastClickedLayer memory is not left pointing at this layer

Definition at line 392 of file sglayer.cpp.

00393 {
00394     // Make sure LastClickedLayer pointer is not left in an invalid state
00395     if (this == LastClickedLayer)
00396         LastClickedLayer = NULL;
00397 }


Member Function Documentation

void SGDisplayLayer::CalculateButtonRects SGMiscInfo MiscInfo,
DocRect MyRect,
DocRect VisibleBtn,
DocRect LockedBtn,
DocRect SnapBtn = NULL
[static, protected]
 

Shared method to determine where the visible/locked buttons will be displayed.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/2/95
Parameters:
ButtonGap - The gap between buttons, in MILLIPOINTS (usually TwoPixels) [INPUTS] MyRect - A rectangle vbased on FormatRect, from which to carve out 2 buttons
MyRect - The used portion of MyRect will have been subtracted [OUTPUTS] VisibleBtn - Will contain the button rectangle for the 'Visible' button LockedBtn - Will contain the button rectangle for the 'Locked' button SnapBtn - if non-NULL, will return containing the snap-button position
Scope: private

Definition at line 460 of file sglayer.cpp.

00462 {
00463     INT32 ButtonGap = MiscInfo->PixelSize * 2;
00464     INT32 ButtonSize = MiscInfo->PixelSize * 16;            // The bitmap glyphs are 16x16 pixels
00465 
00466     // First, render the 'visible' and 'locked' buttons at the left end of our rectangle
00467     *VisibleBtn = *MyRect;
00468     VisibleBtn->hi.x = VisibleBtn->lo.x + ButtonSize;   // Make it a square
00469 
00470     INT32 Excess = VisibleBtn->Height() - ButtonSize;   // Center it in the Y axis
00471     Excess = GridLock(MiscInfo, Excess / 2);
00472     VisibleBtn->lo.y += Excess;
00473     VisibleBtn->hi.y = VisibleBtn->lo.y + ButtonSize;
00474 
00475     MyRect->lo.x = VisibleBtn->hi.x + ButtonGap;    // And exclude it from 'MyRect'
00476 
00477 
00478     *LockedBtn = *MyRect;
00479     LockedBtn->hi.x = LockedBtn->lo.x + ButtonSize; // Make it a square
00480     LockedBtn->lo.y = VisibleBtn->lo.y;             // & use same y coords as for visible button
00481     LockedBtn->hi.y = VisibleBtn->hi.y;
00482 
00483     MyRect->lo.x = LockedBtn->hi.x + ButtonGap;     // And exclude it from 'MyRect'
00484 
00485 #if DO_SNAP_BUTTON
00486     if (SnapBtn != NULL)
00487     {
00488         *SnapBtn = *MyRect;
00489         SnapBtn->hi.x = SnapBtn->lo.x + ButtonSize; // Make it a square
00490         SnapBtn->lo.y = VisibleBtn->lo.y;               // & use same y coords as for visible button
00491         SnapBtn->hi.y = VisibleBtn->hi.y;
00492 
00493         MyRect->lo.x = SnapBtn->hi.x + ButtonGap;       // And exclude it from 'MyRect'
00494     }
00495 #else
00496     // If snapbtn is disabled, fill it in with a sensible rect, just to be safe
00497     if (SnapBtn != NULL)
00498         *SnapBtn = *LockedBtn;
00499 #endif
00500 
00501 
00502     // And grid align the 3 resulting rectangles...
00503     GridLockRect(MiscInfo, VisibleBtn);
00504     GridLockRect(MiscInfo, LockedBtn);
00505     if (SnapBtn != NULL)
00506         GridLockRect(MiscInfo, SnapBtn);
00507     GridLockRect(MiscInfo, MyRect);
00508 }

void SGDisplayLayer::CalculateMyRect SGFormatInfo FormatInfo,
SGMiscInfo MiscInfo
[protected, virtual]
 

Shared code for Layer items to calculate where they will appear in the grand scheme of things.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
FormatInfo - The formatting info from which to calculate my position/size [INPUTS] MiscInfo - As usual, the useful misc info struct
member variable FormatRect - is returned filled in with the size/position of [OUTPUTS] this Layer item's display area. This is dependent upon the current display mode and format state
FormatInfo will be updated as a result of the formatting operation

Notes: Layers supply only one display mode ("full info")

Scope: private (for use of SGDisplayLayer class only)

Definition at line 427 of file sglayer.cpp.

00428 {
00429     INT32 XSize = SG_InfiniteWidth;
00430     INT32 YSize = SG_DefaultSmallIcon;
00431 
00432     CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize);
00433 }

SGDisplayLayer::CC_DECLARE_DYNAMIC SGDisplayLayer   )  [private]
 

void SGDisplayLayer::ChangeRangeState SGDisplayLayer Start,
SGDisplayLayer End,
BOOL  Range,
INT32  WhichButton,
SGMiscInfo MiscInfo
[protected, virtual]
 

To handle extension-clicks on layers, we set the state of a range of layers rather than just the one clicked. The range usually extends to the layer which was previously clicked.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/8/95
Parameters:
Start - Points to the node, or start of a range of nodes, to set [INPUTS] End - NULL or points to the end of the range Range - TRUE to do a whole range, FALSE to do only the Start node This is used to override the range description. WhichButton - 0 to change VISIBLE state 1 to change LOCKED state 2 to change SNAP state MiscInfo - The usual (see HandleEvent)
Notes: This scans the sibling list containing Start, and sets the states of all layers it finds between start and end. If End is not found then Start is treated as a single item.

Scope: private

Definition at line 680 of file sglayer.cpp.

00682 {
00683     ERROR3IF(Start == NULL || MiscInfo == NULL, "Illegal NULL params");
00684 
00685     SuperGallery *ParentGallery = GetParentGallery();
00686     ERROR3IF(ParentGallery == NULL, "No parent gallery?! Weird!");
00687 
00688     // Determine the new state based on inverting this item's state
00689     BOOL NewState = TRUE;
00690     switch (WhichButton)
00691     {
00692         case 0:     // Visible state
00693             NewState = !(GetDisplayedLayer()->GetVisibleFlagState());
00694             break;
00695         
00696         case 1:     // Locked sate
00697             NewState = !(GetDisplayedLayer()->GetLockedFlagState());
00698             break;
00699 
00700         case 2:     // Snap state
00701 #if DO_SNAP_BUTTON
00702                 // **** MARKN NEEDS TO FIX THIS ****
00703                 NewState = !(GetDisplayedLayer()->GetVisibleFlagState());
00704 #endif
00705             break;
00706 
00707         default:
00708             ERROR3("Illegal WhichButton parameter to SGDisplayLayer::ChangeRangeState (must be 0..2)");
00709             break;
00710     }
00711 
00712     // Scan the sibling list to find the start and end nodes, and determine if end comes
00713     // before start (in which case we'll need to swap them over before continuing)
00714     SGDisplayLayer *Ptr = NULL;
00715 
00716     if (!Range || End == NULL)
00717         End = Start;
00718 
00719     BOOL FoundStart = FALSE;
00720     BOOL FoundEnd   = FALSE;
00721     BOOL MustSwap   = FALSE;
00722 
00723     Ptr = (SGDisplayLayer *) (Start->GetParent()->GetChild());
00724     while (Ptr != NULL)
00725     {
00726         if (Ptr == Start)
00727             FoundStart = TRUE;
00728 
00729         if (Ptr == End)
00730         {
00731             FoundEnd = TRUE;
00732             MustSwap = !FoundStart;     // If not found Start first, then the range is backwards
00733         }
00734 
00735         Ptr = (SGDisplayLayer *) Ptr->GetNext();
00736     }
00737 
00738     if (!FoundStart)        // Couldn't even find the start node!
00739     {
00740         ERROR3("Start node not found");
00741         return;
00742     }
00743 
00744     if (!FoundEnd)          // No end node? Make the range one item only
00745         End = Start;
00746 
00747     if (MustSwap)           // Range is backwards - swap the pointers
00748     {
00749         Ptr = Start;
00750         Start = End;
00751         End = Ptr;
00752     }
00753 
00754 
00755     // Now scan the list from Start to End, setting all the layers (inclusive)
00756     Ptr = Start;    
00757     
00758     while (Ptr != NULL)
00759     {
00760         DocRect MyRect(Ptr->FormatRect);
00761         DocRect VisibleBtn;
00762         DocRect LockedBtn;
00763         DocRect SnapBtn;
00764         Ptr->CalculateButtonRects(MiscInfo, &MyRect, &VisibleBtn, &LockedBtn, &SnapBtn);
00765 
00766         switch (WhichButton)
00767         {
00768             case 0:     // Visible state
00769                 Ptr->DoChangeState(LAYER_VISIBLE, NewState);
00770                 ParentGallery->ForceRedrawOfArea(&VisibleBtn);
00771                 break;
00772 
00773             case 1:     // Locked state
00774                 Ptr->DoChangeState(LAYER_LOCKED, NewState);
00775                 ParentGallery->ForceRedrawOfArea(&LockedBtn);
00776                 break;
00777 
00778             case 2:     // Snap state
00779 #if DO_SNAP_BUTTON
00780                 // **** MARKN NEEDS TO FIX THIS ****
00781                 Ptr->DoChangeState(LAYER_VISIBLE, NewState);
00782                 ParentGallery->ForceRedrawOfArea(&SnapBtn);
00783 #endif
00784                 break;
00785         }
00786 
00787         if (Ptr == End)                 // Slight strangeness to handle (Start==End) case
00788             Ptr = NULL;                                 // Have hit and processed End, so stop
00789         else
00790             Ptr = (SGDisplayLayer *) Ptr->GetNext();    // Have not, so go on to next layer
00791     }
00792 }

void SGDisplayLayer::DoChangeState OpLayerGalReason  Reason,
BOOL  NewState
[protected, virtual]
 

Called when a flag changes for a layer gallery item.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/8/94
Parameters:
Reason = reason code definiting what 'NewState' represents [INPUTS] NewState= boolean that determines the new state of the flag defined by 'Reason'
Returns:
-
Notes: Does not redraw the layer in the display list

Reimplemented in SGDisplayFrame.

Definition at line 1070 of file sglayer.cpp.

01071 {
01072     LayerSGallery* pGal = (LayerSGallery*)GetParentGallery();
01073     ERROR3IF(!IS_A(pGal,LayerSGallery),"Parent not a layer gallery");
01074     if (!IS_A(pGal,LayerSGallery)) return;
01075 
01076     Layer* pLayer = GetDisplayedLayer();
01077     pGal->DoChangeLayerState(pLayer,Reason,NewState);
01078 }

Layer * SGDisplayLayer::GetDisplayedLayer void   )  [inline]
 

To find out the Layer this object is responsible for displaying.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
Date:
27/1/95
Returns:
A pointer to the Layer which this Display Item is used to display.

Definition at line 237 of file sglayer.h.

00238 {
00239     return(TheLayer);
00240 }

BOOL SGDisplayLayer::HandleEvent SGEventType  EventType,
void *  EventInfo,
SGMiscInfo MiscInfo
[virtual]
 

Handles a SuperGallery DisplayTree event.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
EventType - An enumerated value describing what type of event is to be processed [INPUTS]
EventInfo - A structure describing the event (may be NULL). The exact thing pointed at by this pointer depends upon the event type:

MonoOn Event Thing EventInfo points at SGEVENT_FORMAT (SGFormatInfo *) SGEVENT_REDRAW (SGRedrawInfo *) SGEVENT_MOUSECLICK (SGMouseInfo *) MonoOff Use the provided SGDisplayNode::Get[Format]Info() inlines to retrieve this information - they provide useful error/type checking, and hide the cast

MiscInfo - always provided. Contains a few useful bits of info that may be needed for all event types.

Parameters:
FormatInfo is updated as appropriate [OUTPUTS]
Returns:
TRUE if the event was handled successfully FALSE if it was not
Notes: This overrides the pure virtual SGDisplayNode::HandleEvent method

A node need not handle a specific event - if it does not handle it, it should return FALSE.

Redraw and Formatting handlers should never return TRUE, as this will prevent the event from continuing through the tree.

Non-leaf-nodes must call SGDisplayNode::GiveEventToMyChildren in order to pass the event dow the tree. THIS node is a leaf-node, so it doesn't.

See also:
SGDisplayNode::HandleEvent

Reimplemented from SGDisplayItem.

Reimplemented in SGDisplayFrame.

Definition at line 843 of file sglayer.cpp.

00845 {
00846     switch (EventType)
00847     {
00848         case SGEVENT_FORMAT:
00849             {
00850                 SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo);
00851                 CalculateMyRect(FormatInfo, MiscInfo);      // Cache our FormatRect for later use
00852             }
00853             break;
00854 
00855 
00856         case SGEVENT_REDRAW:
00857             {
00858                 DocRect MyRect(FormatRect);     // Rely on FormatRect being cached from above
00859                 SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo);
00860 
00861                 if (IMustRedraw(RedrawInfo))    // only redraw if we intersect the clip rect
00862                     HandleRedraw(RedrawInfo, MiscInfo);
00863             }
00864             break;      // exit and return FALSE to pass the redraw event on
00865 
00866 
00867         case SGEVENT_MOUSECLICK:
00868             {
00869                 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
00870 
00871                 SuperGallery *ParentGallery = GetParentGallery();
00872                 ERROR3IF(ParentGallery == NULL, "No parent gallery?! Weird!");
00873 
00874                 if (FormatRect.ContainsCoord(Mouse->Position))
00875                 {
00876                     DocRect MyRect(FormatRect);
00877                     DocRect VisibleBtn;
00878                     DocRect LockedBtn;
00879                     DocRect SnapBtn;
00880                     Document* pDoc = (Document*)GetDisplayedLayer()->FindOwnerDoc();
00881                     ERROR2IF(pDoc == NULL,TRUE,"Can't find owner doc for layer");
00882                     ERROR2IF(!IS_A(pDoc,Document),TRUE,"Owner doc is not a Document");
00883 
00884                     Layer* pLayer = GetDisplayedLayer();
00885                     ERROR2IF(pLayer == NULL,TRUE,"GetDisplayedLayer() returned NULL");
00886 
00887                     // Find out the state of the layer's flags
00888                     BOOL ActiveAndVisEd = (pLayer->IsActive() && Layer::ActiveLayerVisibleAndEditable);
00889 //                  BOOL Visible        = pLayer->GetVisibleFlagState();
00890 //                  BOOL Locked         = pLayer->GetLockedFlagState();
00891                     BOOL Guide          = pLayer->IsGuide();
00892                     BOOL PageBackground = pLayer->IsPageBackground();
00893 
00894 
00895                     CalculateButtonRects(MiscInfo, &MyRect, &VisibleBtn, &LockedBtn, &SnapBtn);
00896 
00897                     // Ignore menu clicks on the Visible button
00898                     if (!Mouse->MenuClick && VisibleBtn.ContainsCoord(Mouse->Position))
00899                     {
00900                         // Only change the actual setting if the AllVisible flag is clear
00901                         // and it's not the active layer with the 'active layer is visible and edtable' pref on
00902                         if (Guide || (!pDoc->IsAllVisible() && !ActiveAndVisEd))
00903                         {
00904                             ChangeRangeState(this, LastClickedLayer, Mouse->Extend, 0, MiscInfo);
00905 //                          DoChangeState(LAYER_VISIBLE,!Visible);
00906 //                          ParentGallery->ForceRedrawOfArea(&VisibleBtn);
00907 
00908                             // Remember this as the "anchor" layer for extend-click setting of ranges
00909                             LastClickedLayer = this;
00910                         }
00911                         else
00912                         {
00913                             UINT32 IDS = _R(IDS_LAYER_NOCHANGE_VISIBLE);
00914 
00915                             if (ActiveAndVisEd)
00916                                 IDS = _R(IDS_LAYER_NOCHANGE_VISIBLE_ACTIVE);
00917 
00918                             String_256 msg(IDS);
00919                             GetApplication()->UpdateStatusBarText(&msg);
00920                             Beep();
00921                         }
00922 
00923                         break;
00924                     }
00925 
00926                     // Ignore menu clicks on the Locked button
00927                     if (!Mouse->MenuClick && LockedBtn.ContainsCoord(Mouse->Position))
00928                     {
00929                         // Only change the actual setting if the Multilayer flag is clear
00930                         // and it's not the active layer with the 'active layer is visible and editable' pref on
00931                         // Now disallow the user the edit the page background layer.
00932                         if (!PageBackground && !pDoc->IsMultilayer() && !ActiveAndVisEd)
00933                         {
00934                             ChangeRangeState(this, LastClickedLayer, Mouse->Extend, 1, MiscInfo);
00935 //                          DoChangeState(LAYER_LOCKED,!Locked);
00936 //                          ParentGallery->ForceRedrawOfArea(&LockedBtn);
00937 
00938                             // Remember this as the "anchor" layer for extend-click setting of ranges
00939                             LastClickedLayer = this;
00940                         }
00941                         else
00942                         {
00943                             UINT32 IDS = _R(IDS_LAYER_NOCHANGE_LOCKED);
00944 
00945                             if (PageBackground)
00946                                 IDS = _R(IDS_LAYER_NOCHANGE_BACKGROUND);
00947 
00948                             if (ActiveAndVisEd)
00949                                 IDS = _R(IDS_LAYER_NOCHANGE_LOCKED_ACTIVE);
00950 
00951                             String_256 msg(IDS);
00952                             GetApplication()->UpdateStatusBarText(&msg);
00953                             Beep();
00954                         }
00955 
00956                         break;
00957                     }
00958 
00959 #if DO_SNAP_BUTTON
00960                     // Ignore menu clicks on the Snap button
00961                     if (!Mouse->MenuClick && SnapBtn.ContainsCoord(Mouse->Position))
00962                     {
00963                         // Only change the actual setting if the AllVisible flag is clear
00964                         // and it's not the active layer with the 'active layer is visible and edtable' pref on
00965                         
00966                         // **** MARKN NEEDS TO FIX THIS ****
00967                         // Mark: This currently all sets the visible state of the layer.
00968                         if (!pDoc->IsAllVisible() && !ActiveAndVisEd)
00969                         {
00970                             ChangeRangeState(this, LastClickedLayer, Mouse->Extend, 2, MiscInfo);
00971 //                          DoChangeState(LAYER_VISIBLE,!Visible);
00972 //                          ParentGallery->ForceRedrawOfArea(&VisibleBtn);
00973 
00974                             // Remember this as the "anchor" layer for extend-click setting of ranges
00975                             LastClickedLayer = this;
00976                         }
00977                         else
00978                         {
00979                             UINT32 IDS = _R(IDS_LAYER_NOCHANGE_VISIBLE);
00980 
00981                             if (ActiveAndVisEd)
00982                                 IDS = _R(IDS_LAYER_NOCHANGE_VISIBLE_ACTIVE);
00983 
00984                             String_256 msg(IDS);
00985                             GetApplication()->UpdateStatusBarText(&msg);
00986                             Beep();
00987                         }
00988 
00989                         break;
00990                     }
00991 #endif
00992 
00993                     // Only treat clicks as selection clicks if they are to the right of the tick buttons
00994                     // This is easy, as MyRect excludes the buttons
00995                     if (MyRect.ContainsCoord(Mouse->Position))
00996                     {
00997                         // In the layer gallery the selection can never be more than one item,
00998                         // so all clicks are treated like Select clicks.
00999                         if (!Flags.Selected)
01000                         {
01001                             // Make the layer we're displaying the active one
01002                             Layer* pLayer = GetDisplayedLayer();
01003                             LayerSGallery::MakeActiveLayer(pLayer);
01004 
01005                             // Now update the selection states...
01006                             ParentGallery->SelectItems(FALSE);  // Deselect everything else
01007 
01008                             // Repaint the list box now. This is because if there is a large
01009                             // distance between the old selection and the new one, we get a huge
01010                             // redraw cliprect, so get a (slow) complete redraw, instead of two
01011                             // small redraws. It is thus better to break the redraw into 2 steps
01012                             // so that we are more likely to get 2 fast redraws than one slow one.
01013                             //ParentGallery->PaintGadgetNow(_R(IDC_GALLERY_LISTBOX));
01014                             ParentGallery->PaintListNow();
01015                         
01016                             // And select myself, and the new active layer
01017                             SetSelected(TRUE);
01018 
01019                             // My selection state has changed, so I'd better redraw myself
01020                             ForceRedrawOfMyself();
01021 
01022                             // And inform the parent gallery that the selection has changed, so
01023                             // it can shade/unshade buttons as appropriate, etc
01024                             ParentGallery->SelectionHasChanged();
01025                         }
01026 
01027                         // Remember this as the "anchor" layer for extend-click setting of ranges
01028                         LastClickedLayer = this;
01029 
01030                         // Start a drag on the layer item
01031                         SGListDragInfo* pDragInfo = new SGListDragInfo(ParentGallery,this,Mouse,Mouse->MenuClick);
01032 
01033                         if (pDragInfo != NULL)
01034                             DragManagerOp::StartDrag(pDragInfo, GetParentGallery()->GetReadWriteWindowID());
01035                     }
01036 
01037                     return(TRUE);       // Claim this event - nobody else can own this click
01038                 }
01039             }
01040             break;
01041 
01042 
01043         default:
01044             // Let the base class handle all unknown/unwanted events
01045             return(SGDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo));
01046     }
01047 
01048     // Default return value: We do not claim this event, so it will be passed on to others
01049     return(FALSE);
01050 }

void SGDisplayLayer::HandleRedraw SGRedrawInfo RedrawInfo,
SGMiscInfo MiscInfo
[protected, virtual]
 

SGDisplayLayer item redraw method - removed from the main HandleEvent method merely to make the code tidier.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
RedrawInfo - The information on the kernel-rendered redraw area [INPUTS] FormatInfo - The formatting information structure
member variable FormatRect should be set up (before calling this method) to be the rectangle in which to draw this item

Scope: private

Reimplemented in SGDisplayFrame.

Definition at line 533 of file sglayer.cpp.

00534 {
00535     StartRendering(RedrawInfo, MiscInfo);
00536 
00537     DocRect MyRect(FormatRect);     // Get my redraw position from the cached FormatRect
00538 
00539     RenderRegion *Renderer = RedrawInfo->Renderer;
00540 
00541 //  INT32 OnePixel  = (INT32) DevicePixels(MiscInfo, 1);
00542 //  INT32 TwoPixels = (INT32) DevicePixels(MiscInfo, 2);
00543 
00544     Renderer->SetLineWidth(0);
00545     Renderer->SetLineColour(RedrawInfo->Transparent);
00546     DocColour fill(191, 191, 191);
00547     Renderer->SetFillColour(fill);
00548 
00549     // Calculate and redraw the buttons
00550     // NOTE:
00551     // The buttons are usually blank grey rectangles, or a rectangle with an eye/lock
00552     // glyph on them. However, to hint at what the buttons are for, the selected layer
00553     // also shows the buttons in a greyed state
00554 
00555     DocRect VisibleBtn;
00556     DocRect LockedBtn;
00557     DocRect SnapBtn;
00558 
00559     CalculateButtonRects(MiscInfo, &MyRect, &VisibleBtn, &LockedBtn, &SnapBtn);
00560 
00561     // Find out the state of the layer's flags
00562     BOOL ActiveAndVisEd = (GetDisplayedLayer()->IsActive() && Layer::ActiveLayerVisibleAndEditable);
00563     BOOL Visible        = GetDisplayedLayer()->IsVisible();
00564     BOOL Locked         = GetDisplayedLayer()->IsLocked();
00565     BOOL Guide          = GetDisplayedLayer()->IsGuide();
00566     Document* pDoc = (Document*)GetDisplayedLayer()->FindOwnerDoc();
00567 
00568     ERROR3IF(pDoc == NULL,"Displayed layer doesn't have an owner doc");
00569     if (pDoc == NULL) return;
00570 
00571     // Draw 'visible' button (The glyph is "on" when the layer is visible)
00572     if (Visible)
00573     {
00574         if (!Guide && (ActiveAndVisEd || pDoc->IsAllVisible()))
00575             DrawBitmap(Renderer, &VisibleBtn, _R(IDB_LGAL_TICKFORCED));
00576         else
00577             DrawBitmap(Renderer, &VisibleBtn, _R(IDB_LGAL_TICKON));
00578     }
00579     else
00580         DrawBitmap(Renderer, &VisibleBtn, _R(IDB_LGAL_TICKOFF));
00581 
00582     // Draw 'Locked' button (Glyph is on if the layer is unlocked)
00583     if (!Locked)
00584     {
00585         if (ActiveAndVisEd || pDoc->IsMultilayer())
00586             DrawBitmap(Renderer, &LockedBtn, _R(IDB_LGAL_TICKFORCED));
00587         else
00588             DrawBitmap(Renderer, &LockedBtn, _R(IDB_LGAL_TICKON));
00589     }
00590     else
00591         DrawBitmap(Renderer, &LockedBtn, _R(IDB_LGAL_TICKOFF));
00592 
00593 #if DO_SNAP_BUTTON
00594     // Draw 'Snap' button
00595     if (Snap)
00596     {
00597         if (FALSE)      // **** MARKN NEEDS TO FIX THIS ****
00598             DrawBitmap(Renderer, &SnapBtn, _R(IDB_LGAL_TICKFORCED));    // Globally "forced to be ticked"
00599         else
00600             DrawBitmap(Renderer, &SnapBtn, _R(IDB_LGAL_TICKON));        // Just ticked normally
00601     }
00602     else
00603         DrawBitmap(Renderer, &SnapBtn, _R(IDB_LGAL_TICKOFF));           // Just ticked normally
00604 #endif
00605 
00606     Layer* pLayer = GetDisplayedLayer();
00607     ERROR3IF(pLayer == NULL, "I'm displaying a NULL layer? Serious screwup has occurred!");
00608     if (pLayer == NULL)
00609         return;
00610 
00611     DocColour Foreground = RedrawInfo->Foreground;
00612     DocColour Background = RedrawInfo->Background;
00613     DocColour SelForeground = RedrawInfo->SelForeground;
00614     DocColour SelBackground = RedrawInfo->SelBackground;
00615 
00616     if (pLayer->IsGuide())
00617     {
00618         Foreground      = DocColour(COLOUR_RED);
00619         SelBackground   = DocColour(COLOUR_RED);
00620     }
00621 
00622     if (pLayer->IsPageBackground())
00623     {
00624         Foreground      = DocColour(COLOUR_MIDGREY);
00625         SelBackground   = DocColour(COLOUR_MIDGREY);
00626     }
00627 
00628     // Set up the colours for rendering our text, and fill the background if selected
00629     if (Flags.Selected)
00630     {
00631         // Fill the entire background with the 'selected' colour, so we don't
00632         // get gaps between bits of text or uneven rectangles in multiple selections
00633         Renderer->SetFillColour(SelBackground);
00634         Renderer->DrawRect(&MyRect);
00635         Renderer->SetFixedSystemTextColours(&SelForeground,&SelBackground);
00636     }
00637     else
00638         Renderer->SetFixedSystemTextColours(&Foreground, &Background);
00639 
00640     MyRect.lo.x += SG_GapBeforeText;    // Leave a small gap before text begins
00641 
00642     // And render the text
00643     String_256 MyText = pLayer->GetLayerID();
00644     Renderer->DrawFixedSystemText(&MyText, MyRect);             
00645 
00646     StopRendering(RedrawInfo, MiscInfo);
00647 }

void SGDisplayLayer::MoveAfter SGDisplayNode NodeToMove  )  [virtual]
 

Called when the Locked button is clicked in a layer gallery item. Changes the lockedness of the displayed layer.MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (from a Jason func)
Date:
21/3/95
Parameters:
NodeToMove - the node to move [INPUTS]
Returns:
Errors: ERROR3 and quiet exit if NodeToMove == NULL
See also:
SuperGallery; SGDisplayNode::MoveAfter; SGDisplayNode::InsertAfter; SGDisplayNode::AddItem

Reimplemented from SGDisplayNode.

Definition at line 1137 of file sglayer.cpp.

01138 {
01139     ERROR3IF(NodeToMove == NULL, "Illegal NULL param");
01140     if (NodeToMove == this || NodeToMove == NULL)
01141         return;
01142 
01143     // Call base class to shift around the display item
01144     SGDisplayItem::MoveAfter(NodeToMove);
01145 
01146     // And move the associated layer in the docuemnt tree
01147     MoveLayer(NodeToMove,FALSE,FALSE);
01148 }

void SGDisplayLayer::MoveBefore SGDisplayNode NodeToMove  )  [virtual]
 

MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (from a Jason func)
Date:
21/3/95
Parameters:
NodeToMove - the node to move [INPUTS]
Notes: This base class method simply delinks the item and relinks it elsewhere in the display tree. However, derived classes will override this method so that moving display items can have a further effect of also rearranging the displayed "real" items. Before/After moving the real item, the derived class can then call this baseclass method to complete the action.

Take care when moving items between groups (e.g. if an item is "moved" from one docuemnt to another, it could be a bad thing, so be very careful in derived classes to take appropriate action)

Any attempt to move an item before *itself* is queitly ignored

Returns:
Errors: ERROR3 and quiet exit if NodeToMove == NULL
See also:
SuperGallery; SGDisplayNode::MoveBefore; SGDisplayNode::InsertBefore; SGDisplayNode::AddItem

Reimplemented from SGDisplayNode.

Definition at line 1184 of file sglayer.cpp.

01185 {
01186     ERROR3IF(NodeToMove == NULL, "Illegal NULL param");
01187     if (NodeToMove == this || NodeToMove == NULL)
01188         return;
01189 
01190     // Call base class to shift around the display item
01191     SGDisplayItem::MoveBefore(NodeToMove);
01192 
01193     // And move the associated layer in the docuemnt tree
01194     MoveLayer(NodeToMove,TRUE,FALSE);
01195 }

void SGDisplayLayer::MoveLayer SGDisplayNode NodeToMove,
BOOL  Before,
BOOL  ToggleBackground
[virtual]
 

This moves the given layer either before or after this layer, in an undoable way.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/3/95
Parameters:
NodeToMove = the node to move (which specifies the layer to move) [INPUTS] Before = if TRUE the layer is moved previous (before) this layer, otherwise the layer is moved next (after) this layer ToggleBacground = TRUE if the background flag should be toggled when moved
Returns:
Errors: ERROR3 and quiet exit if NodeToMove == NULL
See also:
SuperGallery; SGDisplayNode::MoveAfter; SGDisplayNode::InsertAfter; SGDisplayNode::AddItem

Reimplemented in SGDisplayFrame.

Definition at line 1219 of file sglayer.cpp.

01220 {
01221 PORTNOTE("galleries", "disabled frame gallery")
01222 #ifndef EXCLUDE_FROM_XARALX
01223     ERROR3IF((!IS_A(NodeToMove,SGDisplayLayer) && !IS_A(NodeToMove,SGDisplayFrame)),"The node to move is not a SGDisplayLayer");
01224     if (!IS_A(NodeToMove,SGDisplayLayer) && !IS_A(NodeToMove,SGDisplayFrame))
01225         return;
01226 #else
01227     ERROR3IF((!IS_A(NodeToMove,SGDisplayLayer)),"The node to move is not a SGDisplayLayer");
01228     if (!IS_A(NodeToMove,SGDisplayLayer))
01229         return;
01230 #endif
01231 
01232     Layer* pLayerToMove = ((SGDisplayLayer*)NodeToMove)->GetDisplayedLayer();
01233     Layer* pThisLayer   = GetDisplayedLayer();
01234 
01235     Spread* pSpread = pLayerToMove->FindParentSpread();
01236     ERROR3IF(pSpread == NULL,"Parent spread is NULL");
01237     if (pSpread == NULL)
01238         return; 
01239     
01240     OpLayerGalReason Reason;
01241 
01242     if (pLayerToMove == pThisLayer)
01243     {
01244         // if the context node and the layer to move are the same, and we don't have to toggle
01245         // the background flag, just return (give errors in debug mode)
01246         ERROR3IF(!ToggleBackground,"Not moving the layer OR toggling the background flag, so why did you call?");
01247         if (!ToggleBackground)
01248             return;
01249 
01250         Reason = LAYER_TOGGLEBACKGROUND;
01251     }
01252     else
01253         Reason = LAYER_MOVE;
01254     
01255 
01256     OpLayerGalParam Param(Reason,pSpread);
01257 
01258     Param.pLayer            = pLayerToMove;
01259     Param.pContextNode      = pThisLayer;
01260     Param.MoveRedraw        = TRUE;
01261     Param.ToggleBackground  = ToggleBackground;
01262     Param.pLayerSGal        = (LayerSGallery*)GetParentGallery();
01263 
01264     if (Before)
01265         Param.AttDir = NEXT;    // next means insert-before-this
01266     else
01267         Param.AttDir = PREV;    // prev means insert-after-this
01268 
01269     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERGALCHANGE); 
01270     if (pOpDesc != NULL)
01271         pOpDesc->Invoke((OpParam*)&Param);
01272     else
01273     {
01274         ENSURE(FALSE,"Couldn't find OPTOKEN_LAYERGALCHANGE op descriptor");
01275     }
01276 }


Friends And Related Function Documentation

friend class SGLayerGroup [friend]
 

Reimplemented in SGDisplayFrame.

Definition at line 140 of file sglayer.h.


Member Data Documentation

SGDisplayLayer * SGDisplayLayer::LastClickedLayer = NULL [static, private]
 

Reimplemented in SGDisplayFrame.

Definition at line 184 of file sglayer.h.

Layer* SGDisplayLayer::TheLayer [protected]
 

Definition at line 181 of file sglayer.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:01:00 2007 for Camelot by  doxygen 1.4.4