bfxdlg.cpp

Go to the documentation of this file.
00001 // $Id: bfxdlg.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // Handles the bitmap effects dialog
00099 
00100 /*
00101 */
00102 
00103 #include "camtypes.h"
00104 //#include "bfxrc.h"
00105 #include "bfxdlg.h"
00106 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "bmplist.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 #include "oilprog.h"
00109 
00110 #include "ccdc.h"       // specific #includes needed for kernel-rendered dialogues
00111 #include "dlgcol.h"
00112 //#include "fillval.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 #include "grnddib.h"
00114 
00115 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 //#include "range.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00117 #include "nodebmp.h"
00118 #include "bitmpinf.h"
00119 //#include "bmplist.h"
00120 #include "bmpcomp.h"
00121 //#include "fillattr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00122 #include "bitmapfx.h"
00123 //#include "undoop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00124 #include "progress.h"
00125 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00126 #include "chapter.h"
00127 #include "page.h"
00128 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00129 //#include "trans2d.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00130 //#include "rikdlg.h"
00131 //#include "resource.h"
00132 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00133 //#include "barsdlgs.h"         // for the bitmap effects bar control
00134 #include "wrkrect.h"
00135 #include "bubbleid.h"
00136 
00137 //#include "will2.h"
00138 
00139 // This is not compulsory, but you may as well put it in so that the correct version
00140 // of your file can be registered in the .exe
00141 DECLARE_SOURCE("$Revision: 1282 $");
00142 
00143 // An implement to match the Declare in the .h file.
00144 // If you have many classes, it is recommended to place them all together, here at the start of the file
00145 CC_IMPLEMENT_DYNAMIC(BfxMsg, Msg)
00146 CC_IMPLEMENT_DYNCREATE(BfxDlg, DialogTabOp)
00147 CC_IMPLEMENT_DYNCREATE(BfxOp, UndoableOperation)   
00148 CC_IMPLEMENT_MEMDUMP(BfxOpParam, OpParam)
00149 
00150 // This will get Camelot to display the filename and linenumber of any memory allocations
00151 // that are not released at program exit
00152 #define new CAM_DEBUG_NEW
00153 
00154 const CDlgMode BfxDlg::Mode = MODELESS; // Mode of the dialog  
00155 const UINT32 BfxDlg::IDD = _R(IDD_BFXDLG); // Used to uniquely identify the tabbed dialog
00156                                                  // there is no actual resource associated with this ID.
00157 BOOL BfxDlg::InteractiveBCC = TRUE;
00158 
00159 /********************************************************************************************
00160 >   BfxDlg::BfxDlg(): DialogTabOp(BfxDlg::IDD, BfxDlg::Mode) 
00161                      
00162 
00163     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00164     Created:    20/02/95
00165     Purpose:    The Constructor of the DialogTabOp derived class simply sets modality of the
00166                 dialog, and it's ID.
00167 
00168 ********************************************************************************************/
00169 
00170 
00171 
00172 BfxDlg::BfxDlg(): DialogTabOp(BfxDlg::IDD, BfxDlg::Mode) 
00173 {
00174     OpenPage = 0;
00175     pOriginal = NULL;
00176     pDestination = NULL;
00177     pPrevOriginal=NULL;
00178     pOrigInfo = NULL;
00179     Clean = FALSE;
00180     pFX = NULL;
00181     SetParameters();
00182     for (INT32 i = 0; i<=8; i++) Matrix[i]=(i==4)?1.0:0.0;
00183 }        
00184 
00185 /********************************************************************************************
00186 >   BfxDlg::~BfxDlg()
00187                      
00188 
00189     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00190     Created:    20/02/95
00191     Purpose:    Destructor
00192 
00193 ********************************************************************************************/
00194 
00195 BfxDlg::~BfxDlg()
00196 {
00197     if (pFX) delete pFX;
00198     if (pDestination) {TRACEUSER( "Alex", _T("Destructor deleting destination\n"));delete pDestination;}
00199     if (pOrigInfo) delete pOrigInfo;
00200 }        
00201 
00202 /*******************************************************************************************
00203 
00204 >   BOOL BfxDlg::OriginalChanged()
00205 
00206     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00207     Created:    14/12/94
00208     Inputs:     None
00209     Outputs:    None
00210     Returns:    TRUE if succeeded, FALSE & error set if not
00211     Purpose:    Invalidates area for original bitmap, marks no destination as yet
00212     Errors:     None at present
00213     SeeAlso:    -
00214 
00215 *******************************************************************************************/
00216 
00217 BOOL BfxDlg::OriginalChanged()
00218 {
00219     if (pPrevOriginal==pOriginal) return TRUE;
00220     pPrevOriginal=pOriginal;
00221 
00222     if (!pOrigInfo)
00223     {
00224         pOrigInfo = new BitmapInfo;
00225         if (!pOrigInfo) return FALSE; // error already set.
00226     }
00227 
00228     pOrigInfo->PixelWidth = 100;
00229     pOrigInfo->PixelHeight = 100;
00230     pOrigInfo->PixelDepth = 24;
00231     if (pOriginal && pOrigInfo) // Should always be true
00232     {
00233         pOriginal->ActualBitmap->GetInfo(pOrigInfo);
00234     }
00235 
00236     if (SetDirty() && (OpenPage != 0))
00237     {
00238         InvalidateGadget(_R(IDC_BFXDLG_ORIGREDRAW));
00239     }
00240 
00241     BROADCAST_TO_CLASS(DialogMsg(WindowID, DIM_OUT_OF_SPACE, _R(IDC_BFXDLG_ORIGREDRAW),
00242                        0, OpenPage) ,DialogOp);  // Pretty horrible bodge
00243 
00244     return FixOriginalComboBox();
00245 }
00246 
00247 /*******************************************************************************************
00248 
00249 >   BOOL BfxDlg::SetEffect(CCRuntimeClass * Effect)
00250 
00251     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00252     Created:    14/12/94
00253     Inputs:     Effect = runtime class of effect to be used, or none.
00254     Outputs:    None
00255     Returns:    TRUE if succeeded, FALSE & error set if not
00256     Purpose:    Choses the bitmap effect for processing
00257     Errors:     None at present
00258     SeeAlso:    -
00259 
00260 *******************************************************************************************/
00261 
00262 BOOL BfxDlg::SetEffect(CCRuntimeClass * Effect)
00263 {
00264     if (pFX)
00265     {
00266         if (pFX->GetRuntimeClass() == Effect) return TRUE;
00267         delete pFX;
00268         pFX = NULL;
00269     }
00270     if (Effect)
00271     {
00272         pFX = (AccusoftBitmapEffect *) (Effect->CreateObject());
00273         if (!pFX) return FALSE;
00274         return pFX->SetParameters(Param1, Param2, Param3, Matrix);
00275     }
00276     else return TRUE;
00277 }
00278 
00279 /*******************************************************************************************
00280 
00281 >   BOOL BfxDlg::SetDirty(BOOL Redraw=TRUE)
00282 
00283     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00284     Created:    14/12/94
00285     Inputs:     None
00286     Outputs:    None
00287     Returns:    TRUE if succeeded, FALSE & error set if not
00288     Purpose:    Clears the clean flag and deletes the effect
00289     Errors:     None at present
00290     SeeAlso:    -
00291 
00292 *******************************************************************************************/
00293 
00294 BOOL BfxDlg::SetDirty(BOOL Redraw)
00295 {
00296     if (!ClearDestination(Redraw)) return FALSE;
00297     Clean = FALSE;
00298     if (pFX)
00299     {
00300         delete pFX;
00301         pFX = NULL;
00302     }
00303     return TRUE;
00304 }
00305 
00306 /*******************************************************************************************
00307 
00308 >   BOOL BfxDlg::DestinationChanged()
00309 
00310     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00311     Created:    14/12/94
00312     Inputs:     None
00313     Outputs:    None
00314     Returns:    TRUE if succeeded, FALSE & error set if not
00315     Purpose:    Invalidates area for destination bitmap, marks no destination as yet
00316     Errors:     None at present
00317     SeeAlso:    -
00318 
00319 *******************************************************************************************/
00320 
00321 BOOL BfxDlg::DestinationChanged()
00322 {
00323     if (OpenPage)
00324     {
00325         InvalidateGadget(_R(IDC_BFXDLG_ORIGREDRAW2));
00326     }
00327     return TRUE;
00328 }
00329 
00330 /*******************************************************************************************
00331 
00332 >   BOOL BfxDlg::ClearDestination(BOOL Redraw=TRUE)
00333 
00334     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00335     Created:    14/12/94
00336     Inputs:     None
00337     Outputs:    None
00338     Returns:    TRUE if succeeded, FALSE & error set if not
00339     Purpose:    Marks no dest bitmap
00340     Errors:     None at present
00341     SeeAlso:    -
00342 
00343 *******************************************************************************************/
00344 
00345 BOOL BfxDlg::ClearDestination(BOOL Redraw)
00346 {
00347     if (pDestination)
00348     {
00349         delete pDestination;
00350         pDestination = NULL; //TRACEUSER( "Alex", _T("ClearDestination deleting dest\n"));
00351         return ((!Redraw) || (DestinationChanged()));
00352     }
00353     return TRUE;
00354 }
00355 
00356 /*******************************************************************************************
00357 
00358 >   BOOL BfxDlg::FindBitmap()
00359 
00360     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00361     Created:    14/12/94
00362     Inputs:     None
00363     Outputs:    pOriginal set
00364     Returns:    TRUE if succeeded, FALSE & error set if not
00365     Purpose:    Set pOriginal to point at a bitmap
00366     Errors:     None at present
00367     SeeAlso:    -
00368 
00369 *******************************************************************************************/
00370 
00371 BOOL BfxDlg::FindBitmap()
00372 {
00373 //  pOriginal = NULL;
00374 
00375     Range Sel(*(GetApplication()->FindSelection()));
00376 
00377     Node* FirstSelectedNode = Sel.FindFirst(); 
00378     if (FirstSelectedNode != NULL) // No nodes selected so End
00379     {
00380         Node* CurrentNode = FirstSelectedNode;       
00381         Node* NextCurrent; 
00382         
00383         // Do all bitmaps. OK this should pick up the fill as well. Never mind
00384         while (CurrentNode != NULL)
00385         {
00386             NextCurrent = Sel.FindNext(CurrentNode);
00387             if  ( (CurrentNode->IsSelected()) && (CurrentNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodeBitmap)) ) 
00388             {         
00389                 pOriginal = ((NodeBitmap *)(CurrentNode))->GetBitmap();
00390                 return CheckOriginalBitmap();
00391             }
00392             CurrentNode = NextCurrent; 
00393         }
00394 
00395     } 
00396 
00397     // Find the first Fill Attribute in the selection
00398     AttrFillGeometry* pAttrNode = AttrFillGeometry::FindFirstSelectedAttr();
00399 
00400     while (pAttrNode != NULL)
00401     {
00402         if (pAttrNode->IsKindOf(CC_RUNTIME_CLASS(AttrBitmapColourFill)))
00403         {
00404             pOriginal = pAttrNode->GetBitmap();
00405             return CheckOriginalBitmap();
00406         }
00407 
00408         // Check the next fill
00409         pAttrNode = AttrFillGeometry::FindNextSelectedAttr();
00410     }
00411 
00412     return CheckOriginalBitmap();
00413 }
00414 
00415 /*******************************************************************************************
00416 
00417 >   BOOL BfxDlg::CheckOriginalBitmap()
00418 
00419     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00420     Created:    14/12/94
00421     Inputs:     None
00422     Outputs:    pOriginal set
00423     Returns:    TRUE if succeeded, FALSE & error set if not
00424     Purpose:    Ensures pOriginal points to a valid bitmap in this document
00425     Errors:     None at present
00426     SeeAlso:    -
00427 
00428 
00429 *******************************************************************************************/
00430 
00431 BOOL BfxDlg::CheckOriginalBitmap()
00432 {
00433     Document * pDoc = Document::GetSelected();
00434 
00435     // Get the bitmap list
00436     BitmapList* Bitmaps = NULL;
00437     if (pDoc) Bitmaps = pDoc->GetBitmapList();
00438 
00439     if (Bitmaps == NULL)
00440     {
00441         pOriginal = NULL;
00442         return OriginalChanged();
00443     }
00444 
00445     KernelBitmap * pBmp = (KernelBitmap *)(Bitmaps->GetHead());
00446 
00447     while (pBmp != NULL)
00448     {
00449         if (pBmp == pOriginal) return OriginalChanged(); // OK we've found it.
00450         pBmp = (KernelBitmap *) Bitmaps->GetNext(pBmp);
00451     }
00452 
00453     pOriginal = (KernelBitmap *)(Bitmaps->GetHead()); // possibly NULL but certainly on the list
00454     return OriginalChanged();
00455 }
00456 
00457 /*******************************************************************************************
00458 
00459 >   BOOL BfxDlg::FixOriginalComboBox()
00460 
00461     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00462     Created:    14/12/94
00463     Inputs:     None
00464     Outputs:    None
00465     Returns:    TRUE if succeeded, FALSE & error set if not
00466     Purpose:    Makes the combo box reflect the bitmaps within the document
00467     Errors:     None at present
00468     SeeAlso:    -
00469 
00470 This routine is heavilly copied from one within the fill tool
00471 
00472 *******************************************************************************************/
00473 
00474 BOOL BfxDlg::FixOriginalComboBox()
00475 {
00476     // Find the doccomponent with the list of bitmaps in it
00477     Document * pDoc = Document::GetSelected();
00478 
00479     // Get the bitmap list
00480     BitmapList* Bitmaps = NULL;
00481     if (pDoc) Bitmaps = pDoc->GetBitmapList();
00482 
00483     if (Bitmaps == NULL)
00484         return TRUE;
00485 
00486     String_256 Str;
00487 
00488     if (OpenPage)
00489     {
00490         DeleteAllValues(_R(IDC_BFXDLG_ORIGCOMBO));
00491     }
00492 
00493     BOOL DoneMain = FALSE;
00494     INT32 SelIndex = 0;
00495 
00496     if (Bitmaps->GetCount() > 0)
00497     {
00498         INT32 Index = 0;
00499 
00500         ListItem* pBmp = Bitmaps->GetHead();
00501 
00502         while (pBmp != NULL)
00503         {
00504             Str = ((KernelBitmap*)pBmp)->ActualBitmap->GetName();
00505             if (OpenPage)
00506             {
00507                 if (((KernelBitmap*)(pBmp)) == pOriginal)
00508                 {
00509                     SetStringGadgetValue(_R(IDC_BFXDLG_ORIGCOMBO),&Str, FALSE, -1);
00510                     DoneMain = TRUE;
00511                     SelIndex=Index;
00512                 }
00513                 SetStringGadgetValue(_R(IDC_BFXDLG_ORIGCOMBO),&Str,FALSE, Index++);
00514             }
00515             pBmp = Bitmaps->GetNext(pBmp);
00516         }
00517     }
00518     else
00519     {
00520         Str.Load(_R(IDS_K_BFXDLG_DEFAULT));
00521         if (OpenPage) SetStringGadgetValue(_R(IDC_BFXDLG_ORIGCOMBO),&Str,TRUE, 0);
00522     }
00523 
00524     if (OpenPage)
00525     {
00526         Str.Load(_R(IDS_K_BFXDLG_DEFAULT));
00527         SetComboListLength(_R(IDC_BFXDLG_ORIGCOMBO));
00528         if (!DoneMain)
00529         {
00530             SetStringGadgetValue(_R(IDC_BFXDLG_ORIGCOMBO),&Str, FALSE, -1);
00531             SetSelectedValueIndex(_R(IDC_BFXDLG_ORIGCOMBO), 0);
00532         }
00533         else
00534         {
00535             SetSelectedValueIndex(_R(IDC_BFXDLG_ORIGCOMBO), SelIndex);
00536         }
00537     }
00538     return TRUE;
00539 }
00540 
00541 
00542 /*******************************************************************************************
00543 
00544 >   BOOL BfxDlg::ReadOriginalComboBox()
00545 
00546     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00547     Created:    14/12/94
00548     Inputs:     None
00549     Outputs:    None
00550     Returns:    TRUE if succeeded, FALSE & error set if not
00551     Purpose:    Chooses a different bitmap from the combo box
00552     Errors:     None at present
00553     SeeAlso:    -
00554 
00555 This routine is heavilly copied from one within the fill tool
00556 
00557 *******************************************************************************************/
00558 
00559 BOOL BfxDlg::ReadOriginalComboBox()
00560 {
00561     if (!OpenPage) return FALSE;
00562 
00563     Document * pDoc = Document::GetSelected();
00564 
00565     // Get the bitmap list
00566     BitmapList* Bitmaps = NULL;
00567     if (pDoc) Bitmaps = pDoc->GetBitmapList();
00568 
00569     if (Bitmaps == NULL)
00570         return TRUE;
00571 
00572     ListItem* pBmp = Bitmaps->GetHead();
00573 
00574     WORD Index;
00575     GetValueIndex(_R(IDC_BFXDLG_ORIGCOMBO),&Index); 
00576 
00577     for (INT32 i = 0; i < Index; i++)
00578     {
00579         if (pBmp == NULL)
00580             break;
00581 
00582         pBmp = Bitmaps->GetNext(pBmp);
00583     }
00584 
00585     pOriginal = (KernelBitmap*)pBmp; // Might be NULL (conceivably)
00586     return CheckOriginalBitmap();
00587 }
00588 
00589 /********************************************************************************************
00590 
00591 >   BOOL BfxDlg::RenderBitmap(ReDrawInfoType* ExtraInfo, KernelBitmap * BitmapToUse)
00592 
00593     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00594     Created:    20/02/95
00595     Inputs:     ExtraInfo - The structure that has the extra data we need to start rendering
00596                 BitmapToUse - The bitmap to render
00597     Outputs:    None
00598     Returns:    TRUE if succeeded, FALSE & error set if not
00599     Purpose:    Fills a renderable control with a bitmap
00600     Errors:     None at present
00601     SeeAlso:    -
00602 
00603 ********************************************************************************************/
00604 
00605 BOOL BfxDlg::RenderBitmap(ReDrawInfoType* ExtraInfo, KernelBitmap * BitmapToUse)
00606 {
00607     // Go get a render region
00608     DocRect VirtualSize(0, 0, ExtraInfo->dx, ExtraInfo->dy);
00609     RenderRegion* pRender = CreateGRenderRegion(&VirtualSize, ExtraInfo);
00610     if (pRender!=NULL)
00611     {
00612         DialogColourInfo RedrawColours;     // Get a supplier for default dlg colours
00613 
00614         // A Grey colour [...hmmm, it's not a very grey grey any more... oragnge more like]
00615         DocColour Grey(255,200,0);
00616 
00617         // Render the attributes and the a rectangle
00618         pRender->SaveContext();
00619         pRender->SetLineColour(COLOUR_TRANS);
00620 
00621             // Draw a rectangle to fill in the background - Fill with Dialogue Background colour
00622         pRender->SetFillColour(RedrawColours.DialogBack());
00623         pRender->DrawRect(&VirtualSize);
00624     
00625         if (BitmapToUse)
00626         {
00627 
00628             NodeBitmap NB;
00629             NodeBitmap * pNodeBitmap = &NB;
00630         
00631             if (!((pNodeBitmap == NULL) || (!pNodeBitmap->SetUpPath(12,12))))
00632             {
00633                 // Get a new bitmap object for this node.
00634                 pNodeBitmap->GetBitmapRef()->SetBitmap(BitmapToUse);
00635                         
00636                 ENSURE(pNodeBitmap->GetBitmap()->ActualBitmap != NULL, "No bitmap object found!");
00637         
00638                 DocRect BitmapSize(VirtualSize);
00639                 BitmapInfo BMInfo;
00640                 BitmapToUse->ActualBitmap->GetInfo(&BMInfo);
00641                 if (BMInfo.PixelWidth==0) BMInfo.PixelWidth=1;
00642                 if (BMInfo.PixelHeight==0) BMInfo.PixelHeight=1;
00643 
00644                 double BMAspect = ((double)(BMInfo.PixelWidth))/((double)(BMInfo.PixelHeight));
00645                 double RedrawAspect = ((double)(ExtraInfo->dx))/((double)(ExtraInfo->dy));
00646 
00647                 if (BMAspect>RedrawAspect)
00648                 {
00649                     // grey at top and bottom
00650                     INT32 NewHeight = (INT32)( 0.5 + ((double)(VirtualSize.Width()))/BMAspect);
00651                     if (NewHeight<1) NewHeight = 1;
00652                     BitmapSize.loy = (VirtualSize.Height()-NewHeight)/2;
00653                     BitmapSize.hiy = BitmapSize.loy + NewHeight;
00654                 }
00655                 else
00656                 {
00657                     // grey on left and right
00658                     INT32 NewWidth = (INT32)( 0.5 + ((double)(VirtualSize.Height()))*BMAspect);
00659                     if (NewWidth<1) NewWidth = 1;
00660                     BitmapSize.lox = (VirtualSize.Width()-NewWidth)/2;
00661                     BitmapSize.hix = BitmapSize.lox + NewWidth;
00662                 }
00663 
00664                 // And set this in our bitmap node
00665                 pNodeBitmap->CreateShape(BitmapSize);
00666                     
00667                 pNodeBitmap->Render(pRender);
00668             }
00669         }
00670 
00671         pRender->RestoreContext();
00672 
00673         // Get rid of the render region
00674         DestroyGRenderRegion(pRender);
00675     }
00676     return TRUE;
00677 }
00678 
00679 /********************************************************************************************
00680 >   MsgResult BfxDlg::Message( Msg* Message)
00681 
00682     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00683     Created:    20/02/95
00684     Inputs:     Message: The message 
00685 
00686     
00687     Returns:    OK            Message handled ok (return this even if you don't need to 
00688                               respond to the message). 
00689 
00690                 FAIL          Something terrible happened whilst processing the message
00691                               eg. we ran out of memory. You must set ERROR if you
00692                               are returning this value. 
00693 
00694                 EAT_MSG       The Message was handled ok but don't send it to any
00695                               more MessageHandlers. 
00696 
00697     Purpose:    This is the message handler for the BfxDlg
00698      
00699 ********************************************************************************************/
00700 
00701 
00702 MsgResult BfxDlg::Message( Msg* Message)
00703 {
00704     if (IS_OUR_DIALOG_MSG(Message))
00705     {
00706         DialogMsg* Msg = ((DialogMsg*) Message); 
00707         
00708         BOOL EndDialog = FALSE;     // TRUE if we should quit the dialog
00709         BOOL CommitValues = FALSE;  // TRUE if we should commit the dialog values
00710 
00711         CDlgResID ThePage = Msg->PageID;
00712 
00713         if (ThePage == 0) switch (Msg->DlgMsg)
00714         {
00715             case DIM_CREATE:
00716                 OpenPage=0;
00717                 pOriginal=NULL;
00718                 TalkToPage(0);
00719                 FindBitmap();
00720                 FixOriginalComboBox();
00721                 SetDirty();
00722                 break;
00723             
00724             case DIM_COMMIT:        // Want to commit and quit
00725                 EndDialog = TRUE;
00726                 CommitValues = TRUE; 
00727                 ThePage = OpenPage;
00728                 break;
00729 
00730             case DIM_SOFT_COMMIT:   // Want to commit
00731                 CommitValues = TRUE; 
00732                 ThePage = OpenPage;
00733                 break; 
00734 
00735             case DIM_CANCEL:        // Want to quit
00736                 ThePage = OpenPage;
00737                 EndDialog = TRUE;
00738                 break;
00739 
00740         }
00741 
00742         // These are common to all pages, and get passed on to the pages themselves
00743         switch (Msg->DlgMsg)
00744         {
00745             case DIM_SET_ACTIVE:
00746                 OpenPage = Msg->PageID;
00747                 TalkToPage(Msg->PageID);
00748                 CheckOriginalBitmap();
00749                 FixOriginalComboBox();
00750                 SetDirty();
00751                 break;
00752 
00753             case DIM_REDRAW :
00754                 // This is where all the redrawing is done
00755                 // Which control in the window is sending the redraw message (if there are many
00756                 // grdraw controls you can tell which is which from the Gadget ID
00757                 TalkToPage(Msg->PageID);
00758                 switch (Msg->GadgetID)
00759                 {
00760                     // Draw the redraw_me control in here
00761                     case _R(IDC_BFXDLG_ORIGREDRAW) :
00762                     {
00763                         RenderBitmap((ReDrawInfoType*) Msg->DlgMsgParam, pOriginal);
00764                         break;
00765                     }
00766                     case _R(IDC_BFXDLG_ORIGREDRAW2) :
00767                     {
00768                         RenderBitmap((ReDrawInfoType*) Msg->DlgMsgParam, pDestination);
00769                         break;
00770                     }
00771                 }
00772                 break;
00773             
00774             case DIM_SELECTION_CHANGED:
00775                 TalkToPage(Msg->PageID);
00776                 switch (Msg->GadgetID)
00777                 {
00778                     // Draw the redraw_me control in here
00779                     case _R(IDC_BFXDLG_ORIGCOMBO) :
00780                     {
00781                         ReadOriginalComboBox();
00782                         break;
00783                     }
00784                 }
00785                 break;                                                 
00786 
00787         }
00788 
00789         // Determine from what page the message originated
00790         if (ThePage) switch (ThePage)
00791         {
00792             case _R(IDD_BFXDLG_PG1):
00793                 HandleFlipAndRotateMsg(Msg, &CommitValues, &EndDialog); 
00794                 break;
00795             case _R(IDD_BFXDLG_PG2):
00796                 HandleResizeMsg(Msg, &CommitValues, &EndDialog); 
00797                 break;
00798             case _R(IDD_BFXDLG_PG3):
00799                 HandleBrightnessAndContrastMsg(Msg, &CommitValues, &EndDialog); 
00800                 break;
00801             case _R(IDD_BFXDLG_PG4):
00802                 HandleDitherMsg(Msg, &CommitValues, &EndDialog); 
00803                 break;
00804             case _R(IDD_BFXDLG_PG5):
00805                 HandleSpecialEffectsMsg(Msg, &CommitValues, &EndDialog); 
00806                 break;
00807             case _R(IDD_BFXDLG_PG6):
00808                 HandleAlchemistMsg(Msg, &CommitValues, &EndDialog); 
00809                 break;
00810             default:
00811                 ERROR3("Message from unknown tab dialog page"); 
00812         }
00813 
00814         // Commit values here
00815         if (CommitValues)
00816         {
00817             if (pOriginal)
00818             {
00819                 if (pFX)
00820                 {
00821                     if (!Clean)
00822                     {
00823                         ClearDestination();
00824                         String_64 ProcessMessage(_R(IDS_BFXDLG_PROCESSING));
00825                         // Bodge to avoid progress bar on interactive B&C
00826                         if (Msg->DlgMsg==DIM_COMMIT || Msg->DlgMsg==DIM_SOFT_COMMIT)
00827                         {
00828                             BeginSlowJob(100, FALSE, &ProcessMessage);
00829                             ContinueSlowJob();
00830                         }
00831                         pFX->SetParameters(Param1, Param2, Param3, Matrix);
00832                         pDestination = pFX->GetProcessedBitmap(pOriginal);
00833                         if (Msg->DlgMsg==DIM_COMMIT || Msg->DlgMsg==DIM_SOFT_COMMIT)
00834                         {
00835                             ContinueSlowJob(99);
00836                             EndSlowJob();
00837                         }
00838                         if (!pDestination) InformError(); else
00839                         {
00840                             DestinationChanged();
00841                             Clean=TRUE;
00842                         }
00843                     }
00844                 }
00845                 else
00846                 {
00847                     TRACEUSER( "Alex", _T("Wierd - he didn't actually ask for an effect..."));
00848                 }
00849             }
00850         }
00851 
00852         // End dialog here
00853         if (EndDialog)  // Dialog communication over 
00854         {   
00855             if (pOriginal && CommitValues)
00856             {
00857                 OpenPage = 0;
00858                 TalkToPage(0);
00859 
00860                 BfxOpParam param;
00861                 param.ppBitmap = &pDestination;
00862             
00863                 OpDescriptor* pOpDesc=OpDescriptor::FindOpDescriptor("BfxOp");
00864                 ERROR3IF_PF(pOpDesc==NULL,("Couldn't find OPTOKEN_OPBFXOP op descriptor"));
00865                 pOpDesc->Invoke((OpParam*)&param);
00866                 // NULLs destination on success
00867             }
00868 
00869             ClearDestination();
00870 
00871             Close();           
00872 //          TRACEUSER( "Alex", _T("Calling End()\n"));
00873             End();      // End of dialog 
00874         }
00875         //return (DLG_EAT_IF_HUNGRY(Msg));   // I return EAT_MSG unless the message needs to be sent to all dialogs 
00876     } else if (MESSAGE_IS_A(Message, SelChangingMsg))       // Selection changed - use new bitmap
00877     {
00878         if (OpenPage) TalkToPage(OpenPage);
00879         SelChangingMsg *Msg = (SelChangingMsg *) Message;
00880         switch ( Msg->State )
00881         {
00882             case SelChangingMsg::SelectionState::SELECTIONCHANGED:
00883             case SelChangingMsg::SelectionState::NODECHANGED:
00884 //              pOriginal=NULL;
00885                 FindBitmap();
00886                 break;
00887         }
00888     } else if (MESSAGE_IS_A(Message, BitmapListChangedMsg))     // Selection changed - use new bitmap
00889     {
00890         if (OpenPage) TalkToPage(OpenPage);
00891         CheckOriginalBitmap();
00892         FixOriginalComboBox();
00893     } else if (MESSAGE_IS_A(Message, BfxMsg))
00894     {
00895         if (OpenPage) TalkToPage(OpenPage);
00896         pOriginal=((BfxMsg*)(Message))->pBitmap;
00897         CheckOriginalBitmap();
00898     }
00899 
00900     return DialogTabOp::Message(Message);
00901 } 
00902 
00903 
00904 // -----------------------------------------------------------------------------------------
00905 // Message handlers for individual pages
00906 
00907 /********************************************************************************************
00908 
00909 >   void BfxDlg::HandleFlipAndRotateMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
00910 
00911     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00912     Created:    20/02/95
00913     Inputs:     Msg: The message sent from page 1 of the dialog
00914     Outputs:    -
00915     Returns:    -
00916     Purpose:    All messages generated from the tabbed dialog's page 1 get processed here
00917     Errors:     -
00918     Scope:      private
00919     SeeAlso:    BfxDlg::Message
00920 
00921 ********************************************************************************************/
00922 
00923 
00924 void BfxDlg::HandleFlipAndRotateMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
00925 {
00926     TalkToPage(_R(IDD_BFXDLG_PG1));  // The Coords Page identifier
00927     switch(Msg->DlgMsg)
00928     {
00929         case DIM_CREATE:
00930             SetLongGadgetValue(_R(IDC_BFXDLG_FLIPX), TRUE); 
00931             SetLongGadgetValue(_R(IDC_BFXDLG_FLIPY), FALSE); 
00932             SetLongGadgetValue(_R(IDC_BFXDLG_ROTATE90), FALSE); 
00933             SetLongGadgetValue(_R(IDC_BFXDLG_ROTATE180), FALSE); 
00934             SetLongGadgetValue(_R(IDC_BFXDLG_ROTATE270), FALSE); 
00935             break;
00936 
00937         case DIM_LFT_BN_CLICKED:
00938         case DIM_SELECTION_CHANGED:
00939             {
00940                 switch (Msg->GadgetID)
00941                 {
00942                     case _R(IDC_BFXDLG_FLIPX):
00943                     case _R(IDC_BFXDLG_FLIPY):
00944                     case _R(IDC_BFXDLG_ROTATE90):
00945                     case _R(IDC_BFXDLG_ROTATE180):
00946                     case _R(IDC_BFXDLG_ROTATE270):
00947                         SetDirty();
00948                         break;
00949                     default:
00950                         break;
00951                 }
00952             }
00953             break;
00954 
00955         case DIM_COMMIT:
00956         case DIM_SOFT_COMMIT:
00957             {
00958                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_FLIPX))) SetEffect(CC_RUNTIME_CLASS(ABFXFlipX));
00959                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_FLIPY))) SetEffect(CC_RUNTIME_CLASS(ABFXFlipY));
00960                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_ROTATE90) )) SetEffect(CC_RUNTIME_CLASS(ABFXRotate90 ));
00961                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_ROTATE180))) SetEffect(CC_RUNTIME_CLASS(ABFXRotate180));
00962                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_ROTATE270))) SetEffect(CC_RUNTIME_CLASS(ABFXRotate270));
00963             }
00964             break;
00965 
00966     }
00967 }
00968 
00969 /********************************************************************************************
00970 
00971 >   void BfxDlg::HandleResizeMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
00972 
00973     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00974     Created:    20/02/95
00975     Inputs:     Msg: The message sent from page 1 of the dialog
00976     Outputs:    -
00977     Returns:    -
00978     Purpose:    All messages generated from the tabbed dialog's page 1 get processed here
00979     Errors:     -
00980     Scope:      private
00981     SeeAlso:    BfxDlg::Message
00982 
00983 ********************************************************************************************/
00984 
00985 
00986 void BfxDlg::HandleResizeMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
00987 {
00988     static BOOL ReEntered = FALSE;
00989     BOOL RescanSize = FALSE;
00990     TalkToPage(_R(IDD_BFXDLG_PG2));  // The Coords Page identifier
00991     switch(Msg->DlgMsg)
00992     {
00993         case DIM_SET_ACTIVE:
00994             ReEntered = FALSE; // Just in case we get out of sync
00995             break;
00996 
00997         case DIM_CREATE:
00998             FindBitmap();
00999             SetLongGadgetValue(_R(IDC_BFXDLG_INTERP), TRUE); 
01000             SetLongGadgetValue(_R(IDC_BFXDLG_ASPECT), TRUE); 
01001             RescanSize=TRUE;
01002             break;
01003 
01004         case DIM_OUT_OF_SPACE: // BODGE!!
01005             if (Msg->GadgetID == _R(IDC_BFXDLG_ORIGREDRAW))
01006                 RescanSize=TRUE;
01007             break;
01008 
01009         case DIM_SELECTION_CHANGED:
01010         case DIM_SLIDER_POS_SET:
01011         //case DIM_SLIDER_POS_CHANGING:
01012         case DIM_LFT_BN_CLICKED:
01013         case DIM_TEXT_CHANGED:             // Text changed 
01014             SetDirty();
01015             if ((GetLongGadgetValue(_R(IDC_BFXDLG_ASPECT),0,1)!=0) && !ReEntered)
01016             {
01017                 INT32 NewX = GetLongGadgetValue(_R(IDC_BFXDLG_NEWXSIZE),0,10000000);
01018                 INT32 NewY = GetLongGadgetValue(_R(IDC_BFXDLG_NEWYSIZE),0,10000000);
01019                 switch (Msg->GadgetID)
01020                 {
01021                     case _R(IDC_BFXDLG_NEWXSIZE):
01022                         if (pOrigInfo->PixelWidth)
01023                         {
01024                             ReEntered = TRUE;
01025                             SetLongGadgetValue(_R(IDC_BFXDLG_NEWYSIZE), (INT32)(0.5+ (
01026                                 ((double)(pOrigInfo->PixelHeight))/((double)(pOrigInfo->PixelWidth))*((double)(NewX)) )));
01027                             ReEntered = FALSE;
01028                         }
01029                         break;
01030                 
01031                     case _R(IDC_BFXDLG_NEWYSIZE):
01032                         if (pOrigInfo->PixelHeight)
01033                         {
01034                             ReEntered = TRUE;
01035                             SetLongGadgetValue(_R(IDC_BFXDLG_NEWXSIZE), (INT32)(0.5+ (
01036                                 ((double)(pOrigInfo->PixelWidth))/((double)(pOrigInfo->PixelHeight))*((double)(NewY)) )));
01037                             ReEntered = FALSE;
01038                         }
01039                         break;
01040 
01041                     default:
01042                         break;
01043                 }
01044             }
01045             break;
01046         case DIM_COMMIT:
01047         case DIM_SOFT_COMMIT:
01048             {
01049                 SetEffect(CC_RUNTIME_CLASS(ABFXResize));
01050                 INT32 NewX = GetLongGadgetValue(_R(IDC_BFXDLG_NEWXSIZE),0,10000000);
01051                 INT32 NewY = GetLongGadgetValue(_R(IDC_BFXDLG_NEWYSIZE),0,10000000);
01052                 if (NewX<2) NewX = 2;
01053                 if (NewY<2) NewY = 2;
01054                 SetParameters(NewX, NewY, (INT32)(BOOL)(GetLongGadgetValue(_R(IDC_BFXDLG_INTERP),0,1)!=0));
01055                 }
01056             break;
01057     }
01058 
01059     if (RescanSize && pOrigInfo)
01060     {
01061         ReEntered = TRUE;
01062         SetLongGadgetValue(_R(IDC_BFXDLG_ORIGXSIZE), pOrigInfo->PixelWidth);
01063         SetLongGadgetValue(_R(IDC_BFXDLG_NEWXSIZE),  pOrigInfo->PixelWidth);
01064         SetLongGadgetValue(_R(IDC_BFXDLG_ORIGYSIZE), pOrigInfo->PixelHeight);
01065         SetLongGadgetValue(_R(IDC_BFXDLG_NEWYSIZE),  pOrigInfo->PixelHeight);
01066         ReEntered = FALSE;
01067     }
01068 }
01069 /********************************************************************************************
01070 
01071 >   void BfxDlg::HandleBrightnessAndContrastMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01072 
01073     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01074     Created:    20/02/95
01075     Inputs:     Msg: The message sent from page 1 of the dialog
01076     Outputs:    -
01077     Returns:    -
01078     Purpose:    All messages generated from the tabbed dialog's page 1 get processed here
01079     Errors:     -
01080     Scope:      private
01081     SeeAlso:    BfxDlg::Message
01082 
01083 ********************************************************************************************/
01084 
01085 
01086 void BfxDlg::HandleBrightnessAndContrastMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01087 {
01088     TalkToPage(_R(IDD_BFXDLG_PG3));  // The Coords Page identifier
01089     switch(Msg->DlgMsg)
01090     {
01091         case DIM_CREATE:
01092             SetGadgetRange(_R(IDC_BFXDLG_BRIGHTNESS), -127, 127, 1);
01093             SetGadgetBitmaps(_R(IDC_BFXDLG_BRIGHTNESS), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01094             SetGadgetRange(_R(IDC_BFXDLG_CONTRAST), -127, 127, 1);
01095             SetGadgetBitmaps(_R(IDC_BFXDLG_CONTRAST), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01096             SetGadgetRange(_R(IDC_BFXDLG_COLOUR), -127, 127, 1);
01097             SetGadgetBitmaps(_R(IDC_BFXDLG_COLOUR), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01098             SetLongGadgetValue(_R(IDC_BFXDLG_BRIGHTNESS), 0); 
01099             SetLongGadgetValue(_R(IDC_BFXDLG_CONTRAST), 0); 
01100             SetLongGadgetValue(_R(IDC_BFXDLG_COLOUR), 0); 
01101             break;
01102 //      case DIM_SLIDER_POS_SET:
01103 //      case DIM_SLIDER_POS_IDLE:
01104         case DIM_LFT_BN_CLICKED:
01105         case DIM_SELECTION_CHANGED:
01106             {
01107                 switch (Msg->GadgetID)
01108                 {
01109                     case _R(IDC_BFXDLG_BRIGHTNESS):
01110                     case _R(IDC_BFXDLG_CONTRAST):
01111                     case _R(IDC_BFXDLG_COLOUR):
01112                         SetDirty();
01113                         break;
01114                     default:
01115                         break;
01116                 }
01117             }
01118             break;
01119 
01120         case DIM_SLIDER_POS_SET:
01121         case DIM_SLIDER_POS_IDLE:
01122         case DIM_COMMIT:
01123         case DIM_SOFT_COMMIT:
01124             {
01125                 INT32 Brightness = -GetLongGadgetValue(_R(IDC_BFXDLG_BRIGHTNESS),-127,127);
01126                 INT32 Contrast = -GetLongGadgetValue(_R(IDC_BFXDLG_CONTRAST),-127,127);
01127                 INT32 Colour = -GetLongGadgetValue(_R(IDC_BFXDLG_COLOUR),-127,127);
01128                 if (Msg->DlgMsg == DIM_SLIDER_POS_SET || Msg->DlgMsg == DIM_SLIDER_POS_IDLE)
01129                 {
01130                     if (InteractiveBCC)
01131                     {                   
01132                         if ((!pFX) || (!pFX->IsKindOf(CC_RUNTIME_CLASS(ABFXBrightnessContrast))) ||
01133                             (Brightness!=Param1) || (Contrast!=Param2) || (Colour!=Param3))
01134                         {
01135                             *pCommitValues = TRUE;
01136                             *pEndDialog = FALSE;
01137                             SetDirty(FALSE); // no redraw right now
01138                         }
01139                         else break;
01140                     }
01141                     else
01142                     {
01143                         SetDirty();
01144                         break;
01145                     }
01146                 }
01147                 SetEffect(CC_RUNTIME_CLASS(ABFXBrightnessContrast));
01148                 SetParameters(Brightness, Contrast, Colour);
01149             }
01150             break;
01151 
01152     }
01153 }
01154 /********************************************************************************************
01155 
01156 >   void BfxDlg::HandleDitherMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01157 
01158     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01159     Created:    20/02/95
01160     Inputs:     Msg: The message sent from page 1 of the dialog
01161     Outputs:    -
01162     Returns:    -
01163     Purpose:    All messages generated from the tabbed dialog's page 1 get processed here
01164     Errors:     -
01165     Scope:      private
01166     SeeAlso:    BfxDlg::Message
01167 
01168 ********************************************************************************************/
01169 
01170 
01171 void BfxDlg::HandleDitherMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01172 {
01173     TalkToPage(_R(IDD_BFXDLG_PG4));  // The Coords Page identifier
01174     switch(Msg->DlgMsg)
01175     {
01176         case DIM_CREATE:
01177             SetLongGadgetValue(_R(IDC_BFXDLG_BAYERMONO), TRUE); 
01178             SetLongGadgetValue(_R(IDC_BFXDLG_HALFTONEMONO), FALSE); 
01179             SetLongGadgetValue(_R(IDC_BFXDLG_DIFFUSIONMONO), FALSE); 
01180             SetLongGadgetValue(_R(IDC_BFXDLG_BAYERCOLOUR), FALSE); 
01181             SetLongGadgetValue(_R(IDC_BFXDLG_DIFFUSIONCOLOUR), FALSE); 
01182             SetLongGadgetValue(_R(IDC_BFXDLG_POPULARITY), FALSE); 
01183             SetLongGadgetValue(_R(IDC_BFXDLG_MAKEGREYSCALE), FALSE); 
01184             SetLongGadgetValue(_R(IDC_BFXDLG_OCTREECOLOUR), FALSE); 
01185             
01186 //EnableGadget(_R(IDC_BFXDLG_DIFFUSIONCOLOUR), FALSE); // Accusoft library crashes
01187 //EnableGadget(_R(IDC_BFXDLG_OCTREECOLOUR), FALSE); // Accusoft library crashes
01188             
01189             break;
01190 
01191         case DIM_LFT_BN_CLICKED:
01192         case DIM_SELECTION_CHANGED:
01193             {
01194                 switch (Msg->GadgetID)
01195                 {
01196                     case _R(IDC_BFXDLG_BAYERMONO):
01197                     case _R(IDC_BFXDLG_HALFTONEMONO):
01198                     case _R(IDC_BFXDLG_DIFFUSIONMONO):
01199                     case _R(IDC_BFXDLG_BAYERCOLOUR):
01200                     case _R(IDC_BFXDLG_DIFFUSIONCOLOUR):
01201                     case _R(IDC_BFXDLG_POPULARITY):
01202                     case _R(IDC_BFXDLG_MAKEGREYSCALE):
01203                     case _R(IDC_BFXDLG_OCTREECOLOUR):
01204                         SetDirty();
01205                         break;
01206                     default:
01207                         break;
01208                 }
01209             }
01210             break;
01211 
01212         case DIM_COMMIT:
01213         case DIM_SOFT_COMMIT:
01214             {
01215                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_BAYERMONO)      )) SetEffect(CC_RUNTIME_CLASS(ABFXBayerMono));
01216                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_HALFTONEMONO)   )) SetEffect(CC_RUNTIME_CLASS(ABFXHalftoneMono));
01217                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_DIFFUSIONMONO)  )) SetEffect(CC_RUNTIME_CLASS(ABFXDiffusionMono));
01218                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_BAYERCOLOUR)    )) SetEffect(CC_RUNTIME_CLASS(ABFXBayerColour));
01219                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_DIFFUSIONCOLOUR))) SetEffect(CC_RUNTIME_CLASS(ABFXDiffusionColour));
01220                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_POPULARITY)     )) SetEffect(CC_RUNTIME_CLASS(ABFXPopularityColour));
01221                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_MAKEGREYSCALE)  )) SetEffect(CC_RUNTIME_CLASS(ABFXMakeGreyscale));
01222                 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_OCTREECOLOUR)      )) SetEffect(CC_RUNTIME_CLASS(ABFXOctree));
01223             }
01224             break;
01225 
01226     }
01227 }
01228 
01229 /********************************************************************************************
01230 
01231 >   void BfxDlg::HandleSpecialEffectsMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01232 
01233     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01234     Created:    20/02/95
01235     Inputs:     Msg: The message sent from page 1 of the dialog
01236     Outputs:    -
01237     Returns:    -
01238     Purpose:    All messages generated from the tabbed dialog's page 1 get processed here
01239     Errors:     -
01240     Scope:      private
01241     SeeAlso:    BfxDlg::Message
01242 
01243 ********************************************************************************************/
01244 
01245 
01246 void BfxDlg::HandleSpecialEffectsMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01247 {
01248     TalkToPage(_R(IDD_BFXDLG_PG5));  // The Coords Page identifier
01249     switch(Msg->DlgMsg)
01250     {
01251         case DIM_CREATE:
01252             {
01253                 SetLongGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO), 0); 
01254                 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM1), (INT32)(Matrix[0]+0.5));
01255                 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM2), (INT32)(Matrix[1]+0.5));
01256                 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM3), (INT32)(Matrix[2]+0.5));
01257                 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM4), (INT32)(Matrix[3]+0.5));
01258                 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM5), (INT32)(Matrix[4]+0.5));
01259                 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM6), (INT32)(Matrix[5]+0.5));
01260                 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM7), (INT32)(Matrix[6]+0.5));
01261                 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM8), (INT32)(Matrix[7]+0.5));
01262                 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM9), (INT32)(Matrix[8]+0.5));
01263                 SetGadgetRange(_R(IDC_BFXDLG_AMOUNT), 0, 127, 1);
01264                 SetGadgetBitmaps(_R(IDC_BFXDLG_AMOUNT), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01265                 SetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT), 64); 
01266 
01267                 DeleteAllValues(_R(IDC_BFXDLG_EFFECTCOMBO));
01268 
01269                 String_256 Str0(_R(IDS_BFXDLG_EFFECTMENU0));
01270                 String_256 Str1(_R(IDS_BFXDLG_EFFECTMENU1));
01271                 String_256 Str2(_R(IDS_BFXDLG_EFFECTMENU2));
01272                 String_256 Str3(_R(IDS_BFXDLG_EFFECTMENU3));
01273                 String_256 Str4(_R(IDS_BFXDLG_EFFECTMENU4));
01274                 String_256 Str5(_R(IDS_BFXDLG_EFFECTMENU5));
01275                 String_256 Str6(_R(IDS_BFXDLG_EFFECTMENU6));
01276                 String_256 Str7(_R(IDS_BFXDLG_EFFECTMENU7));
01277                 String_256 Str8(_R(IDS_BFXDLG_EFFECTMENU8));
01278                 String_256 Str9(_R(IDS_BFXDLG_EFFECTMENU9));
01279                 String_256 Str10(_R(IDS_BFXDLG_EFFECTMENU10));
01280                 String_256 Str11(_R(IDS_BFXDLG_EFFECTMENU11));
01281                 String_256 Str12(_R(IDS_BFXDLG_EFFECTMENU12));
01282                 String_256 Str13(_R(IDS_BFXDLG_EFFECTMENU13));
01283                 String_256 Str14(_R(IDS_BFXDLG_EFFECTMENU14));
01284                 String_256 Str15(_R(IDS_BFXDLG_EFFECTMENU15));
01285                 String_256 Str16(_R(IDS_BFXDLG_EFFECTMENU16));
01286                 String_256 Str17(_R(IDS_BFXDLG_EFFECTMENU17));
01287                 String_256 Str18(_R(IDS_BFXDLG_EFFECTMENU18));
01288                 String_256 Str19(_R(IDS_BFXDLG_EFFECTMENU19));
01289             
01290                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str0,FALSE, 0);
01291                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str1,FALSE, 1);
01292                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str2,FALSE, 2);
01293                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str3,FALSE, 3);
01294                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str4,FALSE, 4);
01295                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str5,FALSE, 5);
01296                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str6,FALSE, 6);
01297                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str7,FALSE, 7);
01298                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str8,FALSE, 8);
01299                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str9,FALSE, 9);
01300                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str10,FALSE, 10);
01301                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str11,FALSE, 11);
01302                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str12,FALSE, 12);
01303                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str13,FALSE, 13);
01304                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str14,FALSE, 14);
01305                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str15,FALSE, 15);
01306                 if (IsUserName("Alex"))
01307                 {
01308                     SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str16,FALSE, 16);
01309                     SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str17,FALSE, 17);
01310                     SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str18,FALSE, 18);
01311                     SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str19,FALSE, 19);
01312                 }           
01313                 
01314                 
01315                 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str11, FALSE, -1);
01316                 SetComboListLength(_R(IDC_BFXDLG_EFFECTCOMBO));
01317                 SetSelectedValueIndex(_R(IDC_BFXDLG_EFFECTCOMBO), 11);
01318             }
01319             //break; RUN THROUGH
01320 
01321         case DIM_SLIDER_POS_SET:
01322         //case DIM_SLIDER_POS_CHANGING:
01323         case DIM_LFT_BN_CLICKED:
01324         case DIM_SELECTION_CHANGED:
01325         case DIM_TEXT_CHANGED:             // Text changed 
01326             {
01327                 SetDirty();
01328                 INT32 Choice = GetSelectedValueIndex(_R(IDC_BFXDLG_EFFECTCOMBO));
01329                 BOOL GreyAmount = (Choice <= 9);
01330                 BOOL GreyCustom = (Choice != 0);
01331                 EnableGadget(_R(IDC_BFXDLG_CUSTOM1), !GreyCustom);
01332                 EnableGadget(_R(IDC_BFXDLG_CUSTOM2), !GreyCustom);
01333                 EnableGadget(_R(IDC_BFXDLG_CUSTOM3), !GreyCustom);
01334                 EnableGadget(_R(IDC_BFXDLG_CUSTOM4), !GreyCustom);
01335                 EnableGadget(_R(IDC_BFXDLG_CUSTOM5), !GreyCustom);
01336                 EnableGadget(_R(IDC_BFXDLG_CUSTOM6), !GreyCustom);
01337                 EnableGadget(_R(IDC_BFXDLG_CUSTOM7), !GreyCustom);
01338                 EnableGadget(_R(IDC_BFXDLG_CUSTOM8), !GreyCustom);
01339                 EnableGadget(_R(IDC_BFXDLG_CUSTOM9), !GreyCustom);
01340                 EnableGadget(_R(IDC_BFXDLG_AMOUNT), !GreyAmount);
01341                 EnableGadget(_R(IDC_BFXDLG_AMOUNTTXT), !GreyAmount);
01342             }
01343             break;
01344 
01345         case DIM_COMMIT:
01346         case DIM_SOFT_COMMIT:
01347             {
01348                 INT32 Choice = GetSelectedValueIndex(_R(IDC_BFXDLG_EFFECTCOMBO));
01349                 Matrix[0]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM1),-255.0,255.0);
01350                 Matrix[1]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM2),-255.0,255.0);
01351                 Matrix[2]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM3),-255.0,255.0);
01352                 Matrix[3]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM4),-255.0,255.0);
01353                 Matrix[4]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM5),-255.0,255.0);
01354                 Matrix[5]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM6),-255.0,255.0);
01355                 Matrix[6]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM7),-255.0,255.0);
01356                 Matrix[7]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM8),-255.0,255.0);
01357                 Matrix[8]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM9),-255.0,255.0);
01358 
01359                 switch (Choice)
01360                 {
01361                     case 0:
01362                     case 1:
01363                     case 2:
01364                     case 3:
01365                     case 4:
01366                     case 5:
01367                     case 6:
01368                     case 7:
01369                     case 8:
01370                     case 9:
01371                         SetEffect(CC_RUNTIME_CLASS(ABFXSpecialEffect));
01372                         SetParameters((INT32) Choice);
01373                         break;
01374                     case 10:
01375                         SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01376                         SetParameters(((INT32) 127-GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127)), 1);
01377                         break;
01378                     case 11:
01379                         SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01380                         SetParameters(((INT32) 127-GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127)), 2);
01381                         break;
01382                     case 12:
01383                         SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01384                         SetParameters(((INT32) 127-GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127)), 3);
01385                         break;
01386                     case 13:
01387                         SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01388                         SetParameters(((INT32) GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127))-127, 1);
01389                         break;
01390                     case 14:
01391                         SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01392                         SetParameters(((INT32) GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127))-127, 2);
01393                         break;
01394                     case 15:
01395                         SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01396                         SetParameters(((INT32) GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127))-127, 3);
01397                         break;
01398                     case 16:
01399                     case 17:
01400                     case 18:
01401                     case 19:
01402                         SetEffect(CC_RUNTIME_CLASS(ABFXRemoveDither));
01403                         SetParameters((127-((INT32) GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127)))<<1, 30, Choice-16);
01404                         break;
01405                 }                                           
01406             }
01407 
01408     }
01409 }
01410 
01411 /********************************************************************************************
01412 
01413 >   void BfxDlg::HandleSpecialEffectsMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01414 
01415     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01416     Created:    20/02/95
01417     Inputs:     Msg: The message sent from page 1 of the dialog
01418     Outputs:    -
01419     Returns:    -
01420     Purpose:    All messages generated from the tabbed dialog's page 1 get processed here
01421     Errors:     -
01422     Scope:      private
01423     SeeAlso:    BfxDlg::Message
01424 
01425 ********************************************************************************************/
01426 
01427 
01428 void BfxDlg::HandleAlchemistMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01429 {
01430     TalkToPage(_R(IDD_BFXDLG_PG6));  // The Coords Page identifier
01431     switch(Msg->DlgMsg)
01432     {
01433         case DIM_CREATE:
01434             {
01435                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_HUE_CHECK), TRUE); 
01436                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_SATURATION_CHECK), TRUE); 
01437                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_VALUE_CHECK), TRUE); 
01438                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_RAINBOW_CHECK), TRUE); 
01439                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_VARIATION_CHECK), TRUE); 
01440                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_SHAPES_CHECK), TRUE); 
01441                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_STYLE_CHECK), TRUE); 
01442                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_OPACITY_CHECK), TRUE); 
01443                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_GRAIN_CHECK), TRUE); 
01444 
01445                 SetGadgetRange    (_R(IDC_BFXDLG_ALC_HUE_SLIDER), 0, 127, 1);
01446                 SetGadgetBitmaps  (_R(IDC_BFXDLG_ALC_HUE_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01447                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_HUE_SLIDER), 64); 
01448                 SetGadgetRange    (_R(IDC_BFXDLG_ALC_SATURATION_SLIDER), 0, 127, 1);
01449                 SetGadgetBitmaps  (_R(IDC_BFXDLG_ALC_SATURATION_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01450                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_SATURATION_SLIDER), 64); 
01451                 SetGadgetRange    (_R(IDC_BFXDLG_ALC_VALUE_SLIDER), 0, 127, 1);
01452                 SetGadgetBitmaps  (_R(IDC_BFXDLG_ALC_VALUE_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01453                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_VALUE_SLIDER), 64); 
01454                 SetGadgetRange    (_R(IDC_BFXDLG_ALC_RAINBOW_SLIDER), 0, 127, 1);
01455                 SetGadgetBitmaps  (_R(IDC_BFXDLG_ALC_RAINBOW_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01456                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_RAINBOW_SLIDER), 64); 
01457                 SetGadgetRange    (_R(IDC_BFXDLG_ALC_VARIATION_SLIDER), 0, 127, 1);
01458                 SetGadgetBitmaps  (_R(IDC_BFXDLG_ALC_VARIATION_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01459                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_VARIATION_SLIDER), 64); 
01460                 SetGadgetRange    (_R(IDC_BFXDLG_ALC_SHAPES_SLIDER), 0, 127, 1);
01461                 SetGadgetBitmaps  (_R(IDC_BFXDLG_ALC_SHAPES_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01462                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_SHAPES_SLIDER), 64); 
01463                 SetGadgetRange    (_R(IDC_BFXDLG_ALC_STYLE_SLIDER), 0, 127, 1);
01464                 SetGadgetBitmaps  (_R(IDC_BFXDLG_ALC_STYLE_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01465                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_STYLE_SLIDER), 64); 
01466                 SetGadgetRange    (_R(IDC_BFXDLG_ALC_OPACITY_SLIDER), 0, 127, 1);
01467                 SetGadgetBitmaps  (_R(IDC_BFXDLG_ALC_OPACITY_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01468                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_OPACITY_SLIDER), 64); 
01469                 SetGadgetRange    (_R(IDC_BFXDLG_ALC_GRAIN_SLIDER), 0, 127, 1);
01470                 SetGadgetBitmaps  (_R(IDC_BFXDLG_ALC_GRAIN_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01471                 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_GRAIN_SLIDER), 64); 
01472 
01473             }
01474             break; //RUN THROUGH
01475 
01476         case DIM_SLIDER_POS_SET:
01477         //case DIM_SLIDER_POS_CHANGING:
01478         case DIM_LFT_BN_CLICKED:
01479         case DIM_SELECTION_CHANGED:
01480         case DIM_TEXT_CHANGED:             // Text changed 
01481             {
01482                 SetDirty();
01483             }
01484             break;
01485 
01486         case DIM_COMMIT:
01487         case DIM_SOFT_COMMIT:
01488             {
01489             }
01490             break;
01491 
01492     }
01493 }
01494 
01495 
01496 /********************************************************************************************
01497 
01498 >   OpState BfxDlg::GetState(String_256*, OpDescriptor*)
01499 
01500 
01501     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01502     Created:    20/02/95
01503     Inputs:     -
01504     Outputs:    -
01505     Returns:    -
01506     Purpose:    The standard GetState fn, does nothing
01507     Errors:     -
01508     SeeAlso:    -
01509 
01510 ********************************************************************************************/
01511 
01512 
01513 OpState BfxDlg::GetState(String_256*, OpDescriptor*)
01514 {    
01515     OpState OpSt;
01516     return(OpSt);
01517 }
01518          
01519 /********************************************************************************************
01520 
01521 >   BOOL BfxDlg::Init()
01522 
01523 
01524     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01525     Created:    20/02/95
01526     Inputs:     -
01527     Outputs:    -
01528     Returns:    -
01529     Purpose:    The standard Init fn for the op. 
01530     Errors:     -
01531     SeeAlso:    -
01532 
01533 ********************************************************************************************/
01534 
01535 
01536 BOOL BfxDlg::Init()
01537 {  
01538     GetApplication()->DeclareSection( "Bitmap Effects", 1);
01539     GetApplication()->DeclarePref( "Bitmap Effects", "Interactive Brightness & Contrast", &InteractiveBCC, FALSE, TRUE);
01540     
01541     return (RegisterOpDescriptor(
01542                                 0,                         // Tool ID                    
01543                                 _R(IDS_BFXDLGM),               // String resouirce ID        
01544                                 CC_RUNTIME_CLASS(BfxDlg),  // Runtime class              
01545                                 OPTOKEN_BFXDLG,            // Token string               
01546                                 BfxDlg::GetState,          // GetState function          
01547                                 0,  /* help ID */          // Help ID                    
01548                                 _R(IDBBL_BITMAPEFFECTS),//_R(IDBBL_BFXDLG),   // Bubble ID                  
01549                                 _R(IDD_BARCONTROLSTORE),       // Resource ID                
01550                                 _R(IDC_BITMAPEFFECTS),         // Control ID                 
01551                                 SYSTEMBAR_UTILITIES,       // Bar ID                     
01552                                 TRUE,                      // Recieve system messages    
01553                                 FALSE,                     // Smart duplicate operation  
01554                                 TRUE,                      // Clean operation            
01555                                 0,                         // No vertical counterpart
01556                                 _R(IDS_BFXDLG_ONE),            // String for one copy only
01557                                 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE
01558                                 )
01559                                 
01560         && BfxOp::Init()); // HORRIBLE! But means I don't have to get a lock on main.cpp
01561 } 
01562 
01563 /********************************************************************************************
01564 
01565 >   static void BfxMsg::OpenOrUse(KernelBitmap * pBitmap)
01566 
01567     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01568     Created:    20/02/95
01569     Inputs:     pBitmap = bitmap to use
01570     Outputs:    -
01571     Returns:    -
01572     Purpose:    Open the bitmap effects dialog if it's not already open, else just uses that bitmap
01573     Errors:     -
01574     SeeAlso:    -
01575 
01576 ********************************************************************************************/
01577 
01578 void BfxMsg::OpenOrUse(KernelBitmap * pBitmap)
01579 {
01580     // Obtain a pointer to the op descriptor for the create operation 
01581     OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(BfxDlg));
01582     if (!OpDesc) return;
01583 
01584     // Only one live instance of the operation is allowed. It's probably a dialog 
01585     if (!MessageHandler::MessageHandlerExists(CC_RUNTIME_CLASS(BfxDlg)))
01586     {
01587         OpDesc->Invoke(&OpParam((INT32)pBitmap,(INT32)NULL));        
01588     }
01589     else
01590     {
01591         BROADCAST_TO_CLASS(BfxMsg(pBitmap),DialogOp);   
01592     }   
01593     return;
01594 }
01595 
01596 /********************************************************************************************
01597 
01598 >   void BfxDlg::Do(OpDescriptor*)
01599 
01600     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01601     Created:    20/02/95
01602     Inputs:     -
01603     Outputs:    -
01604     Returns:    -
01605     Purpose:    Like all Do functions invokes the BfxDlg
01606     Errors:     -
01607     SeeAlso:    -
01608 
01609 ********************************************************************************************/
01610 
01611 void BfxDlg::Do(OpDescriptor*)
01612 {
01613     String_256 Title(_R(IDS_BFXDLG));
01614     SetName(&Title); 
01615     BOOL ok = Create(); // Create the TAB dialog please
01616     if (!ok)
01617     {
01618         /*InformError(blobby)*/;    // Display an error if this is a real dialog please
01619         OpenPage=0;
01620         End(); 
01621     }
01622     TalkToPage(0);
01623     SetStringGadgetValue(_R(ID_APPLY_NOW), _R(IDS_BFXDLG_TEST));
01624     SetStringGadgetValue(IDOK, _R(IDS_BFXDLG_INSERT));
01625     SetStringGadgetValue(IDCANCEL, _R(IDS_BFXDLG_CLOSE));
01626 }
01627 
01628 /********************************************************************************************
01629 
01630 >   void BfxDlg::DoWithParam(OpDescriptor* pOp, OpParam* pParam)       
01631 
01632     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01633     Created:    23/2/95
01634     Inputs:     OpDescriptor (unused)
01635     Outputs:    -
01636     Returns:    -
01637     Purpose:    Performs the BfxOp for the first time
01638     Errors:     -
01639     SeeAlso:    -
01640 
01641 The first parameter should be a kernel bitmap to use or null to just bring the dialog up
01642 
01643 ********************************************************************************************/
01644 
01645 void BfxDlg::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
01646 {
01647     Do(pOp);
01648     KernelBitmap * pBitmap = NULL;
01649     if (pParam) pBitmap = (KernelBitmap *)(void *)(pParam->Param1);
01650     if (pBitmap && pBitmap->IsKindOf(CC_RUNTIME_CLASS(KernelBitmap)))
01651     {
01652         pOriginal=pBitmap;
01653         TalkToPage(OpenPage);
01654         OriginalChanged();
01655     }
01656     return;
01657 }
01658 
01659 
01660 /********************************************************************************************
01661 
01662 >   virtual BOOL BfxDlg::RegisterYourPagesInOrderPlease()
01663 
01664 
01665     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01666     Created:    20/02/95
01667     Inputs:     -
01668     Outputs:    -
01669     Returns:    return TRUE if all calls to AddAPage returned TRUE
01670     Purpose:    This virtual function will get called to give you a chance to add pages to your
01671                 DialogTabOp. This function will usually make multiple calls to AddAPage to 
01672                 register the initial set of pages to be contained in the tab dialog. The pages
01673                 should all be the same size and be registered in the left to right order in which
01674                 you wish them to appear. 
01675 
01676                 This function get's called directly from the Create method, Don't call it 
01677                 explicitly yourself. If you return FALSE from this method then the Create 
01678                 method will fail. 
01679 
01680     Errors:     -
01681     SeeAlso:    DialogTabOp::AddPage
01682     SeeAlso:    DialogOp::Create
01683 
01684 ********************************************************************************************/
01685 
01686 
01687 BOOL BfxDlg::RegisterYourPagesInOrderPlease()
01688 {
01689     BOOL ok = AddAPage(_R(IDD_BFXDLG_PG1)) &&   
01690               AddAPage(_R(IDD_BFXDLG_PG2)) &&
01691               AddAPage(_R(IDD_BFXDLG_PG3)) &&
01692               AddAPage(_R(IDD_BFXDLG_PG4)) &&
01693               AddAPage(_R(IDD_BFXDLG_PG5)) &&
01694 #ifdef _DEBUG
01695               ((!IsUserName("Alex")) || AddAPage(_R(IDD_BFXDLG_PG6))) &&
01696 #endif
01697               TRUE;
01698     return (ok); 
01699 }
01700  
01701    
01702 
01703 /********************************************************************************************
01704 
01705 >   BfxOp::BfxOp() 
01706 
01707     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01708     Created:    23/2/95
01709     Inputs:     -
01710     Outputs:    -
01711     Returns:    -
01712     Purpose:    BfxOp constructor
01713     Errors:     -
01714     SeeAlso:    -
01715 
01716 ********************************************************************************************/
01717 
01718 BfxOp::BfxOp(): UndoableOperation()  
01719 {                                
01720 }
01721    
01722 /********************************************************************************************
01723 
01724 >   BOOL BfxOp::Init()
01725 
01726     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01727     Created:    23/2/95
01728     Inputs:     -
01729     Outputs:    -
01730     Returns:    TRUE if the operation could be successfully initialised 
01731                 FALSE if no more memory could be allocated 
01732                 
01733     Purpose:    BlobyOp initialiser method
01734     Errors:     ERROR will be called if there was insufficient memory to allocate the 
01735                 operation.
01736     SeeAlso:    -
01737 
01738 ********************************************************************************************/
01739 
01740 BOOL BfxOp::Init()
01741 {  
01742     return (UndoableOperation::RegisterOpDescriptor(
01743                                             0,
01744                                             _R(IDS_BFXOP),
01745                                             CC_RUNTIME_CLASS(BfxOp),
01746                                             OPTOKEN_BFXOP,
01747                                             BfxOp::GetState,
01748                                             0,  /* help ID */
01749                                             0,  /* bubble help ID */
01750                                             0   /* bitmap ID */)); 
01751 }
01752 
01753 /********************************************************************************************
01754 
01755 >   OpState BfxOp::GetState(String_256*, OpDescriptor*)
01756 
01757     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01758     Created:    23/2/95
01759     Inputs:     -
01760     Outputs:    -
01761     Returns:    The state of the BfxOp
01762     Purpose:    For finding the BfxOp's state. 
01763     Errors:     -
01764     SeeAlso:    -
01765 
01766 ********************************************************************************************/
01767 
01768 OpState BfxOp::GetState(String_256*, OpDescriptor*)
01769 {    
01770     OpState OpSt;
01771     return(OpSt);
01772 }
01773         
01774 /********************************************************************************************
01775 
01776 >   void BfxOp::DoWithParam(OpDescriptor* pOp, OpParam* pParam)    
01777 
01778     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01779     Created:    23/2/95
01780     Inputs:     OpDescriptor (unused)
01781     Outputs:    -
01782     Returns:    -
01783     Purpose:    Performs the BfxOp for the first time
01784     Errors:     -
01785     SeeAlso:    -
01786 
01787 Blatantly copied from BitFilt::DoImportBitmap
01788 
01789 ********************************************************************************************/
01790 
01791 void BfxOp::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
01792 {               
01793     DocCoord DropPos;
01794     Spread * pSpread;
01795     BOOL ok=FALSE;
01796     
01797     if (!GetWorkingDoc()) return;
01798     
01799     if (!FindCentreInsertionPosition(&pSpread, &DropPos))
01800     {
01801         InformError();
01802         FailAndExecute();
01803         End();
01804         return;
01805     }
01806 
01807     // Get a new NodeBitmap object to import into.
01808     NodeBitmap *pNodeBitmap = new NodeBitmap;
01809     if ((pNodeBitmap == NULL) || (!pNodeBitmap->SetUpPath(12,12)))
01810     {
01811         InformError();      
01812         FailAndExecute();
01813         End();
01814         return;
01815     }
01816 
01817     KernelBitmap* pKB = *(((BfxOpParam *)(pParam))->ppBitmap);
01818     if (pKB == NULL)
01819     {
01820         // Bitmap is NULL, so the op must have failed
01821         delete pNodeBitmap;
01822         FailAndExecute();
01823         End();
01824         return;
01825     }
01826     
01827     // Put up a progress display/hourglass (FALSE => no delay, show it NOW!)
01828     BeginSlowJob(100, FALSE);
01829     *(((BfxOpParam *)(pParam))->ppBitmap) = NULL; // The bitmap is now the responsibility of this routine
01830 
01831     // The bitmap above is a temp bitmap, so we'll extract the OILBitmap (which will delete the KBmp),
01832     // and create a 'proper' kbmp to attach to the node
01833     OILBitmap* pOILBmp = pKB->ExtractOILBitmap();
01834     pKB = KernelBitmap::MakeKernelBitmap(pOILBmp, GetWorkingDoc());
01835 
01836     pNodeBitmap->GetBitmapRef()->Attach(pKB);
01837 
01838     if (pNodeBitmap->GetBitmap() != pKB)
01839     {
01840         // It didn't use the bitmap we gave it, so we can delete it
01841         delete pKB;
01842     }
01843 
01844     // First, set the rectangle to the right size for the bitmap...
01845     BitmapInfo Info;
01846     pNodeBitmap->GetBitmap()->ActualBitmap->GetInfo(&Info);
01847 
01848     DocRect BoundsRect;
01849     BoundsRect.lo.x = DropPos.x - (Info.RecommendedWidth/2);
01850     BoundsRect.lo.y = DropPos.y - (Info.RecommendedHeight/2);
01851     BoundsRect.hi.x = BoundsRect.lo.x + Info.RecommendedWidth;
01852     BoundsRect.hi.y = BoundsRect.lo.y + Info.RecommendedHeight;
01853 
01854     // And set this in our bitmap node
01855     pNodeBitmap->CreateShape(BoundsRect);
01856 
01857     // Apply some default attrs for the bitmap
01858     // This Must be done before the NodeBitmap is inserted into the tree
01859     if (!pNodeBitmap->ApplyDefaultBitmapAttrs(this))
01860     {
01861         goto EndOp;
01862     }
01863         
01864     // Insert the node
01865     if (!DoInsertNewNode(pNodeBitmap, pSpread, TRUE))
01866     {
01867         // It didn't work - delete the sub-tree we just created.
01868         delete pNodeBitmap;
01869         goto EndOp;
01870     }
01871 
01872     ok = TRUE;
01873 
01874 EndOp:
01875     if (!ok)
01876     {
01877         FailAndExecute();
01878         InformError();
01879     }
01880 
01881     EndSlowJob();
01882     End();
01883 }
01884 
01885 /********************************************************************************************
01886 
01887 >   BOOL BfxOp::FindCentreInsertionPosition(Spread** Spread, DocCoord* Position)
01888 
01889     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
01890     Created:    24/3/95
01891     Inputs:     -
01892     Outputs:    Spread:  The spread to place the clipboard objects on
01893                 Position:The centre of the view (Spread coords)
01894     Returns:    TRUE if succeeded else FALSE
01895     Purpose:    Finds the centre insertion position for clipboard objects
01896     Errors:     ERROR2 in various situations
01897     Scope:      private
01898     SeeAlso:    -
01899 
01900 ********************************************************************************************/
01901 
01902 BOOL BfxOp::FindCentreInsertionPosition(Spread** Spread, DocCoord* Position)
01903 {
01904     // Let's chuck in a smattering of defensive programming
01905     ERROR3IF(Spread == NULL || Position == NULL, "Illegal NULL params");
01906     *Spread = NULL;
01907     *Position = DocCoord(0,0);  // A default value if we fail
01908 
01909     // ---------------------------------------------------------------------------------
01910     // Find out which spread is in the centre of the view 
01911     // this is the spread that the pasted objects will be placed on
01912 
01913     ERROR2IF((!Spread)||(!Position),FALSE,"Invalid call to FindCentreInsertionPoint()");
01914     // Obtain the current DocView
01915     DocView* CurDocView = GetWorkingDocView();
01916 
01917     ERROR2IF(!CurDocView, FALSE, "The current DocView is NULL"); 
01918 
01919     WorkRect WrkViewRect = CurDocView->GetViewRect();
01920 
01921     ERROR2IF((WrkViewRect.IsEmpty() || (!WrkViewRect.IsValid()) ), FALSE, "Invalid WorkRect");
01922     
01923     // Determine the centre of the view
01924     WorkCoord WrkCentreOfView; 
01925     WrkCentreOfView.x = WrkViewRect.lox + (WrkViewRect.Width()/2); 
01926     WrkCentreOfView.y = WrkViewRect.loy + (WrkViewRect.Height()/2);
01927     
01928     // FindEnclosing spread requires an OilCoord
01929     OilCoord OilCentreOfView = WrkCentreOfView.ToOil(CurDocView->GetScrollOffsets()); 
01930 
01931     // Find out which spread to insert the pasteboard objects onto
01932     (*Spread) = CurDocView->FindEnclosingSpread(OilCentreOfView);
01933     ERROR2IF(!(*Spread), FALSE, "No spread?!");
01934 
01935     // Phew
01936     // ---------------------------------------------------------------------------------
01937     // Now lets find the spread coordinate of the centre of the view
01938     DocRect DocViewRect = CurDocView->GetDocViewRect(*Spread);
01939 
01940     ERROR2IF( ( (DocViewRect.IsEmpty()) || !(DocViewRect.IsValid())), FALSE, "DocViewRect is invalid" );
01941 
01942     // Find the centre of the DocViewRect
01943     DocCoord DocCentreOfView; 
01944     DocCentreOfView.x = DocViewRect.lox + (DocViewRect.Width()/2); 
01945     DocCentreOfView.y = DocViewRect.loy + (DocViewRect.Height()/2);
01946 
01947     // Now convert from DocCoords to spread coords
01948     (*Spread)->DocCoordToSpreadCoord(&DocCentreOfView);
01949 
01950     // Finally, fill in the return value
01951     *Position = DocCentreOfView;
01952     
01953     return TRUE;  
01954 }
01955 
01956 

Generated on Sat Nov 10 03:44:20 2007 for Camelot by  doxygen 1.4.4