ColourPickerDragInformation Class Reference

Contains all information about a colour being dragged. More...

#include <dragpick.h>

Inheritance diagram for ColourPickerDragInformation:

DragInformation CCObject SimpleCCObject List of all members.

Public Member Functions

 ColourPickerDragInformation ()
 Constructor.
virtual UINT32 GetCursorID (DragTarget *pDragTarget)
 Set cursor over this target.
virtual BOOL GetStatusLineText (String_256 *TheText, DragTarget *pDragTarget)
 provide status line text for this target
virtual UINT32 GetCursorID (void)
 Determines what cursor to display during a colour drag.
virtual BOOL GetStatusLineText (String_256 *TheText)
 provide status line text for this drag
virtual BOOL OnDrawSolidDrag (wxPoint Origin, wxDC *TheDC)
 allows the drag to draw into a Device Context - DragManager will look after painting the background etc.
virtual INT32 GetDragTransparency ()
 Specifies how transparent a drag should be. A value of 0, will cause a normal solid blit. Any other value (between 0 and 100), will cause a masked blit.
virtual BOOL OnMouseMove (wxPoint p)
 Called on a mouse move. Find the doc colour under point p.

Static Public Member Functions

static BOOL Init ()
 Initialise any Colour Drag stuff. (eg. ini file preferences).

Protected Types

enum  Status { NO_COLOUR, SCREEN_COLOUR, DOC_COLOUR, COLOURBAR_COLOUR }

Protected Member Functions

void InitObject (void)
 Shared code for initialising the object - called by all constructors.

Protected Attributes

DocColour TheColour
Status m_Status
wxScreenDC ScreenDC

Static Protected Attributes

static INT32 DragTransparency = 0

Detailed Description

Contains all information about a colour being dragged.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com> (upgraded by Jason)
Date:
05/05/94 (8/8/96)

Definition at line 123 of file dragpick.h.


Member Enumeration Documentation

enum ColourPickerDragInformation::Status [protected]
 

Enumerator:
NO_COLOUR 
SCREEN_COLOUR 
DOC_COLOUR 
COLOURBAR_COLOUR 

Definition at line 159 of file dragpick.h.

00160     {
00161         NO_COLOUR,
00162         SCREEN_COLOUR,
00163         DOC_COLOUR,
00164         COLOURBAR_COLOUR
00165     };


Constructor & Destructor Documentation

ColourPickerDragInformation::ColourPickerDragInformation  ) 
 

Constructor.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95

Definition at line 186 of file dragpick.cpp.

00187 {
00188     InitObject();
00189 }


Member Function Documentation

UINT32 ColourPickerDragInformation::GetCursorID void   )  [virtual]
 

Determines what cursor to display during a colour drag.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/1/95
Returns:
a cursor ID to set during this drag

Reimplemented from DragInformation.

Definition at line 262 of file dragpick.cpp.

00263 {
00264     switch (m_Status)
00265     {
00266         case DOC_COLOUR:
00267             return _R(IDC_COLOURPICKERCURSORDOC);
00268         case SCREEN_COLOUR:
00269             return _R(IDC_COLOURPICKERCURSOR);
00270         case COLOURBAR_COLOUR:
00271             return _R(IDC_COLOURPICKERCURSORCOLBAR);
00272         default:
00273             break;
00274     }
00275 
00276     return(_R(IDC_COLOURPICKERCURSORNOREAD));
00277 }

UINT32 ColourPickerDragInformation::GetCursorID DragTarget pDragTarget  )  [virtual]
 

Set cursor over this target.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/3/95

Reimplemented from DragInformation.

Definition at line 227 of file dragpick.cpp.

00228 {
00229     return GetCursorID();
00230 }

INT32 ColourPickerDragInformation::GetDragTransparency  )  [virtual]
 

Specifies how transparent a drag should be. A value of 0, will cause a normal solid blit. Any other value (between 0 and 100), will cause a masked blit.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
30/05/2006
Returns:
-
See also:
-

Reimplemented from DragInformation.

Definition at line 443 of file dragpick.cpp.

00444 {
00445     return ColourPickerDragInformation::DragTransparency;
00446 }

BOOL ColourPickerDragInformation::GetStatusLineText String_256 TheText  )  [virtual]
 

provide status line text for this drag

