#include <palman.h>
Static Public Member Functions | |
static BOOL | EnsurePalette (wxWindow *CWindow, BOOL ForceRedraw) |
To respond to WM_QUERYNEWPALETTE and WM_ONPALETTECHANGED Whenever you get one of these messages for youre window, call this method if you want to use the normal GDraw palette. The only splitter in this area to date is the splashbox window. | |
static wxPalette * | StartPaintPalette (wxDC *hDC, wxPalette *pHPal=NULL, BOOL bForceBackground=FALSE) |
To select and realise the mainframe GDraw palette before painting Scope: Static public. | |
static wxPalette * | StopPaintPalette (wxDC *RenderDC, wxPalette *OldPalette, BOOL bForceBackground=TRUE) |
To restore the palette after painting, using the palette returned to you by StartPaintPalette. | |
static BOOL | Init (void) |
Initialises the palette manager. | |
static BOOL | UsePalette (void) |
static void | UpdatePalette (void) |
Sets up the static main frame palette This will be called whenever the palette needs updating. | |
static wxPalette * | GetPalette (void) |
static void | LockPalette (BOOL fLocked) |
"Locks" or "unlocks" the palette, preventing or allowing palette changes due to window repaints. Ultra-bodge way of preventing splash-box palette flash during workspace restoration. | |
static void | RedrawAllPalettedWindows (wxWindow *ParentWindow=NULL) |
To redraw the given window (and all children) that are reliant upon 256- colour palettes. Usually called with NULL to just redraw the MainFrame. | |
static void | MakePaletteBrowserCompatible (LPLOGPALETTE pPalette, BOOL IncludeSystemColours) |
This inserts all the browser colours into the palette, and marks all other entries so that they are not used when creating bitmaps. | |
static void | FillWithBrowserColours (LPLOGPALETTE pPalette, INT32 StartIndex) |
Stuffs all the browser colours into the palette provided Also markes each peFlags entry to 0 (i.e. so Gavin will use it). | |
static BOOL | ContainsAllBrowserColours (LPLOGPALETTE pPalette) |
A test to see if the palette contains all the 216 browser palette entries. | |
static LPLOGPALETTE | CreateBrowserPalette (BOOL AvoidSystemColours) |
Creates a palette of browser colours. | |
static void | FindNearestColour (const ColourRGBT &Colour, LPLOGPALETTE pPalette, ColourRGBT *const pResult) |
Finds the closest colour in the given palette. | |
static PALETTEENTRY | FindNearestColour (const PALETTEENTRY &PalColour, LPLOGPALETTE pPalette) |
Finds the closest colour in the given palette. | |
static INT32 | FindIndexOfNearestColour (const PALETTEENTRY &PalColour, LPLOGPALETTE pPalette) |
static double | FindColourDistanceSquared (const PALETTEENTRY *pPal1, const PALETTEENTRY *pPal2) |
Finds the distance between two colours. | |
static void | FindNearestBrowserColour (const ColourRGBT &Colour, ColourRGBT *const pResult) |
Finds the closest colour in the browser palette. | |
static void | SnapToPalette (LPLOGPALETTE pPalette, const LPLOGPALETTE pPaletteToSnapTo) |
This snaps each colour in pPalette to the closest definition in pPaletteToSnapTo. | |
static void | SnapToBrowserPalette (LPLOGPALETTE pPalette) |
This snaps each colour in pPalette to the closest definition in browser palette. | |
static void | PokePaletteEntry (LPLOGPALETTE Palette, INT32 *index, BYTE red, BYTE green, BYTE blue, BYTE Flags=0) |
Puts the required value of rgb into the specified palette entry. | |
static LPLOGPALETTE | Get4bppBrowserPalette (UINT32 ReservedColours) |
This produces a browser compatible 4bpp Palette. | |
static INT32 | FindFirstDontUseColourInPalette (LPLOGPALETTE pPalette) |
This finds the first colour marked as don't use in the specified palette. This colour should correspond to the transparent colour. | |
Static Protected Member Functions | |
static BOOL CALLBACK | InvalidateChildProc (wxWindow *hWnd, LPARAM lParam) |
A callback proc to invalidate child windows if they need to be redrawn as a result of a palette change. | |
static BOOL | IsRedrawOnPaletteChangeRequired (wxWindow *hWnd, BOOL *pNotifyFirst=NULL) |
To respond to InvalidateChildProc. Determines if the given window needs to be redrawn as a result of a palette change. | |
Static Protected Attributes | |
static wxPalette | sm_MainPalette |
static BOOL | sm_bUseMainPalette = FALSE |
static BOOL | m_fPaletteLocked = FALSE |
Definition at line 108 of file palman.h.
|
A test to see if the palette contains all the 216 browser palette entries.
Definition at line 841 of file palman.cpp. 00842 { 00843 for (INT32 r=0;r <= 255;r += 51) 00844 { 00845 BYTE ra = r; 00846 for (INT32 g=0;g <=255;g += 51) 00847 { 00848 BYTE ga = g; 00849 for (INT32 b=0;b <=255;b += 51) 00850 { 00851 BYTE ba = b; 00852 BOOL found = FALSE; 00853 for (INT32 i=0;i<pPalette->palNumEntries;i++) 00854 { 00855 // if peFlags != 255, then it hasn't been marked as "Don't use", so check it 00856 if (pPalette->palPalEntry[i].peFlags != 255) 00857 { 00858 found = pPalette->palPalEntry[i].peRed == ra && 00859 pPalette->palPalEntry[i].peGreen == ga && 00860 pPalette->palPalEntry[i].peBlue == ba; 00861 if ( found ) 00862 break; 00863 } 00864 } 00865 if (!found) 00866 return FALSE; 00867 } 00868 } 00869 } 00870 return TRUE; 00871 }
|
|
Creates a palette of browser colours.
Definition at line 891 of file palman.cpp. 00892 { 00893 LPLOGPALETTE pPalette = NULL; 00894 const size_t TotalPal = sizeof(LOGPALETTE) + ( sizeof(PALETTEENTRY) * 256 ); 00895 pPalette = (LPLOGPALETTE)CCMalloc( TotalPal ); 00896 if (pPalette!= NULL) 00897 { 00898 pPalette->palVersion = 0x300; 00899 pPalette->palNumEntries = 256; 00900 MakePaletteBrowserCompatible(pPalette,AvoidSystemColours); 00901 } 00902 00903 return pPalette; 00904 }
|
|
To respond to WM_QUERYNEWPALETTE and WM_ONPALETTECHANGED Whenever you get one of these messages for youre window, call this method if you want to use the normal GDraw palette. The only splitter in this area to date is the splashbox window.
Notes: Use ForceRedraw = FALSE for WM_QUERYNEWPALETTE, TRUE for WM_ONPALETTECHANGED Definition at line 385 of file palman.cpp. 00386 { 00387 /* GAT 00388 #if DEBUG_PALMAN 00389 TRACE( _T("BOOL PaletteManager::EnsurePalette(HWND hWnd = %d, BOOL ForceRedraw = %d)\n"), 00390 (DWORD)hWnd, ForceRedraw); 00391 #endif 00392 00393 static PALETTEENTRY OldSysPal[256]; 00394 BOOL ForceBackground = m_fPaletteLocked; 00395 00396 static BOOL SelectingPalette = FALSE; 00397 00398 // This code may well look a bit odd but it is necessary to prevent reentrancy problems 00399 BOOL CheckPalette = !SelectingPalette; 00400 00401 #ifdef RALPH 00402 if(!RalphDocument::ForegroundPalette) 00403 ForceBackground = TRUE; 00404 #endif 00405 00406 // This "event" is directed at the application as a whole but the palette we set up is 00407 // always associated with the Selected DocView and so we'll set Current to Selected... 00408 if (Document::GetSelected != NULL) 00409 Document::GetSelected()->SetCurrent(); 00410 00411 if (DocView::GetSelected() != NULL) 00412 DocView::GetSelected()->SetCurrent(); 00413 00414 if (!UsePalette()) // We don't use a special palette, so do nothing 00415 return(FALSE); 00416 00417 // This check (to stop us changing the palette when minimised) has been removed (Jason - 26/7/95) 00418 // The reason for this is: 00419 // (a) This is contrary to microsoft coding guidelines, 00420 // (b) If you restore camelot from minimised state, it fails to realise its palette! 00421 // (c) The behaviour is now "correct" and exactly the same as all other apps 00422 // 00423 // if (MainFrame->IsIconic()) // We are currently in an iconised state, so do nothing 00424 // return(FALSE); 00425 00426 SelectingPalette = TRUE; 00427 00428 HDC hDC = ::GetDC(hWnd); 00429 00430 // We need to check that the palette actully has changed 00431 // because RealizePalette() will say that 256 colours have changed 00432 // if you close the help file on NT4/95 00433 00434 PALETTEENTRY NewSysPal[256]; 00435 00436 HPALETTE OldPal = ::SelectPalette(hDC, sm_MainPalette, ForceBackground); 00437 UINT32 NumColoursChanged = ::RealizePalette(hDC); 00438 ::SelectPalette(hDC, OldPal, TRUE); 00439 ::RealizePalette(hDC); 00440 00441 GetSystemPaletteEntries(hDC, 0, 256, NewSysPal); 00442 00443 ::ReleaseDC(hWnd, hDC); 00444 00445 SelectingPalette = FALSE; 00446 00447 if (CheckPalette) 00448 { 00449 for (DWORD Index = 0; Index < 256; Index++) 00450 NewSysPal[Index].peFlags = 0; 00451 00452 // If the palette has really changed 00453 if (memcmp(NewSysPal, OldSysPal, sizeof(PALETTEENTRY) * 256) != 0) 00454 { 00455 // TRACEUSER( "Gerry", _T("Palette has actually changed\n")); 00456 // Update the old palette 00457 memcpy(OldSysPal, NewSysPal, sizeof(PALETTEENTRY) * 256); 00458 00459 // TRACEUSER( "Gerry", _T("Cols changed %d\n"), NumColoursChanged); 00460 00461 // Only set the flag if the OS thinks the palette has changed 00462 if (NumColoursChanged != 0) 00463 ForceRedraw = TRUE; 00464 } 00465 // else 00466 // { 00467 // TRACEUSER( "Gerry", _T("Palette not actually changed\n")); 00468 // } 00469 } 00470 // else 00471 // { 00472 // TRACEUSER( "Gerry", _T("Not checking palette\n")); 00473 // } 00474 00475 if (ForceRedraw) 00476 { 00477 // TRACEUSER( "Gerry", _T("Forcing redraw\n")); 00478 GRenderRegion::GColInit(NULL, TRUE); // tell GDraw of new palette 00479 RedrawAllPalettedWindows(hWnd); // And redraw everything 00480 } 00481 00482 // This used to return the commented out line below but was changed 00483 // to help fix a problem with the help file 00484 00485 // return(NumColoursChanged != 0); 00486 */ return(TRUE); 00487 }
|
|
Stuffs all the browser colours into the palette provided Also markes each peFlags entry to 0 (i.e. so Gavin will use it).
Definition at line 798 of file palman.cpp. 00799 { 00800 ERROR3IF(pPalette == NULL,"NULL Entry param"); 00801 if (pPalette == NULL) 00802 return; 00803 00804 INT32 i = StartIndex; 00805 00806 // Generate the entire browser palette 00807 for (INT32 r=0;r <= 255;r += 51) 00808 { 00809 for (INT32 g=0;g <=255;g += 51) 00810 { 00811 for (INT32 b=0;b <=255;b += 51) 00812 { 00813 if (i < pPalette->palNumEntries) // Extra safety check 00814 { 00815 pPalette->palPalEntry[i].peRed = r; 00816 pPalette->palPalEntry[i].peGreen = g; 00817 pPalette->palPalEntry[i].peBlue = b; 00818 pPalette->palPalEntry[i].peFlags = 0; // Mark as "Use this colour if you want" 00819 } 00820 00821 i++; // Next entry please 00822 } 00823 } 00824 } 00825 }
|
|
Finds the distance between two colours.
Definition at line 1057 of file palman.cpp. 01058 { 01059 ERROR2IF(pPal1 == NULL || pPal2 == NULL,0.0,"NULL pal entry pointer"); 01060 01061 double dr = double(pPal1->peRed - pPal2->peRed ); 01062 double dg = double(pPal1->peGreen - pPal2->peGreen); 01063 double db = double(pPal1->peBlue - pPal2->peBlue ); 01064 01065 return dr*dr+dg*dg+db*db ; 01066 }
|
|
This finds the first colour marked as don't use in the specified palette. This colour should correspond to the transparent colour.
Definition at line 1276 of file palman.cpp. 01277 { 01278 ERROR2IF(pPalette == NULL,-1,"FindFirstDontUseColourInPalette Bad palette"); 01279 01280 UINT32 colours = pPalette->palNumEntries; 01281 INT32 DontUseColour = -1; 01282 PALETTEENTRY * pPaletteEntry = pPalette->palPalEntry; 01283 for (UINT32 i = 0; (i < colours) && (DontUseColour == -1); i++) 01284 { 01285 if (pPaletteEntry[i].peFlags == 0xFF) 01286 DontUseColour = i; 01287 } 01288 01289 return DontUseColour; 01290 }
|
|
Definition at line 1005 of file palman.cpp. 01006 { 01007 // PALETTEENTRY Dummy = {0,0,0,0}; 01008 01009 double SmallestDistance = 0.0; 01010 BOOL FirstDistanceCalc = TRUE; 01011 INT32 ClosestColourIndex = 0; 01012 01013 // look at all the colours in the palette 01014 for (INT32 i=0;i<pPalette->palNumEntries;i++) 01015 { 01016 // If the peFlags is 0, then it's not been marked as "ignore", so look at it 01017 if (pPalette->palPalEntry[i].peFlags == 0) 01018 { 01019 // Get the distance between the colour and this palette entry 01020 double d = FindColourDistanceSquared(&PalColour, &(pPalette->palPalEntry[i])); 01021 01022 if (FirstDistanceCalc) 01023 { 01024 // First time around, so 'd' must be closest yet 01025 FirstDistanceCalc = FALSE; 01026 SmallestDistance = d; 01027 ClosestColourIndex = i; 01028 } 01029 else if (d < SmallestDistance) 01030 { 01031 // Smallest distance so far? if so remember the distance & index 01032 SmallestDistance = d; 01033 ClosestColourIndex = i; 01034 } 01035 } 01036 } 01037 01038 // Return the closest palette entry 01039 return ClosestColourIndex; 01040 }
|
|
Finds the closest colour in the browser palette.
Definition at line 1086 of file palman.cpp. 01087 { 01088 ERROR3IF(pResult == NULL,"NULL pResult pointer"); 01089 if (pResult == NULL) 01090 return; 01091 01092 LPLOGPALETTE pBrowserPalette = PaletteManager::CreateBrowserPalette(FALSE); 01093 if (pBrowserPalette != NULL) 01094 { 01095 FindNearestColour(Colour,pBrowserPalette,pResult); 01096 CCFree(pBrowserPalette); 01097 } 01098 }
|
|
Finds the closest colour in the given palette.
Definition at line 964 of file palman.cpp. 00965 { 00966 PALETTEENTRY Dummy = {0,0,0,0}; 00967 ERROR2IF(pPalette == NULL,Dummy,"NULL Palette ptr"); 00968 ERROR2IF(pPalette->palNumEntries < 1,Dummy,"No Palette entries"); 00969 00970 double SmallestDistance = 0.0; 00971 BOOL FirstDistanceCalc = TRUE; 00972 INT32 ClosestColourIndex = 0; 00973 00974 // look at all the colours in the palette 00975 for (INT32 i=0;i<pPalette->palNumEntries;i++) 00976 { 00977 // If the peFlags is 0, then it's not been marked as "ignore", so look at it 00978 if (pPalette->palPalEntry[i].peFlags == 0) 00979 { 00980 // Get the distance between the colour and this palette entry 00981 double d = FindColourDistanceSquared(&PalColour, &(pPalette->palPalEntry[i])); 00982 00983 if (FirstDistanceCalc) 00984 { 00985 // First time around, so 'd' must be closest yet 00986 FirstDistanceCalc = FALSE; 00987 SmallestDistance = d; 00988 ClosestColourIndex = i; 00989 } 00990 else if (d < SmallestDistance) 00991 { 00992 // Smallest distance so far? if so remember the distance & index 00993 SmallestDistance = d; 00994 ClosestColourIndex = i; 00995 } 00996 } 00997 } 00998 00999 // Return the closest palette entry 01000 return (pPalette->palPalEntry[ClosestColourIndex]); 01001 }
|
|
Finds the closest colour in the given palette.
Definition at line 925 of file palman.cpp. 00926 { 00927 ERROR3IF(pResult == NULL,"NULL pResult pointer"); 00928 if (pResult == NULL) 00929 return; 00930 00931 // Convert original colour into an RGB palette entry 00932 PALETTEENTRY PalColour; 00933 PalColour.peRed = BYTE(Colour.Red.MakeDouble()*255); 00934 PalColour.peGreen = BYTE(Colour.Green.MakeDouble()*255); 00935 PalColour.peBlue = BYTE(Colour.Blue.MakeDouble()*255); 00936 00937 // Find the closest palette entry 00938 PALETTEENTRY ClosestPalColour = FindNearestColour(PalColour,pPalette); 00939 00940 // Convert back to a ColourRGBT 00941 pResult->Red = FIXED24(double(ClosestPalColour.peRed)/255.0); 00942 pResult->Green = FIXED24(double(ClosestPalColour.peGreen)/255.0); 00943 pResult->Blue = FIXED24(double(ClosestPalColour.peBlue)/255.0); 00944 }
|
|
This produces a browser compatible 4bpp Palette.
Definition at line 1217 of file palman.cpp. 01218 { 01219 ERROR3IF(ReservedColours > 15,"Bad number of reserved colours"); 01220 01221 LPLOGPALETTE pPalette = DIBUtil::AllocateLogPalette(16); 01222 if (pPalette == NULL) 01223 return NULL; 01224 01225 INT32 i = 0; 01226 // Gavin uses a fixed 16 colour palette 01227 // Usually we use a half intensity value, instead we need to snap it to either 01228 // 40% (102) or 60% (153) to be browser compatible 01229 // Define a constant so its easy to change this snapped half intensity value 01230 const BYTE Shiv = 153; 01231 // We shall just use a browser snapped version of this 01232 PokePaletteEntry(pPalette, &i, 0x00, 0x00, 0x00); // black 01233 PokePaletteEntry(pPalette, &i, Shiv, 0x00, 0x00); // brown 01234 PokePaletteEntry(pPalette, &i, 0x00, Shiv, 0x00); // Half green 01235 PokePaletteEntry(pPalette, &i, Shiv, Shiv, 0x00); // Half browny (red/green) 01236 PokePaletteEntry(pPalette, &i, 0x00, 0x00, Shiv); // Dark blue 01237 PokePaletteEntry(pPalette, &i, Shiv, 0x00, Shiv); // Mauve 01238 PokePaletteEntry(pPalette, &i, 0x00, Shiv, Shiv); // greeny/blue 01239 PokePaletteEntry(pPalette, &i, Shiv, Shiv, Shiv); // mid grey 01240 01241 PokePaletteEntry(pPalette, &i, 0xcc, 0xcc, 0xcc); // light grey from 196 to 204 01242 PokePaletteEntry(pPalette, &i, 0xff, 0x00, 0x00); // red 01243 PokePaletteEntry(pPalette, &i, 0x00, 0xff, 0x00); // green 01244 PokePaletteEntry(pPalette, &i, 0xff, 0xff, 0x00); // yellow 01245 PokePaletteEntry(pPalette, &i, 0x00, 0x00, 0xff); // blue 01246 PokePaletteEntry(pPalette, &i, 0xff, 0x00, 0xff); // magenta 01247 PokePaletteEntry(pPalette, &i, 0x00, 0xff, 0xff); // cyan 01248 PokePaletteEntry(pPalette, &i, 0xff, 0xff, 0xff); // white 01249 01250 /* if (ReservedColours > 0) 01251 { 01252 // Used to pick index 10 to be transparent but now we pick the light grey 01253 i = 8; 01254 PokePaletteEntry(pPalette, &i, 0xFF, 0xFF, 0xFF, 0xFF); // don't use white 01255 01256 // Warn if we try to pick more than 1 reserved colour 01257 ERROR3IF(ReservedColours > 1,"Get4bppBrowserPalette We can only cope with 1 reserved colour"); 01258 } */ 01259 01260 return pPalette; 01261 }
|
|
Definition at line 140 of file palman.h. 00141 { 00142 return(sm_bUseMainPalette ? &sm_MainPalette : NULL); 00143 }
|
|
Initialises the palette manager.
Definition at line 139 of file palman.cpp. 00140 { 00141 #if DEBUG_PALMAN 00142 TRACE( _T("BOOL PaletteManager::Init(void)\n")); 00143 #endif 00144 UpdatePalette(); 00145 00146 return(TRUE); 00147 }
|
|
A callback proc to invalidate child windows if they need to be redrawn as a result of a palette change.
Definition at line 200 of file palman.cpp. 00201 { 00202 /* GAT 00203 #if DEBUG_PALMAN 00204 TRACE( _T("BOOL CALLBACK PaletteManager::InvalidateChildProc(HWND hWnd = %d, LPARAM lParam = %d)\n"), 00205 (DWORD)hWnd, (DWORD)lParam); 00206 #endif 00207 BOOL bNotify = FALSE; 00208 if (PaletteManager::IsRedrawOnPaletteChangeRequired(hWnd, &bNotify)) 00209 { 00210 if (bNotify) 00211 SendMessage(hWnd, WM_CAM_PALETTECHANGE, 0, 0); 00212 00213 ::InvalidateRect(hWnd, NULL, TRUE); 00214 } 00215 */ 00216 return(TRUE); 00217 }
|
|
To respond to InvalidateChildProc. Determines if the given window needs to be redrawn as a result of a palette change.
Definition at line 277 of file palman.cpp. 00278 { 00279 return FALSE; 00280 /* GAT 00281 #if DEBUG_PALMAN 00282 TRACE( _T("BOOL PaletteManager::IsRedrawOnPaletteChangeRequired(HWND hWnd = %d)\n"), (DWORD)hWnd); 00283 #endif 00284 00285 if (pNotifyFirst) 00286 *pNotifyFirst = FALSE; 00287 00288 #ifdef RALPH 00289 // Nasty Ralph bodge to get the palette working sensibly 00290 return(TRUE); 00291 00292 #else 00293 00294 // First see if it is an MFC Window 00295 // Well this does some of it 00296 CWnd* pCWnd = CWnd::FromHandlePermanent(hWnd); 00297 00298 // don't redraw it then 00299 // Note we keep its children separately 00300 #ifndef STANDALONE 00301 if (pCWnd) 00302 { 00303 if (pCWnd->IsKindOf(RUNTIME_CLASS(CColourBar)) || // Redraw the colour bar 00304 pCWnd->IsKindOf(RUNTIME_CLASS(CRenderWnd))) // and the view windows 00305 { 00306 return TRUE; 00307 } 00308 00309 return FALSE; 00310 } 00311 #else 00312 if (pCWnd) 00313 { 00314 if (pCWnd->IsKindOf(RUNTIME_CLASS(CRenderWnd))) // Redraw the view windows 00315 return TRUE; 00316 00317 return FALSE; 00318 } 00319 #endif 00320 00321 // OK, it's not an MFC window 00322 String_256 ClassNameStr; // The control type 00323 00324 // Find out the class type of the gadget 00325 GetClassName(hWnd, (TCHAR*)ClassNameStr, 255); 00326 if ((ClassNameStr == String_16(TEXT("cc_DialogDraw")))) 00327 return TRUE; 00328 00329 if ((ClassNameStr == String_16(TEXT("cc_BitmapButton")))) 00330 { 00331 if (pNotifyFirst) 00332 *pNotifyFirst = TRUE; 00333 return TRUE; 00334 } 00335 00336 if ((ClassNameStr == String_16(TEXT("cc_SmallButton")))) 00337 { 00338 if (pNotifyFirst) 00339 *pNotifyFirst = TRUE; 00340 return TRUE; 00341 } 00342 00343 if ((ClassNameStr == String_16(TEXT("cc_StaticBitmap")))) 00344 { 00345 if (pNotifyFirst) 00346 *pNotifyFirst = TRUE; 00347 return TRUE; 00348 } 00349 00350 return FALSE; 00351 00352 #endif 00353 */ 00354 }
|
|
"Locks" or "unlocks" the palette, preventing or allowing palette changes due to window repaints. Ultra-bodge way of preventing splash-box palette flash during workspace restoration.
Definition at line 170 of file palman.cpp. 00171 { 00172 #if DEBUG_PALMAN 00173 TRACE( _T("void PaletteManager::LockPalette(BOOL fLocked = %d)\n"), fLocked); 00174 #endif 00175 m_fPaletteLocked = fLocked; 00176 }
|
|
This inserts all the browser colours into the palette, and marks all other entries so that they are not used when creating bitmaps.
if AvoidSystemColours is TRUE, the system colour palette entries are marked as "don't use" Introduced for Webster. Modified heavily for Webster v2 by Markn 20/6/97
Definition at line 742 of file palman.cpp. 00743 { 00744 if (pPalette == NULL) 00745 { 00746 ERROR3("Null palette ptr"); 00747 return; 00748 } 00749 00750 if (pPalette->palNumEntries != 256) 00751 { 00752 ERROR3("Only suitable for 8bpp 256 entry palettes"); 00753 return; 00754 } 00755 00756 // Set all entries to be "Don't use" 00757 INT32 i; 00758 for (i = 0; i < pPalette->palNumEntries;i++) 00759 { 00760 pPalette->palPalEntry[i].peRed = 0; 00761 pPalette->palPalEntry[i].peGreen = 0; 00762 pPalette->palPalEntry[i].peBlue = 0; 00763 pPalette->palPalEntry[i].peFlags = 255; 00764 } 00765 00766 // If system colours entries are to be avoided, start from the first non-system colour entry (index value 11) 00767 if (AvoidSystemColours) 00768 i = 11; // 11 in case the bitmap is transparent, in which case index 10 will hold the transparent colour 00769 else 00770 i = 1; // 1 in case the bitmap is transparent, in which case index 0 will hold the transparent colour 00771 00772 // Fill it with the browser colours 00773 PaletteManager::FillWithBrowserColours(pPalette,i); 00774 00775 // Debug sanity check 00776 #ifdef _DEBUG 00777 TRACE( _T("Checking 216 colours\n")); 00778 if (!ContainsAllBrowserColours(pPalette)) 00779 ERROR3("Do what! Some browser colours are missing!"); 00780 #endif 00781 }
|
|
Puts the required value of rgb into the specified palette entry.
Definition at line 1190 of file palman.cpp. 01192 { 01193 ERROR3IF(Palette == NULL || index == NULL,"PaletteManager::PokePaletteEntry bad params"); 01194 if (Palette == NULL || index == NULL) 01195 return; 01196 01197 Palette->palPalEntry[*index].peRed = red; 01198 Palette->palPalEntry[*index].peGreen = green; 01199 Palette->palPalEntry[*index].peBlue = blue; 01200 Palette->palPalEntry[*index].peFlags = 0; 01201 // increment the counter and return it 01202 (*index) ++; 01203 }
|
|
To redraw the given window (and all children) that are reliant upon 256- colour palettes. Usually called with NULL to just redraw the MainFrame.
Definition at line 235 of file palman.cpp. 00236 { 00237 /* GAT 00238 #if DEBUG_PALMAN 00239 TRACE( _T("void PaletteManager::RedrawAllPalettedWindows(HWND hWnd = %d)\n"), (DWORD)hWnd); 00240 #endif 00241 if (hWnd == NULL) 00242 { 00243 CMainFrame *MainFrame = GetMainFrame(); 00244 if (MainFrame != NULL) 00245 hWnd = MainFrame->m_hWnd; 00246 } 00247 00248 if (hWnd != NULL) 00249 { 00250 if (IsRedrawOnPaletteChangeRequired(hWnd)) 00251 ::InvalidateRect(hWnd, NULL, TRUE); // And redraw everything if necessary 00252 00253 EnumChildWindows(hWnd, InvalidateChildProc, 0); // And redraw all children which need it 00254 } 00255 */ 00256 }
|
|
This snaps each colour in pPalette to the closest definition in browser palette.
Definition at line 1158 of file palman.cpp. 01159 { 01160 ERROR3IF(pPalette == NULL,"NULL pPalette pointer"); 01161 if (pPalette == NULL) 01162 return; 01163 01164 LPLOGPALETTE pBrowserPalette = PaletteManager::CreateBrowserPalette(FALSE); 01165 if (pBrowserPalette != NULL) 01166 { 01167 SnapToPalette(pPalette,pBrowserPalette); 01168 CCFree(pBrowserPalette); 01169 } 01170 }
|
|
This snaps each colour in pPalette to the closest definition in pPaletteToSnapTo.
Definition at line 1119 of file palman.cpp. 01120 { 01121 ERROR3IF(pPalette == NULL || pPaletteToSnapTo == NULL,"NULL pal pointer"); 01122 if (pPalette == NULL || pPaletteToSnapTo == NULL) 01123 return; 01124 01125 // look at all the colours in the palette 01126 for (INT32 i=0;i<pPalette->palNumEntries;i++) 01127 { 01128 // Get the next pal entry 01129 PALETTEENTRY PalEntry = pPalette->palPalEntry[i]; 01130 01131 // Find the closest pal entry in the palette to snap to 01132 PALETTEENTRY NearestPalEntry = FindNearestColour(PalEntry, pPaletteToSnapTo); 01133 01134 // Set the pal entry to the nearest colour 01135 pPalette->palPalEntry[i] = NearestPalEntry; 01136 } 01137 }
|
|
To select and realise the mainframe GDraw palette before painting Scope: Static public.
HPal = palette to use (3 only)
Definition at line 556 of file palman.cpp. 00557 { 00558 #if 1 // GAT 00559 return NULL; 00560 #else 00561 #if DEBUG_PALMAN 00562 TRACE( _T("HPALETTE PaletteManager::StartPaintPalette(HDC hDC = %d, HPALETTE *pHPal = %d, BOOL bForceBackground = %d)\n"), 00563 (DWORD)hDC, (DWORD)pHPal, bForceBackground); 00564 #endif 00565 ERROR2IF(!hDC, NULL, "PaletteManager passed NULL DC"); 00566 00567 #ifdef RALPH 00568 if(!RalphDocument::ForegroundPalette) 00569 bForceBackground = TRUE; 00570 #endif 00571 00572 if (!(::GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE)) 00573 return(NULL); 00574 00575 HPALETTE NewPalette = sm_MainPalette; // Sneaky HPALETTE operator 00576 if (pHPal) 00577 *pHPal = NewPalette; 00578 00579 if (m_fPaletteLocked) 00580 bForceBackground = TRUE; 00581 00582 HPALETTE OldPalette = ::SelectPalette(hDC, NewPalette, bForceBackground); 00583 ::RealizePalette(hDC); 00584 00585 return OldPalette; 00586 #endif 00587 }
|
|
To restore the palette after painting, using the palette returned to you by StartPaintPalette.
bForceBackground = value to pass to the forcebackground param in SelectPalette It's not expected that this will ever be anything other than TRUE
Definition at line 650 of file palman.cpp. 00651 { 00652 #if DEBUG_PALMAN 00653 TRACE( _T("CPalette *PaletteManager::StopPaintPalette(CDC *RenderDC = %d, CPalette *OldPalette = %d, BOOL bForceBackground = %d)\n"), 00654 (DWORD)RenderDC, (DWORD)OldPalette, bForceBackground); 00655 #endif 00656 ERROR2IF (!RenderDC, NULL, "PaletteManager passed NULL RenderRC"); 00657 // GAT 00658 // if (!(RenderDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE)) 00659 return(NULL); 00660 /* 00661 if (m_fPaletteLocked) 00662 bForceBackground = TRUE; 00663 00664 CPalette *PrevPalette = RenderDC->SelectPalette(OldPalette, bForceBackground); 00665 RenderDC->RealizePalette(); 00666 00667 return PrevPalette; 00668 */ 00669 }
|
|
Sets up the static main frame palette This will be called whenever the palette needs updating.
Definition at line 684 of file palman.cpp. 00685 { 00686 /* GAT 00687 #if DEBUG_PALMAN 00688 TRACE( _T("void PaletteManager::UpdatePalette(void)\n")); 00689 #endif 00690 00691 HPALETTE hPal = (HPALETTE) sm_MainPalette.Detach(); // Detach the palette object 00692 00693 if (hPal != NULL) 00694 { 00695 ::DeleteObject(hPal); 00696 hPal = NULL; 00697 } 00698 00699 sm_bUseMainPalette = FALSE; 00700 00701 LPLOGPALETTE lpPal = (LPLOGPALETTE)GRenderRegion::GetRecommendedPalette(); 00702 00703 if (lpPal) 00704 { 00705 TRACEUSER( "Gerry", _T("Got a palette in PaletteManager::UpdatePalette()\n")); 00706 00707 // Gavin's palette has 10 unused entries at the front and 10 at the back, which 00708 // is dead handy indeed 00709 hPal = DIBUtil::MakeIdentityPalette( lpPal->palPalEntry, 256 ); 00710 if (hPal) 00711 { 00712 sm_bUseMainPalette = sm_MainPalette.Attach(hPal); 00713 } 00714 } 00715 */ 00716 }
|
|
Definition at line 131 of file palman.h. 00132 { 00133 return(sm_bUseMainPalette); 00134 };
|
|
|
|
|
|
|