#include <sgframe.h>
Inheritance diagram for SGDisplayFrame:
Public Member Functions | |
SGDisplayFrame () | |
SGDisplayFrame constructor DON'T call this constructor. It ERROR3's. Call the other constructor. | |
SGDisplayFrame (Layer *LayerToDisplay) | |
SGDisplayFrame constructor. | |
~SGDisplayFrame () | |
SGDisplayFrame destructor. | |
virtual BOOL | HandleEvent (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo) |
Handles a SuperGallery DisplayTree event. | |
virtual void | MoveLayer (SGDisplayNode *NodeToMove, BOOL Before, BOOL ToggleBackground) |
This moves the given layer either before or after this layer, in an undoable way. | |
Protected Member Functions | |
virtual void | HandleRedraw (SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo) |
SGDisplayFrame 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 (SGDisplayFrame *Start, SGDisplayFrame *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. | |
Private Member Functions | |
CC_DECLARE_DYNAMIC (SGDisplayFrame) | |
Static Private Attributes | |
static SGDisplayFrame * | LastClickedLayer = NULL |
Friends | |
class | SGLayerGroup |
class | SGFrameGroup |
Definition at line 134 of file sgframe.h.
|
SGDisplayFrame constructor DON'T call this constructor. It ERROR3's. Call the other constructor.
Definition at line 329 of file sgframe.cpp. 00329 : SGDisplayLayer() 00330 { 00331 // Let the baseclass handle it 00332 }
|
|
SGDisplayFrame constructor.
Definition at line 349 of file sgframe.cpp. 00349 : SGDisplayLayer(LayerToDisplay) 00350 { 00351 // Let the baseclass handle it 00352 }
|
|
SGDisplayFrame destructor.
Definition at line 369 of file sgframe.cpp. 00370 { 00371 // Make sure LastClickedLayer pointer is not left in an invalid state 00372 if (this == LastClickedLayer) 00373 LastClickedLayer = NULL; 00374 }
|
|
|
|
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.
Scope: private Definition at line 552 of file sgframe.cpp. 00554 { 00555 ERROR3IF(Start == NULL || MiscInfo == NULL, "Illegal NULL params"); 00556 00557 SuperGallery *ParentGallery = GetParentGallery(); 00558 ERROR3IF(ParentGallery == NULL, "No parent gallery?! Weird!"); 00559 00560 // Determine the new state based on inverting this item's state 00561 BOOL NewState = TRUE; 00562 switch (WhichButton) 00563 { 00564 case 0: // Solid state 00565 NewState = !(GetDisplayedLayer()->IsSolid()); 00566 break; 00567 00568 case 1: // Overlayed sate 00569 NewState = !(GetDisplayedLayer()->IsOverlay()); 00570 break; 00571 00572 default: 00573 ERROR3("Illegal WhichButton parameter to SGDisplayFrame::ChangeRangeState (must be 0..2)"); 00574 break; 00575 } 00576 00577 // Scan the sibling list to find the start and end nodes, and determine if end comes 00578 // before start (in which case we'll need to swap them over before continuing) 00579 SGDisplayFrame *Ptr = NULL; 00580 00581 if (!Range || End == NULL) 00582 End = Start; 00583 00584 BOOL FoundStart = FALSE; 00585 BOOL FoundEnd = FALSE; 00586 BOOL MustSwap = FALSE; 00587 00588 Ptr = (SGDisplayFrame *) (Start->GetParent()->GetChild()); 00589 while (Ptr != NULL) 00590 { 00591 if (Ptr == Start) 00592 FoundStart = TRUE; 00593 00594 if (Ptr == End) 00595 { 00596 FoundEnd = TRUE; 00597 MustSwap = !FoundStart; // If not found Start first, then the range is backwards 00598 } 00599 00600 Ptr = (SGDisplayFrame *) Ptr->GetNext(); 00601 } 00602 00603 if (!FoundStart) // Couldn't even find the start node! 00604 { 00605 ERROR3("Start node not found"); 00606 return; 00607 } 00608 00609 if (!FoundEnd) // No end node? Make the range one item only 00610 End = Start; 00611 00612 if (MustSwap) // Range is backwards - swap the pointers 00613 { 00614 Ptr = Start; 00615 Start = End; 00616 End = Ptr; 00617 } 00618 00619 00620 // Now scan the list from Start to End, setting all the layers (inclusive) 00621 Ptr = Start; 00622 00623 while (Ptr != NULL) 00624 { 00625 DocRect MyRect(Ptr->FormatRect); 00626 DocRect VisibleBtn; 00627 DocRect LockedBtn; 00628 DocRect SnapBtn; 00629 Ptr->CalculateButtonRects(MiscInfo, &MyRect, &VisibleBtn, &LockedBtn, &SnapBtn); 00630 00631 switch (WhichButton) 00632 { 00633 case 0: // Visible state 00634 // Notify the gif animation property tabs dlg about this state change. 00635 // This allows us to sit on the ACTIVE_LAYER_CHANGED message. 00636 GIFAnimationPropertyTabs::SetChangeLayerState(TRUE); 00637 00638 // Ask the gallery to change the state of the flag 00639 Ptr->DoChangeState(LAYER_SOLID, NewState); 00640 // Do a redraw so we notice the change 00641 ParentGallery->ForceRedrawOfArea(&VisibleBtn); 00642 00643 // Set this flag back to false. 00644 GIFAnimationPropertyTabs::SetChangeLayerState(FALSE); 00645 break; 00646 00647 case 1: // Locked state 00648 // Notify the gif animation property tabs dlg about this state change. 00649 // This allows us to sit on the ACTIVE_LAYER_CHANGED message. 00650 GIFAnimationPropertyTabs::SetChangeLayerState(TRUE); 00651 00652 // Ask the gallery to change the state of the flag 00653 Ptr->DoChangeState(LAYER_OVERLAY, NewState); 00654 // Do a redraw so we notice the change 00655 ParentGallery->ForceRedrawOfArea(&LockedBtn); 00656 00657 // Set this flag back to false. 00658 GIFAnimationPropertyTabs::SetChangeLayerState(FALSE); 00659 break; 00660 } 00661 00662 if (Ptr == End) // Slight strangeness to handle (Start==End) case 00663 Ptr = NULL; // Have hit and processed End, so stop 00664 else 00665 Ptr = (SGDisplayFrame *) Ptr->GetNext(); // Have not, so go on to next layer 00666 } 00667 }
|
|
Called when a flag changes for a layer gallery item.
Reimplemented from SGDisplayLayer. Definition at line 901 of file sgframe.cpp. 00902 { 00903 FrameSGallery* pGal = (FrameSGallery*)GetParentGallery(); 00904 ERROR3IF(!IS_A(pGal,FrameSGallery),"Parent not a frame gallery"); 00905 if (!IS_A(pGal,FrameSGallery)) return; 00906 00907 Layer* pLayer = GetDisplayedLayer(); 00908 pGal->DoChangeLayerState(pLayer,Reason,NewState); 00909 }
|
|
Handles a SuperGallery DisplayTree event.
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.
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.
Reimplemented from SGDisplayLayer. Definition at line 718 of file sgframe.cpp. 00720 { 00721 switch (EventType) 00722 { 00723 case SGEVENT_FORMAT: 00724 { 00725 SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo); 00726 CalculateMyRect(FormatInfo, MiscInfo); // Cache our FormatRect for later use 00727 } 00728 break; 00729 00730 00731 case SGEVENT_REDRAW: 00732 { 00733 DocRect MyRect(FormatRect); // Rely on FormatRect being cached from above 00734 SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo); 00735 00736 if (IMustRedraw(RedrawInfo)) // only redraw if we intersect the clip rect 00737 HandleRedraw(RedrawInfo, MiscInfo); 00738 } 00739 break; // exit and return FALSE to pass the redraw event on 00740 00741 00742 case SGEVENT_MOUSECLICK: 00743 { 00744 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo); 00745 00746 SuperGallery *ParentGallery = GetParentGallery(); 00747 ERROR3IF(ParentGallery == NULL, "No parent gallery?! Weird!"); 00748 00749 if (FormatRect.ContainsCoord(Mouse->Position)) 00750 { 00751 DocRect MyRect(FormatRect); 00752 DocRect VisibleBtn; 00753 DocRect LockedBtn; 00754 DocRect SnapBtn; 00755 Document* pDoc = (Document*)GetDisplayedLayer()->FindOwnerDoc(); 00756 ERROR2IF(pDoc == NULL,TRUE,"Can't find owner doc for layer"); 00757 ERROR2IF(!IS_A(pDoc,Document),TRUE,"Owner doc is not a Document"); 00758 00759 Layer* pLayer = GetDisplayedLayer(); 00760 ERROR2IF(pLayer == NULL,TRUE,"GetDisplayedLayer() returned NULL"); 00761 00762 // Find out the state of the layer's flags 00763 BOOL ActiveAndVisEd = (pLayer->IsActive() && Layer::ActiveLayerVisibleAndEditable); 00764 //BOOL Visible = pLayer->GetVisibleFlagState(); 00765 //BOOL Locked = pLayer->GetLockedFlagState(); 00766 BOOL Guide = pLayer->IsGuide(); 00767 BOOL Solid = pLayer->IsSolid(); 00768 //BOOL Guide = pLayer->IsOverlay(); 00769 00770 CalculateButtonRects(MiscInfo, &MyRect, &VisibleBtn, &LockedBtn, &SnapBtn); 00771 00772 // Ignore menu clicks on the Visible button 00773 if (!Mouse->MenuClick && VisibleBtn.ContainsCoord(Mouse->Position)) 00774 { 00775 // At present always change the actual setting of the Solid flag 00776 if (TRUE) //Guide || (!pDoc->IsAllVisible() && !ActiveAndVisEd)) 00777 { 00778 ChangeRangeState(this, LastClickedLayer, Mouse->Extend, 0, MiscInfo); 00779 // Remember this as the "anchor" layer for extend-click setting of ranges 00780 LastClickedLayer = this; 00781 00782 // We need to force a redraw of the overlay button as it is dependent 00783 // on the locked state 00784 ParentGallery->ForceRedrawOfArea(&LockedBtn); 00785 } 00786 else 00787 { 00788 UINT32 IDS = _R(IDS_LAYER_NOCHANGE_VISIBLE); 00789 00790 if (ActiveAndVisEd) 00791 IDS = _R(IDS_LAYER_NOCHANGE_VISIBLE_ACTIVE); 00792 00793 String_256 msg(IDS); 00794 GetApplication()->UpdateStatusBarText(&msg); 00795 Beep(); 00796 } 00797 00798 break; 00799 } 00800 00801 // Ignore menu clicks on the Locked button 00802 if (!Mouse->MenuClick && LockedBtn.ContainsCoord(Mouse->Position)) 00803 { 00804 // Only change the actual setting if the Multilayer flag is clear 00805 // and it's not the active layer with the 'active layer is visible and edtable' pref on 00806 if (!Solid) 00807 { 00808 ChangeRangeState(this, LastClickedLayer, Mouse->Extend, 1, MiscInfo); 00809 // Remember this as the "anchor" layer for extend-click setting of ranges 00810 LastClickedLayer = this; 00811 } 00812 else 00813 { 00814 UINT32 IDS = _R(IDS_LAYER_NOCHANGE_OVERLAY); 00815 00816 String_256 msg(IDS); 00817 GetApplication()->UpdateStatusBarText(&msg); 00818 Beep(); 00819 } 00820 00821 break; 00822 } 00823 00824 // Only treat clicks as selection clicks if they are to the right of the tick buttons 00825 // This is easy, as MyRect excludes the buttons 00826 if (MyRect.ContainsCoord(Mouse->Position)) 00827 { 00828 // In the layer gallery the selection can never be more than one item, 00829 // so all clicks are treated like Select clicks. 00830 if (!Flags.Selected) 00831 { 00832 // Make the layer we're displaying the active one 00833 Layer* pLayer = GetDisplayedLayer(); 00834 FrameSGallery::MakeActiveLayer(pLayer); 00835 00836 // Now update the selection states... 00837 ParentGallery->SelectItems(FALSE); // Deselect everything else 00838 00839 // Repaint the list box now. This is because if there is a large 00840 // distance between the old selection and the new one, we get a huge 00841 // redraw cliprect, so get a (slow) complete redraw, instead of two 00842 // small redraws. It is thus better to break the redraw into 2 steps 00843 // so that we are more likely to get 2 fast redraws than one slow one. 00844 //ParentGallery->PaintGadgetNow(_R(IDC_GALLERY_LISTBOX)); 00845 ParentGallery->PaintListNow(); 00846 00847 // And select myself, and the new active layer 00848 SetSelected(TRUE); 00849 00850 // My selection state has changed, so I'd better redraw myself 00851 ForceRedrawOfMyself(); 00852 00853 // And inform the parent gallery that the selection has changed, so 00854 // it can shade/unshade buttons as appropriate, etc 00855 ParentGallery->SelectionHasChanged(); 00856 } 00857 00858 // Remember this as the "anchor" layer for extend-click setting of ranges 00859 LastClickedLayer = this; 00860 00861 // Start a drag on the layer item 00862 SGListDragInfo* pDragInfo = new SGListDragInfo(ParentGallery,this,Mouse,Mouse->MenuClick); 00863 00864 if (pDragInfo != NULL) 00865 DragManagerOp::StartDrag(pDragInfo, GetListWindow()); 00866 } 00867 00868 return(TRUE); // Claim this event - nobody else can own this click 00869 } 00870 } 00871 break; 00872 00873 00874 default: 00875 // Let the base class handle all unknown/unwanted events 00876 return(SGDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo)); 00877 } 00878 00879 // Default return value: We do not claim this event, so it will be passed on to others 00880 return(FALSE); 00881 }
|
|
SGDisplayFrame item redraw method - removed from the main HandleEvent method merely to make the code tidier.
Scope: private Reimplemented from SGDisplayLayer. Definition at line 399 of file sgframe.cpp. 00400 { 00401 StartRendering(RedrawInfo, MiscInfo); 00402 00403 DocRect MyRect(FormatRect); // Get my redraw position from the cached FormatRect 00404 00405 RenderRegion *Renderer = RedrawInfo->Renderer; 00406 00407 INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1); 00408 INT32 TwoPixels = (INT32) DevicePixels(MiscInfo, 2); 00409 00410 Renderer->SetLineWidth(0); 00411 Renderer->SetLineColour(RedrawInfo->Transparent); 00412 Renderer->SetFillColour(DocColour(191L, 191L, 191L)); 00413 00414 // Calculate and redraw the buttons 00415 // NOTE: 00416 // The buttons are usually blank grey rectangles, or a rectangle with an eye/lock 00417 // glyph on them. However, to hint at what the buttons are for, the selected layer 00418 // also shows the buttons in a greyed state 00419 00420 DocRect VisibleBtn; 00421 DocRect LockedBtn; 00422 DocRect SnapBtn; 00423 00424 CalculateButtonRects(MiscInfo, &MyRect, &VisibleBtn, &LockedBtn, &SnapBtn); 00425 00426 // Find out the state of the layer's flags 00427 BOOL ActiveAndVisEd = (GetDisplayedLayer()->IsActive() && Layer::ActiveLayerVisibleAndEditable); 00428 // BOOL Visible = GetDisplayedLayer()->IsVisible(); 00429 // BOOL Locked = GetDisplayedLayer()->IsLocked(); 00430 BOOL Guide = GetDisplayedLayer()->IsGuide(); 00431 BOOL Solid = GetDisplayedLayer()->IsSolid(); 00432 BOOL Overlay = GetDisplayedLayer()->IsOverlay(); 00433 BOOL Edited = GetDisplayedLayer()->IsEdited(); 00434 Document* pDoc = (Document*)GetDisplayedLayer()->FindOwnerDoc(); 00435 00436 ERROR3IF(pDoc == NULL,"Displayed layer doesn't have an owner doc"); 00437 if (pDoc == NULL) return; 00438 00439 // Draw 'Solid' button (The glyph is "on" when the layer is solid) 00440 if (Solid) 00441 { 00442 //if (!Guide && (ActiveAndVisEd || pDoc->IsAllVisible())) 00443 // DrawBitmap(Renderer, &VisibleBtn, _R(IDB_LGAL_TICKFORCED)); 00444 //else 00445 DrawBitmap(Renderer, &VisibleBtn, _R(IDB_LGAL_TICKON)); 00446 } 00447 else 00448 DrawBitmap(Renderer, &VisibleBtn, _R(IDB_LGAL_TICKOFF)); 00449 00450 // Draw 'Overlay' button (Glyph is on if the layer is overlayed) 00451 if (Overlay) 00452 { 00453 // If Solid is on then this is superfluous so render the greyed form 00454 if (Solid) 00455 DrawBitmap(Renderer, &LockedBtn, _R(IDB_LGAL_TICKFORCED)); 00456 else 00457 DrawBitmap(Renderer, &LockedBtn, _R(IDB_LGAL_TICKON)); 00458 } 00459 else 00460 { 00461 // If Solid is on then this is superfluous so render the greyed form 00462 if (Solid) 00463 DrawBitmap(Renderer, &LockedBtn, _R(IDB_LGAL_TICKOFFFORCED)); 00464 else 00465 DrawBitmap(Renderer, &LockedBtn, _R(IDB_LGAL_TICKOFF)); 00466 } 00467 00468 Layer* pLayer = GetDisplayedLayer(); 00469 ERROR3IF(pLayer == NULL, "I'm displaying a NULL layer? Serious screwup has occurred!"); 00470 if (pLayer == NULL) 00471 return; 00472 00473 DocColour Foreground = RedrawInfo->Foreground; 00474 DocColour Background = RedrawInfo->Background; 00475 DocColour SelForeground = RedrawInfo->SelForeground; 00476 DocColour SelBackground = RedrawInfo->SelBackground; 00477 00478 // Set up the colours for rendering our text, and fill the background if selected 00479 if (Flags.Selected) 00480 { 00481 // Fill the entire background with the 'selected' colour, so we don't 00482 // get gaps between bits of text or uneven rectangles in multiple selections 00483 Renderer->SetFillColour(SelBackground); 00484 Renderer->DrawRect(&MyRect); 00485 Renderer->SetFixedSystemTextColours(&SelForeground,&SelBackground); 00486 } 00487 else 00488 Renderer->SetFixedSystemTextColours(&Foreground, &Background); 00489 00490 MyRect.lo.x += SG_GapBeforeText; // Leave a small gap before text begins 00491 00492 // And render the text 00493 String_256 MyText = pLayer->GetLayerID(); 00494 00495 // Find the delay value and add it to the end of the layer/frame name 00496 BOOL IsHidden = pLayer->IsHiddenFrame(); 00497 if (!IsHidden) 00498 { 00499 UINT32 FrameDelay = pLayer->GetFrameDelay(); 00500 String_256 Delay; 00501 Delay.MakeMsg(_R(IDS_FRAMEDELAYFORMAT), FrameDelay); 00502 MyText += Delay; 00503 } 00504 else 00505 { 00506 String_256 HiddenText(_R(IDS_SHOWFRAMEISHIDDEN)); // (Hidden) 00507 MyText += HiddenText; 00508 } 00509 00510 #ifdef _DEBUG 00511 // If the layer is edited then add a star onto it 00512 if (pLayer->IsEdited()) 00513 MyText += " *"; // DEBUG only so ok 00514 #endif 00515 00516 Renderer->DrawFixedSystemText(&MyText, MyRect); 00517 00518 StopRendering(RedrawInfo, MiscInfo); 00519 }
|
|
This moves the given layer either before or after this layer, in an undoable way.
Reimplemented from SGDisplayLayer. Definition at line 933 of file sgframe.cpp. 00934 { 00935 ERROR3IF(!IS_A(NodeToMove,SGDisplayFrame),"The node to move is not a SGDisplayFrame"); 00936 if(!IS_A(NodeToMove,SGDisplayFrame)) 00937 return; 00938 00939 Layer* pLayerToMove = ((SGDisplayFrame*)NodeToMove)->GetDisplayedLayer(); 00940 Layer* pThisLayer = GetDisplayedLayer(); 00941 00942 Spread* pSpread = pLayerToMove->FindParentSpread(); 00943 ERROR3IF(pSpread == NULL,"Parent spread is NULL"); 00944 if (pSpread == NULL) 00945 return; 00946 00947 OpLayerGalReason Reason; 00948 00949 if (pLayerToMove == pThisLayer) 00950 { 00951 // if the context node and the layer to move are the same, and we don't have to toggle 00952 // the background flag, just return (give errors in debug mode) 00953 ERROR3IF(!ToggleBackground,"Not moving the layer OR toggling the background flag, so why did you call?"); 00954 if (!ToggleBackground) 00955 return; 00956 00957 Reason = LAYER_TOGGLEBACKGROUND; 00958 } 00959 else 00960 Reason = FRAME_MOVE; 00961 00962 00963 OpLayerGalParam Param(Reason,pSpread); 00964 00965 Param.pLayer = pLayerToMove; 00966 Param.pContextNode = pThisLayer; 00967 Param.MoveRedraw = TRUE; 00968 Param.ToggleBackground = ToggleBackground; 00969 Param.pLayerSGal = (FrameSGallery*)GetParentGallery(); 00970 00971 if (Before) 00972 Param.AttDir = NEXT; // next means insert-before-this 00973 else 00974 Param.AttDir = PREV; // prev means insert-after-this 00975 00976 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERGALCHANGE); 00977 if (pOpDesc != NULL) 00978 pOpDesc->Invoke((OpParam*)&Param); 00979 else 00980 { 00981 ERROR3("Couldn't find OPTOKEN_LAYERGALCHANGE op descriptor"); 00982 } 00983 }
|
|
|
|
Reimplemented from SGDisplayLayer. |
|
Reimplemented from SGDisplayLayer. |