Author:
Alex Bligh <alex@alex.org.uk>
Date:
30/05/2006
Parameters:
TheText - If it returns TRUE, this is filled in with status line text [OUTPUTS]
Returns:
Whether String is valid

Reimplemented from DragInformation.

Definition at line 295 of file dragpick.cpp.

00296 {
00297     ResourceID r;
00298     switch (m_Status)
00299     {
00300         case DOC_COLOUR:
00301             r = _R(IDS_DRAGGINGCOLOURPICKERTOOLDOCRC);
00302             break;
00303         case SCREEN_COLOUR:
00304             r = _R(IDS_DRAGGINGCOLOURPICKERTOOLRS);
00305             break;
00306         case COLOURBAR_COLOUR:
00307             r = _R(IDS_DRAGGINGCOLOURPICKERTOOLCOLOURBARRC);
00308             break;
00309         default:
00310             r = _R(IDS_DRAGGINGCOLOURPICKERTOOLNOREAD);
00311     }
00312 
00313     *TheText=String_256(r);
00314     return TRUE;
00315 }

BOOL ColourPickerDragInformation::GetStatusLineText String_256 TheText,
DragTarget pDragTarget
[virtual]
 

provide status line text for this target

Author:
Alex Bligh <alex@alex.org.uk>
Date:
30/05/2006
Returns:
Whether String is valid

Reimplemented from DragInformation.

Definition at line 245 of file dragpick.cpp.

00246 {
00247     return GetStatusLineText(TheText);
00248 }

BOOL ColourPickerDragInformation::Init void   )  [static]
 

Initialise any Colour Drag stuff. (eg. ini file preferences).

Author:
Alex Bligh <alex@alex.org.uk>
Date:
30/05/2006
Returns:
-
See also:
-

Reimplemented from SimpleCCObject.

Definition at line 204 of file dragpick.cpp.

00205 {
00206     // Setup preference for drag transparency
00207     if (GetApplication()->DeclareSection(_T("Dragging"), 1))
00208         GetApplication()->DeclarePref( NULL, _T("ColourPickerDragTransparency"), &DragTransparency, 0, 100);
00209 
00210     return TRUE;
00211 }

void ColourPickerDragInformation::InitObject void   )  [protected]
 

Shared code for initialising the object - called by all constructors.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
30/05/2006

Definition at line 155 of file dragpick.cpp.

00156 {
00157     // Init member variables
00158     TheColour = DocColour(COLOUR_TRANS);
00159     m_Status=NO_COLOUR;
00160 
00161     // Set up a few things about this drag
00162     DoesSolidDrag = TRUE;
00163     
00164     // offset of colour swatch from the pointer
00165     SolidDragOffset.x = 14;
00166     SolidDragOffset.y = 4;     
00167     
00168     // size of the solid drag redraw
00169     SolidDragSize.x = CellSize;
00170     SolidDragSize.y = CellSize;
00171 }

BOOL ColourPickerDragInformation::OnDrawSolidDrag wxPoint  Origin,
wxDC *  TheDC
[virtual]
 

