Bugfix : Zooming works correct, no more errors on screen.
[xara-cairo.git] / wxOil / grndbrsh.h
blob30c0ad2d40048e5a628a9e1cd1a703e47dfeeb68
1 // $Id: grndbrsh.h 1755 2006-09-16 12:00:36Z alex $
2 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
3 ================================XARAHEADERSTART===========================
5 Xara LX, a vector drawing and manipulation program.
6 Copyright (C) 1993-2006 Xara Group Ltd.
7 Copyright on certain contributions may be held in joint with their
8 respective authors. See AUTHORS file for details.
10 LICENSE TO USE AND MODIFY SOFTWARE
11 ----------------------------------
13 This file is part of Xara LX.
15 Xara LX is free software; you can redistribute it and/or modify it
16 under the terms of the GNU General Public License version 2 as published
17 by the Free Software Foundation.
19 Xara LX and its component source files are distributed in the hope
20 that it will be useful, but WITHOUT ANY WARRANTY; without even the
21 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 See the GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License along
25 with Xara LX (see the file GPL in the root directory of the
26 distribution); if not, write to the Free Software Foundation, Inc., 51
27 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 ADDITIONAL RIGHTS
31 -----------------
33 Conditional upon your continuing compliance with the GNU General Public
34 License described above, Xara Group Ltd grants to you certain additional
35 rights.
37 The additional rights are to use, modify, and distribute the software
38 together with the wxWidgets library, the wxXtra library, and the "CDraw"
39 library and any other such library that any version of Xara LX relased
40 by Xara Group Ltd requires in order to compile and execute, including
41 the static linking of that library to XaraLX. In the case of the
42 "CDraw" library, you may satisfy obligation under the GNU General Public
43 License to provide source code by providing a binary copy of the library
44 concerned and a copy of the license accompanying it.
46 Nothing in this section restricts any of the rights you have under
47 the GNU General Public License.
50 SCOPE OF LICENSE
51 ----------------
53 This license applies to this program (XaraLX) and its constituent source
54 files only, and does not necessarily apply to other Xara products which may
55 in part share the same code base, and are subject to their own licensing
56 terms.
58 This license does not apply to files in the wxXtra directory, which
59 are built into a separate library, and are subject to the wxWindows
60 license contained within that directory in the file "WXXTRA-LICENSE".
62 This license does not apply to the binary libraries (if any) within
63 the "libs" directory, which are subject to a separate license contained
64 within that directory in the file "LIBS-LICENSE".
67 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
68 ----------------------------------------------
70 Subject to the terms of the GNU Public License (see above), you are
71 free to do whatever you like with your modifications. However, you may
72 (at your option) wish contribute them to Xara's source tree. You can
73 find details of how to do this at:
74 http://www.xaraxtreme.org/developers/
76 Prior to contributing your modifications, you will need to complete our
77 contributor agreement. This can be found at:
78 http://www.xaraxtreme.org/developers/contribute/
80 Please note that Xara will not accept modifications which modify any of
81 the text between the start and end of this header (marked
82 XARAHEADERSTART and XARAHEADEREND).
85 MARKS
86 -----
88 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
89 designs are registered or unregistered trademarks, design-marks, and/or
90 service marks of Xara Group Ltd. All rights in these marks are reserved.
93 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
94 http://www.xara.com/
96 =================================XARAHEADEREND============================
99 //GRenderBrush - render region used for drawing brush strokes
103 #include "grndrgn.h"
104 #include "grnddib.h"
106 class DocRect;
108 #ifndef INC_GRNDBRSH
109 #define INC_GRNDBRSH
111 #include "grndrgn.h"
113 /********************************************************************************************
115 > class GRenderBrush : public GRenderDIB
117 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
118 Created: 20/12/99
119 Purpose: A GDraw render region that uses normal DIBs for the bitmap.
120 It serves a particularly special purpose in that it provides a number of
121 functions that allow us to blit to the screen very quickly without
122 getting tangled up in the render loop. This is so that we can draw brush
123 strokes and have them appear on the screen in real time.
124 This is achieved by maintaining not one but four static
125 bitmaps. These work in the following way:
127 The main bitmap (lpbits) needs to have the current view rendered into it before
128 beginning the brush stroke.
129 lpbrushbits - bitmap which has the brush rendered into it.
131 What we do instead of rendering is to simply combine the brush bitmap with
132 the view bitmap, copy the results to lppreconvertbits and either blit it or
133 convert it(if we are on a <24bit device).
135 ********************************************************************************************/
137 class GRenderBrush : public GRenderDIB
139 CC_DECLARE_DYNAMIC(GRenderBrush)
141 public:
142 GRenderBrush(DocRect ClipRegion, Matrix ConvertMatrix, FIXED16 ViewScale, UINT32 Depth, double dpi);
143 ~GRenderBrush();
146 void DrawToScreenNow(); // the top level function that gets whatever is in the
147 // is in the changed BBox onto the screen
149 public: // access functions
150 void SetChangedBBox(DocRect Rect);
152 public: // functions you need to call to set up the bitmaps
153 // before you draw anything
155 BOOL InitialiseBrushBitmaps(DocRect BrushRect);
156 void SetupMainBitmap();
158 // plots the brush into the main bitmap
159 BOOL PlotBrushIntoBigBitmap(DocRect BrushRect);
161 // captures the screen as a bitmap
162 BOOL CaptureView(Spread* pSpread);
164 // sets the window to the top of the z-order
165 BOOL MoveWindowToFront();
167 BOOL ResetMatrix();
169 void Blackout();
171 static BOOL Convert16to32( LPBITMAPINFO pSourceInfo, LPBYTE pSourceBits, RGBQUAD* pPalette,
172 LPBITMAPINFO pDestInfo, LPBYTE pDestBits);
173 UINT32 GetScreenDepth() { return (UINT32)ScreenDepth; }
175 protected: // helper functions
176 BOOL ConvertBrushBitmap(); // converts the brush bitmap to the right depth
177 BOOL TestConvertBitmap();
179 BOOL ClipBrushBitmaps(RECT* pUsedRect, INT32* pHeight); //makes sure we only blit the
180 // the size of the usedrect
181 void SetupBitmap(LPBITMAPINFO pBitmapInfo, LPBYTE pBits);
182 BOOL InitialiseBrushBitmaps(INT32 Width, INT32 Height, INT32 RenderDepth, INT32 DeviceDepth);
184 BOOL CaptureViewByRendering(); // renders the view into our bitmap
186 PORTNOTE("other", "Disable HDC stuff")
187 #ifndef EXCLUDE_FROM_XARALX
188 // test to split up the captureview fns for better profiling
189 BOOL Blit(HDC DestDC, HDC SourceDC, INT32 Height, INT32 Width, INT32 Left, INT32 Top);
190 BOOL GetBits(HDC hDC, HBITMAP hBitmap, INT32 Height, LPBYTE lpbits, LPBITMAPINFO lpInfo);
191 #endif
193 virtual void FreeLPBits( LPBITMAPINFO, LPBYTE );
195 // Karim 21/07/2000
196 // Overrides so that GRenderBrush doesn't have to worry about feathers
197 // (which are offscreen attrs).
198 public:
199 virtual void SetOffscreen(OffscreenAttrValue*) {}
200 virtual void RestoreOffscreen(OffscreenAttrValue*) {}
202 //#ifdef NEWFASTBRUSHES
203 // CGS 16/1/2001
204 // allow us to optimise the code within DrawToScreenNow - so that we do NOT always have
205 // to expensively grab hold of the views DC within an interactive loop ....
206 void SetView (View* v) { m_pView = v; }
207 void SetCamView (CCamView* v) { m_pCCamView = v; }
208 PORTNOTE("other", "Disable HDC stuff")
209 #ifndef EXCLUDE_FROM_XARALX
210 void SetCDC (CDC* cdc) { m_pDevContext = cdc; }
211 void SetHDC (HDC hdc) { m_DeviceHdc = hdc; }
212 #endif
213 //#endif
215 protected: // Data
217 LPBITMAPINFO lpPreConvertBrushBitmapInfo;
218 LPBYTE lpPreConvertBrushBits;
219 LPBITMAPINFO lpPostConvertBrushBitmapInfo;
220 LPBYTE lpPostConvertBrushBits;
221 LPBITMAPINFO lpBrushBitmapInfo;
222 LPBYTE lpBrushBits;
224 LPBITMAPINFO lpTestInfo;
225 LPBYTE lpTestBits;
227 RGBQUAD* m_pPalette;
229 //#ifdef NEWFASTBRUSHES
230 // CGS 16/1/2001
231 // allow us to optimise the code within DrawToScreenNow - so that we do NOT always have
232 // to expensively grab hold of the views DC within an interactive loop ....
233 View* m_pView;
234 CCamView* m_pCCamView;
235 PORTNOTE("other", "Disable HDC stuff")
236 #ifndef EXCLUDE_FROM_XARALX
237 CDC* m_pDevContext;
238 HDC m_DeviceHdc;
239 #endif
240 //#endif
243 #endif