#include <gbrush.h>
Inheritance diagram for GBrush:
Public Member Functions | |
GBrush () | |
GBrush constructor. Call Init before trying to use. | |
~GBrush () | |
GBrush destructor. Does necessary cleanup. | |
BOOL | Init (wxDC *Ref) |
Determines whether a GBrush can be used in the given device. Call Start before trying to use, assuming a TRUE result. | |
void | Start () |
Call before trying to use the GBrush. There can only be one active GBrush in use at a time. Will fail silently if not available. | |
void | Stop () |
Says 'we have stopped using this for the moment'. Call Start to start again. It is not necessary to call this before destruction. Safe to call even if not Available. | |
BOOL | Available () |
void | GetLogBrush (ColourContext *, DocColour &, wxBrush *) |
The whole point of the GBrush class is to get one of these. | |
void | GetLogBrush (const COLORREF rgb, wxBrush *pBrush) |
The whole point of the GBrush class is to get one of these. This method returns a brush given the RGB screen word to use fo it. Probably you really want to use the other overloaded GetLogBrush method, as this does all the colour conversion for you. | |
void | SetSolidColours (BOOL UseSolid) |
Allows the dithering of colours to be turned off so they look the same using GDraw as they do with the GDI. | |
Static Public Member Functions | |
static BOOL | InitGBrush (BOOL) |
Allows the user to determine whether GDraw brushes are used (1) or normal GDI brushes (0). Defaults to 1 because it produces a much nicer colour bar.GBuilds the pretend bitmap which ise used to fool GDraw into suppyling us with brushes. Called from GRenderRegion::Init and relies on that being called first. | |
static void | DeinitGBrush (void) |
De-initialises the GBrush pretend bitmap. Called on DeInit of GRenderRegion to shut down without a memory leak taking place. | |
static void | NewBrushState () |
Called when the WantBetterBrushes state changes. Goes around and invalidates any current GBrushes, else they will be wrong. It also frees the global memory block in each GBrush so it will be re-allocated. | |
static void | ResetOnFatalError () |
Private Member Functions | |
CC_DECLARE_MEMDUMP (GBrush) | |
void | GetLogBrushInternal (const COLORREF rgb, wxBrush *pBrush) |
The whole point of the GBrush class is to get one of these. This is an inline macro used by the 2 overloaded GetLogBrush functions so the code need only be changed in one place. | |
Private Attributes | |
BOOL | Valid |
BOOL | CanUse |
wxDC * | ReferenceDC |
RGBQUAD | RGBList [256] |
BOOL | UseSolidColours |
Static Private Attributes | |
static List | BrushList |
static GBrush * | Current |
Definition at line 126 of file gbrush.h.
|
GBrush constructor. Call Init before trying to use.
Definition at line 238 of file gbrush.cpp. 00239 { 00240 CanUse = FALSE; 00241 Valid = FALSE; 00242 00243 BrushList.AddHead( this ); 00244 00245 UseSolidColours = FALSE; 00246 }
|
|
GBrush destructor. Does necessary cleanup.
Definition at line 264 of file gbrush.cpp. 00265 { 00266 if (Current == this) 00267 Current = NULL; 00268 00269 #ifdef _DEBUG 00270 ListItem *Old = BrushList.RemoveItem( this ); 00271 ERROR3IF( Old == NULL, "GBrush being deleted not in list" ); 00272 #else 00273 BrushList.RemoveItem( this ); // to suppress compiler warning in both debug & retail builds 00274 #endif 00275 }
|
|
Definition at line 135 of file gbrush.h. 00135 { return Valid; }
|
|
|
|
De-initialises the GBrush pretend bitmap. Called on DeInit of GRenderRegion to shut down without a memory leak taking place.
Definition at line 209 of file gbrush.cpp. 00210 { 00211 #ifdef _DEBUG 00212 // This was an ERROR3, but our stupid error handler doesn't handle errors very well, 00213 // (in fact, at this stage in program de-initialisation, it doesn' handle them at all) 00214 // so it's just a trace warning now. 00215 if (!BrushList.IsEmpty()) 00216 { 00217 TRACEALL( wxT("Warning: Deinitialising GBrush when GBrush(es) still active\n\n" ) ); 00218 } 00219 #endif 00220 }
|
|
The whole point of the GBrush class is to get one of these. This method returns a brush given the RGB screen word to use fo it. Probably you really want to use the other overloaded GetLogBrush method, as this does all the colour conversion for you.
Definition at line 543 of file gbrush.cpp. 00544 { 00545 GetLogBrushInternal(rgb,pBrush); 00546 }
|
|
The whole point of the GBrush class is to get one of these.
Definition at line 515 of file gbrush.cpp. 00516 { 00517 const COLORREF rgb = ConvertColourToScreenWord(OutputContext, &Col); 00518 00519 GetLogBrushInternal(rgb,pBrush); 00520 }
|
|
The whole point of the GBrush class is to get one of these. This is an inline macro used by the 2 overloaded GetLogBrush functions so the code need only be changed in one place.
Definition at line 417 of file gbrush.cpp. 00418 { 00419 ERROR3IF( !Valid, "GBrush called when not available"); 00420 ERROR3IF( Current != this, "GBrush not current"); 00421 00422 pBrush->SetStyle(wxSOLID); 00423 00424 // we let the Widgets handle primary colours cos they should be able to manage it (!) 00425 if ( ((rgb & 0x0000FF)==0x000000 || (rgb & 0x0000FF)==0x0000FF) && 00426 ((rgb & 0x00FF00)==0x000000 || (rgb & 0x00FF00)==0x00FF00) && 00427 ((rgb & 0xFF0000)==0x000000 || (rgb & 0xFF0000)==0xFF0000) ) 00428 { 00429 pBrush->SetColour(GetRValue(rgb),GetGValue(rgb),GetBValue(rgb)); 00430 return; 00431 } 00432 00433 // We assume the GBrush is defined in the GContext belonging to GRenderRegions 00434 // ARRRGGHHH Who wrote MakeCurrent() without making it Virtual. What a naughty 00435 // boy I am (Andy, that is! - Jason ;-) 00436 GDrawContext *GContext = GRenderRegion::GetStaticDrawContext(); 00437 const BYTE *pGBrush = NULL; 00438 00439 // This was checked in init/start, but we might as well be safe 00440 if (GContext != NULL) 00441 { 00442 // If the current mode is for solid colours (no dithering) then we ask for solid colour. 00443 // This is used for things like pasteboards which shouldn't dither for aesthetic (eor!) reasons 00444 if (UseSolidColours) 00445 GContext->SetSolidColour(rgb); 00446 else 00447 GContext->SetColour(rgb); 00448 00449 pGBrush = GContext->ReturnBrushRGB(); 00450 } 00451 else 00452 ERROR3("GBrush got a NULL GContext!\n"); 00453 00454 if (pGBrush == NULL) 00455 pBrush->SetColour(GetRValue(rgb),GetGValue(rgb),GetBValue(rgb)); 00456 else if ( UseSolidColours ) 00457 pBrush->SetColour(pGBrush[0],pGBrush[1],pGBrush[2]); 00458 else 00459 { 00460 #ifdef __WXGTK__ 00461 // The following line shouldn't be necessary, but wxGTK appears to 00462 // fail if it doesn't have a valid colour when setting the brush 00463 // into a device context. 00464 pBrush->SetColour(0,0,0); 00465 #endif 00466 wxImage image(4,4,(BYTE*)pGBrush,true); 00467 wxBitmap bitmap(image); 00468 pBrush->SetStipple(bitmap); // Also sets style to wxSTIPPLE 00469 } 00470 }
|
|
Determines whether a GBrush can be used in the given device. Call Start before trying to use, assuming a TRUE result.
Definition at line 295 of file gbrush.cpp. 00296 { 00297 ENSURE( Current==NULL, "Only one current GBrush at a time" ); 00298 00299 Valid = FALSE; // in case of failure 00300 00301 ReferenceDC = RefDC; // remember for Start time 00302 00303 CanUse = TRUE; 00304 return CanUse; 00305 }
|
|
Allows the user to determine whether GDraw brushes are used (1) or normal GDI brushes (0). Defaults to 1 because it produces a much nicer colour bar.GBuilds the pretend bitmap which ise used to fool GDraw into suppyling us with brushes. Called from GRenderRegion::Init and relies on that being called first.
Definition at line 160 of file gbrush.cpp. 00161 { 00162 if (FirstTime && Camelot.DeclareSection( wxT("Screen"), 10)) 00163 { 00164 Camelot.DeclarePref(NULL, wxT("BetterBrushes"), &WantBetterBrushes, FALSE, TRUE ); 00165 } 00166 // Register the (debug) Op to enable/disable GBrush 00167 if (!Operation::RegisterOpDescriptor( 00168 0, 00169 _R(IDS_GBRUSH), 00170 CC_RUNTIME_CLASS(OpGBrush), 00171 OPTOKEN_GBRUSH, 00172 OpGBrush::GetState, 00173 0, /* help ID */ 00174 0, //_R(IDBBL_ANTIALIASOP), 00175 0 /* bitmap ID */ 00176 )) 00177 { 00178 TRACE( wxT("RegisterOpDescriptor( OpGBrush ) failed") ); 00179 return FALSE; 00180 } 00181 00182 // Ensure that none of the GBrushes are active 00183 NewBrushState(); 00184 Current = NULL; 00185 00186 return TRUE; 00187 }
|
|
Called when the WantBetterBrushes state changes. Goes around and invalidates any current GBrushes, else they will be wrong. It also frees the global memory block in each GBrush so it will be re-allocated.
Definition at line 566 of file gbrush.cpp. 00567 { 00568 // find all current GBrushes 00569 ListItem *Item = BrushList.GetHead(); 00570 while (Item) 00571 { 00572 // check type 00573 #ifdef _DEBUG 00574 ENSURE( Item->GetRuntimeClass() == CC_RUNTIME_CLASS(GBrush), "Not GBrush in list"); 00575 #endif 00576 00577 // safe to cast now 00578 GBrush *const Brush = (GBrush*const)Item; 00579 Brush->Stop(); // reset Valid & Current 00580 00581 // get next one in list 00582 Item = BrushList.GetNext( Item ); 00583 } 00584 }
|
|
Definition at line 146 of file gbrush.h.
|
|
Allows the dithering of colours to be turned off so they look the same using GDraw as they do with the GDI.
Definition at line 489 of file gbrush.cpp. 00490 { 00491 UseSolidColours = SetSolid; 00492 }
|
|
Call before trying to use the GBrush. There can only be one active GBrush in use at a time. Will fail silently if not available.
Definition at line 324 of file gbrush.cpp. 00325 { 00326 ENSURE( Current==NULL, "Only one current GBrush at a time" ); 00327 00328 if (CanUse && WantBetterBrushes) 00329 { 00330 GDrawContext *GContext = GRenderRegion::GetStaticDrawContext(); 00331 00332 // We checked this in Init() so it should be OK, but we might as well be safe 00333 if (GContext != NULL) 00334 { 00335 Valid = TRUE; 00336 Current = this; 00337 00338 // Get the 16bpp screen hinting value so Gavin can do solid colours properly 00339 DWORD GavinHint = DIBUtil::GetGavinBlitFormat(GRenderRegion::ScreenDepth, 00340 32, GRenderRegion::ScreenHinting); 00341 00342 // And set Gavin up to render into our brush bitmap 00343 GContext->SetupBitmap( 00344 4,4, 00345 GRenderRegion::ScreenDepth==24?32:GRenderRegion::ScreenDepth, 00346 NULL, 00347 GavinHint 00348 ); 00349 00350 // We want dithering not error diffusion please GDraw 00351 /*pcLOGPALETTE lpPal =*/ GContext->SelectPalette(0); 00352 00353 // In 8bpp, make sure GDraw is aware of the current system palette 00354 if (GRenderRegion::ScreenDepth == 8) 00355 GRenderRegion::GColInit( ReferenceDC ); 00356 00357 // Attempt to ensure halftone patterns always use the same origin 00358 GContext->SetHalftoneOrigin(0, 0); 00359 } 00360 else 00361 ERROR3("GDraw Context not available in GBrush::Start()"); 00362 } 00363 }
|
|
Says 'we have stopped using this for the moment'. Call Start to start again. It is not necessary to call this before destruction. Safe to call even if not Available.
Definition at line 383 of file gbrush.cpp.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|