allows the drag to draw into a Device Context - DragManager will look after painting the background etc.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
30/05/2006
Parameters:
TheDC - pointer to a DC ready to draw into. [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from DragInformation.

Definition at line 336 of file dragpick.cpp.

00337 {
00338     if (m_Status == NO_COLOUR)
00339         return FALSE;   
00340 
00341     // set up gbrush
00342 //  CPalette * OldPal = NULL;
00343 //  if (PaletteManager::UsePalette())
00344 //  {
00345 //      OldPal = PaletteManager::StartPaintPalette( TheDC );
00346 //  }
00347 
00348     GBrush GDrawBrush;
00349     GDrawBrush.Init(TheDC);
00350     GDrawBrush.Start();
00351 
00352     // get a gbrush brush
00353     Document *ScopeDoc = Document::GetSelected();
00354     ERROR2IF(ScopeDoc == NULL, FALSE, "No Selected Doc !");
00355 
00356     wxBrush* pDragBrush = new wxBrush;
00357     
00358     BOOL BrushCreate = TRUE;
00359 
00360     if (pDragBrush != NULL )
00361     {
00362         if (TheColour.IsTransparent())
00363         {
00364 //          TheDC->SetBkColor(RGB(255,255,255));        // ensure white background
00365             pDragBrush->SetStyle(wxCROSSDIAG_HATCH);
00366             pDragBrush->SetColour(wxColour(0,0,0));     // Fill with black/white cross hatch
00367         }
00368         else
00369         {
00370             DWORD ScreenWord;
00371 
00372             ColourContextRGBT *CCrgbt = (ColourContextRGBT *)
00373                         ColourManager::GetColourContext(COLOURMODEL_RGBT, DocView::GetSelected());
00374             ScreenWord = ConvertColourToScreenWord(CCrgbt, &TheColour);
00375 
00376             // create the Brush and Pen
00377             if (GDrawBrush.Available())
00378             {
00379                 GDrawBrush.GetLogBrush((COLORREF)ScreenWord, pDragBrush);
00380             }
00381             else
00382                 pDragBrush->SetColour((COLORREF)ScreenWord);
00383         }
00384 
00385         wxPen MyPen(wxColour(0,0,0));
00386 
00387         // Set the brush origin so the dither (or Hatch) patterns
00388         // don't move around as you drag.
00389 //      TheDC->SetBrushOrg(Origin.x, Origin.y);
00390         
00391         //the rectangle to draw into
00392         wxRect DrawRect(Origin.x, Origin.y, SolidDragSize.x-1, SolidDragSize.y-1);
00393 
00394         // select brushes and pens ..
00395         TheDC->SetBrush(*pDragBrush);
00396         TheDC->SetPen(MyPen);
00397 
00398         // draw the thingy. In this case, it's a colour patch, circular for a spot colour, else a square
00399 #ifndef WEBSTER // don't distinguish spots in Webster Martin 15/07/97
00400         if (!TheColour.IsTransparent() && TheColour.GetSpotParent() != NULL)
00401             TheDC->DrawEllipse(DrawRect);
00402         else
00403 #endif // WEBSTER
00404             TheDC->DrawRectangle(DrawRect);
00405                                     
00406         // clean up the dc
00407         TheDC->SetBrush(wxNullBrush);
00408         TheDC->SetPen(wxNullPen);
00409 
00410         // delete the objects
00411         delete pDragBrush;
00412     }
00413     else
00414         BrushCreate = FALSE;
00415     
00416     // Finish with GBrush
00417     GDrawBrush.Stop();
00418 //  if (OldPal)
00419 //      PaletteManager::StopPaintPalette(TheDC, OldPal);
00420     
00421     // problems !!!
00422     ERROR2IF(!BrushCreate, FALSE, "Failed to make a solid drag brush!");
00423 
00424     return TRUE;
00425 }

BOOL ColourPickerDragInformation::OnMouseMove wxPoint  p  )  [virtual]
 

Called on a mouse move. Find the doc colour under point p.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
30/05/2006
Returns:
-
See also:
-

Reimplemented from DragInformation.

Definition at line 461 of file dragpick.cpp.

00462 {
00463     Status OldStatus = m_Status;
00464     m_Status = SCREEN_COLOUR;
00465     DocColour col(COLOUR_TRANS);
00466 
00467     CWindowID   WinID=::wxChildWindowFromPoint(p, FALSE, -1);
00468     DocView*    pDocView=NULL;
00469     Spread*     pSpread=NULL;
00470     WinCoord    WndPos(0,0);
00471     DocCoord    DocPos(0,0);
00472 
00473     ColourEditDlg* pColourEditDlg = ColourEditDlg::GetColourEditDlg ();
00474     // Check we can't pick from the colour picker
00475     wxWindow * w = WinID;
00476     while (w)
00477     {
00478         if (pColourEditDlg && (w==pColourEditDlg->WindowID))
00479         {
00480             // No picking colours from the colour editor
00481             m_Status = NO_COLOUR;
00482             break;
00483         }
00484         if (w->IsKindOf(CLASSINFO(CColourBar)))
00485         {
00486             wxPoint cpoint = w->ScreenToClient(p);
00487             if (((CColourBar*) w)->IsColourPickerOverStripRect (w, cpoint))
00488             {
00489                 IndexedColour * pIndexedColour = NULL;
00490                 m_Status = COLOURBAR_COLOUR;
00491                 ((CColourBar*) w)->DoColourPickerColour (w, cpoint, &pIndexedColour);
00492                 if (pIndexedColour)
00493                 {
00494                     // Disassociate from indexed colour
00495                     DocColour Temp;
00496                     Temp.MakeRefToIndexedColour(pIndexedColour);
00497                     INT32 r, g, b;
00498                     Temp.GetRGBValue(&r, &g, &b);
00499                     col = DocColour(r, g, b);
00500                 }
00501                 break;
00502             }
00503         }
00504         w=w->GetParent();
00505     }
00506 
00507     Pixel32bpp Pix;
00508     NodeRenderableInk* pNode = NULL;
00509 
00510     if (m_Status == SCREEN_COLOUR)
00511     {
00512         if (WinID != NULL)
00513             pDocView=CCamView::GetDocViewFromWindowID(WinID);
00514     
00515         if (pDocView != NULL)
00516         {
00517             OilCoord OilPos = WndPos.ToOil(pDocView, TRUE);
00518             pSpread = pDocView->OilToSpreadCoord(OilPos, &DocPos);
00519         }
00520     
00521         if (pDocView)       // were over an active (or inactive document)
00522         {
00523             if (pDocView==DocView::GetSelected())
00524             {
00525                 pNode = NodeRenderableInk::FindSimpleAtPointForColourPicker (pSpread, DocPos, Pix);
00526                 m_Status = DOC_COLOUR;
00527             }
00528             else
00529             {   
00530                 m_Status = SCREEN_COLOUR;
00531             }
00532         }
00533     }
00534 
00535     switch (m_Status)
00536     {
00537         case DOC_COLOUR:
00538         {
00539             const double conversion = 1.0/255.0;
00540                             
00541             FIXED24 rValF24 = Pix.Red * conversion;
00542             FIXED24 gValF24 = Pix.Green * conversion;
00543             FIXED24 bValF24 = Pix.Blue * conversion;
00544             FIXED24 tValF24 = Pix.Alpha * conversion;
00545             
00546             //DocColour* TheColour = new DocColour (rValF24, gValF24, bValF24);
00547             ColourRGBT TheColourRGBT;
00548             TheColourRGBT.Red = rValF24;
00549             TheColourRGBT.Green = gValF24;
00550             TheColourRGBT.Blue = bValF24;
00551             TheColourRGBT.Transparent = tValF24;
00552             col = DOCCOLOUR_RGBT(&TheColourRGBT);//DocColour (rValF24, gValF24, bValF24);
00553         }
00554 
00555         case SCREEN_COLOUR:
00556         {
00557             wxColour c(*wxBLACK);
00558             ScreenDC.GetPixel(p, &c);
00559 
00560             const double conversion = 1.0/255.0;
00561 
00562             FIXED24 rValF24 = c.Red() * conversion;
00563             FIXED24 gValF24 = c.Green() * conversion;
00564             FIXED24 bValF24 = c.Blue() * conversion;
00565 
00566             col=DocColour(rValF24, gValF24, bValF24);
00567         }
00568 
00569         case COLOURBAR_COLOUR:
00570         default:
00571             break;
00572 
00573     }
00574 
00575     if ((OldStatus != m_Status ) || (col !=TheColour))
00576     {
00577         TheColour = col;
00578 
00579         // COLOURBAR_COLOUR has already updated the colour picker
00580         if ((m_Status != NO_COLOUR) && (m_Status != COLOURBAR_COLOUR))
00581         {
00582             IndexedColour* theIndexedColour = ColourManager::GenerateNewUnnamedColour (ColourManager::GetColourList(), &TheColour);
00583     
00584             // Tell the colour edit dlg about the node that this colour came
00585             // from so it can block attribute application if its the same node
00586             if (pColourEditDlg && theIndexedColour)
00587                 pColourEditDlg->SetEditingColour (theIndexedColour, pNode);
00588             //pColourEditDlg->SetEditingColour (theIndexedColour);
00589         }
00590 
00591     }
00592 
00593     return TRUE;
00594 }


Member Data Documentation

INT32 ColourPickerDragInformation::DragTransparency = 0 [static, protected]
 

Definition at line 155 of file dragpick.h.

Status ColourPickerDragInformation::m_Status [protected]
 

Definition at line 167 of file dragpick.h.

wxScreenDC ColourPickerDragInformation::ScreenDC [protected]
 

Definition at line 169 of file dragpick.h.

DocColour ColourPickerDragInformation::TheColour [protected]
 

Definition at line 157 of file dragpick.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:59 2007 for Camelot by  doxygen 1.4.4