#include <bmpalctrl.h>
Inheritance diagram for BitmapExportPaletteControl:
Definition at line 125 of file bmpalctrl.h.
|
Definition at line 150 of file bmpalctrl.h. 00150 { 00151 INVALID_COLOUR_VALUE = -1 // A value that can never be a colour index 00152 };
|
|
Definition at line 129 of file bmpalctrl.cpp. 00130 : m_MouseOverCell(INVALID_COLOUR_VALUE /* Set to none */) 00131 , m_SelectedCell(INVALID_COLOUR_VALUE /* Set to none */) 00132 , m_WindowID(0) 00133 , m_nPixelSize(72000 / GRenderRegion::GetDefaultDPI()) 00134 , m_nCellWidthPixels(11) 00135 , m_nCellHeightPixels(11) 00136 , m_nCellWidth(m_nPixelSize * m_nCellHeightPixels) 00137 , m_nCellHeight(m_nPixelSize * m_nCellHeightPixels) 00138 , m_nCellsPerLine(30) 00139 , m_NumberOfColoursAtLastRedraw(0) 00140 { 00141 }
|
|
Definition at line 143 of file bmpalctrl.cpp.
|
|
|
|
Definition at line 578 of file bmpalctrl.cpp. 00580 { 00581 pRender->SetLineColour(COLOUR_BLACK); 00582 pRender->SetFillColour(colour); 00583 pRender->DrawRect(pCellRect); 00584 00585 if (selected) 00586 { 00587 pRender->SetFillColour(COLOUR_TRANS); 00588 00589 DocRect cell = *pCellRect; // make temp copy 00590 00591 // Draw the outer line in white 00592 pRender->SetLineColour(COLOUR_WHITE); 00593 cell.Inflate(-1 * m_nPixelSize); 00594 pRender->DrawRect(&cell); 00595 00596 // Draw the inner line in black 00597 pRender->SetLineColour(COLOUR_BLACK); 00598 cell.Inflate(-1 * m_nPixelSize); 00599 pRender->DrawRect(&cell); 00600 } 00601 00602 if (flags & DELETED_COLOUR) 00603 { 00604 // Draw a mark to show that this palette entry has been deleted 00605 00606 // Draw a black line from top left to bottom right 00607 pRender->SetLineColour(COLOUR_BLACK); 00608 pRender->DrawLine( DocCoord(pCellRect->lo.x, pCellRect->hi.y + m_nPixelSize), 00609 DocCoord(pCellRect->hi.x + m_nPixelSize, pCellRect->lo.y)); 00610 00611 // Draw a white line from top right to bottom left 00612 pRender->SetLineColour(COLOUR_WHITE); 00613 pRender->DrawLine( DocCoord(pCellRect->hi.x + m_nPixelSize, pCellRect->hi.y + m_nPixelSize), 00614 DocCoord(pCellRect->lo.x + m_nPixelSize, pCellRect->lo.y + m_nPixelSize)); 00615 00616 return; // Stop before rending any other marks 00617 } 00618 00619 if (flags & LOCKED_COLOUR) 00620 { 00621 // Draw a mark to show that this palette entry has been 00622 // edited by the user. 00623 00624 pRender->SetLineColour(COLOUR_BLACK); 00625 pRender->SetFillColour(COLOUR_WHITE); 00626 00627 // Draw a rectangle in the bottom left corner of the cell 00628 DocRect markRect; 00629 markRect.hi.x = pCellRect->lo.x + m_nPixelSize * 2; 00630 markRect.lo.x = pCellRect->lo.x; 00631 markRect.hi.y = pCellRect->lo.y + m_nPixelSize * 2; 00632 markRect.lo.y = pCellRect->lo.y; 00633 pRender->DrawRect(&markRect); 00634 } 00635 00636 if (flags & TRANSPARENT_COLOUR) 00637 { 00638 // Draw a mark to show that this palette entry is transparent 00639 00640 pRender->SetLineColour(COLOUR_BLACK); 00641 pRender->SetFillColour(COLOUR_WHITE); 00642 00643 // Draw a rectangle in the top left corner of the cell 00644 DocRect markRect; 00645 markRect.hi.x = pCellRect->lo.x + m_nPixelSize * 2; 00646 markRect.lo.x = pCellRect->lo.x; 00647 markRect.hi.y = pCellRect->hi.y; 00648 markRect.lo.y = pCellRect->hi.y - m_nPixelSize * 2; 00649 pRender->DrawRect(&markRect); 00650 } 00651 00652 if (webSafe) 00653 { 00654 // Draw a mark to show that this palette entry is web-safe 00655 00656 pRender->SetLineColour(COLOUR_BLACK); 00657 pRender->SetFillColour(COLOUR_WHITE); 00658 00659 DocRect markRect = *pCellRect; 00660 markRect.Inflate(-4 * m_nPixelSize); 00661 pRender->DrawRect(&markRect); 00662 } 00663 }
|
|
Definition at line 177 of file bmpalctrl.cpp. 00178 { 00179 INT32 cellX = x / m_nCellWidthPixels; // zero based 00180 00181 INT32 cellY = y / m_nCellHeightPixels; // zero based 00182 00183 INT32 cell = (m_nCellsPerLine * cellY) + cellX; 00184 00185 if (cell >= m_Palette.GetNumberOfColours() || cellX >= m_nCellsPerLine) 00186 return INVALID_COLOUR_VALUE; 00187 else 00188 return cell; 00189 }
|
|
Definition at line 165 of file bmpalctrl.cpp. 00166 { 00167 return m_Palette.GetPaletteSortType(); 00168 }
|
|
Definition at line 533 of file bmpalctrl.cpp. 00534 { 00535 return m_Palette.SortedValueToRealValue(m_MouseOverCell); 00536 }
|
|
Definition at line 409 of file bmpalctrl.cpp. 00410 { 00411 pRect->lo.x = (cell % m_nCellsPerLine) * m_nCellWidth; 00412 pRect->lo.y = controlHeight - (cell / m_nCellsPerLine) * m_nCellHeight - m_nCellHeight; 00413 pRect->hi.x = (cell % m_nCellsPerLine + 1) * m_nCellWidth - m_nPixelSize; 00414 pRect->hi.y = controlHeight - (cell / m_nCellsPerLine) * m_nCellHeight - m_nPixelSize; 00415 }
|
|
Definition at line 528 of file bmpalctrl.cpp. 00529 { 00530 return m_Palette.SortedValueToRealValue(m_SelectedCell); 00531 }
|
|
Definition at line 560 of file bmpalctrl.cpp. 00561 { 00562 return ((m_Palette.GetFlags(m_SelectedCell) & DELETED_COLOUR) != 0); 00563 }
|
|
Definition at line 538 of file bmpalctrl.cpp. 00539 { 00540 return ((m_Palette.GetFlags(m_SelectedCell) & LOCKED_COLOUR) != 0); 00541 }
|
|
Definition at line 555 of file bmpalctrl.cpp. 00556 { 00557 return ((m_Palette.GetFlags(m_SelectedCell) & TRANSPARENT_COLOUR) != 0); 00558 }
|
|
Definition at line 548 of file bmpalctrl.cpp. 00549 { 00550 return IsColourWebSafe( m_Palette.GetRed(m_SelectedCell), 00551 m_Palette.GetGreen(m_SelectedCell), 00552 m_Palette.GetBlue(m_SelectedCell)); 00553 }
|
|
Definition at line 157 of file bmpalctrl.h. 00157 { m_WindowID = wid; };
|
|
Definition at line 254 of file bmpalctrl.cpp. 00255 { 00256 DocRect cellRect; 00257 ERROR3IF(!m_WindowID, "Window ID not set"); 00258 00259 GetRectForCell(paletteIndex, &cellRect, pInfo->dy); 00260 00261 // Add the bodge factor 00262 cellRect.lo.y -= m_nPixelSize; 00263 cellRect.hi.y += m_nPixelSize; 00264 cellRect.hi.x += m_nPixelSize * 2; 00265 00266 DialogManager::InvalidateGadget(m_WindowID, _R(IDC_T2_PALETTE_CONTROL), pInfo, &cellRect); 00267 }
|
|
Definition at line 543 of file bmpalctrl.cpp.
|
|
Definition at line 472 of file bmpalctrl.cpp. 00473 { 00474 if (*pColour % 51 != 0) 00475 { 00476 if (*pColour % 51 > 20) 00477 // round up to nearest multiple of 51 00478 *pColour += (51 - *pColour % 51); 00479 else 00480 // round down to nearest multiple of 51 00481 *pColour -= *pColour % 51; 00482 } 00483 }
|
|
Definition at line 206 of file bmpalctrl.cpp. 00207 { 00208 ERROR3IF(!m_WindowID, "Window ID not set"); 00209 00210 INT32 cell = GetCellFromPos(pInfo->pMousePos->x / m_nPixelSize, (pInfo->dy - pInfo->pMousePos->y) / m_nPixelSize); 00211 00212 return SetSelectedCellFromSortedIndex(pInfo, cell); 00213 }
|
|
Definition at line 191 of file bmpalctrl.cpp. 00192 { 00193 INT32 cell = GetCellFromPos(pInfo->pMousePos->x / m_nPixelSize, (pInfo->dy - pInfo->pMousePos->y) / m_nPixelSize); 00194 00195 SetHighlightedCellFromSortedIndex(pInfo, cell); 00196 }
|
|
Definition at line 221 of file bmpalctrl.cpp. 00222 { 00223 MsgMouseLeftButtonDown(pInfo); 00224 00225 if (m_SelectedCell == INVALID_COLOUR_VALUE) 00226 return; 00227 00228 // User has right-clicked on the palette control. So, we have 00229 // to construct and display the right-click palette menu. 00230 OpPalettePopupCommand::Init(this, pBmapPrevDlg); 00231 00232 PaletteContextMenu* Menu = new PaletteContextMenu; 00233 00234 // If everything is OK, then show the menu. 00235 if( Menu != NULL ) 00236 Menu->Show(); 00237 else 00238 ERROR3( "Can't create PaletteContextMenu" ); 00239 }
|
|
Definition at line 249 of file bmpalctrl.cpp. 00250 { 00251 InvalidateCell(pInfo, m_SelectedCell); 00252 }
|
|
Definition at line 365 of file bmpalctrl.cpp. 00366 { 00367 DocRect PaletteSize(0, 0, pInfo->dx, pInfo->dy); 00368 00369 // Create a RenderRegion so that we can draw the control 00370 RenderRegion *pRender = CreateOSRenderRegion(&PaletteSize, pInfo); 00371 if (pRender == 0) 00372 return; // Could not create a RenderRegion 00373 00374 // Decide if we are going to render the palette 00375 if (!m_Palette.GetNumberOfColours()) 00376 { 00377 // We are not rendering a palette so just draw a grey box 00378 RenderGrey(&PaletteSize, pRender); 00379 } 00380 else 00381 { 00382 // Check the selection and mouse over colour are valid 00383 if (m_SelectedCell > m_Palette.GetNumberOfColours()) 00384 m_SelectedCell = INVALID_COLOUR_VALUE; 00385 if (m_MouseOverCell > m_Palette.GetNumberOfColours()) 00386 m_MouseOverCell = INVALID_COLOUR_VALUE; 00387 00388 // We are rendering a full palette 00389 RenderPalette(&PaletteSize, pRender, pInfo->dy, pInfo->pClipRect); 00390 } 00391 00392 DestroyOSRenderRegion(pRender); 00393 }
|
|
Definition at line 401 of file bmpalctrl.cpp. 00402 { 00403 DialogColourInfo DialogColours; 00404 pRender->SetFillColour(DialogColours.DialogBack()); 00405 pRender->SetLineColour(COLOUR_TRANS); 00406 pRender->DrawRect(pPaletteSize); 00407 }
|
|
Definition at line 417 of file bmpalctrl.cpp. 00419 { 00420 INT32 nColours = m_Palette.GetNumberOfColours(); 00421 00422 // See if the background needs rendering 00423 if (nColours < m_NumberOfColoursAtLastRedraw) 00424 RenderGrey(pPaletteSize, pRender); 00425 00426 m_NumberOfColoursAtLastRedraw = nColours; 00427 00428 pRender->SetLineColour(COLOUR_BLACK); 00429 00430 DocRect cell; 00431 00432 // Draw each cell in turn 00433 for (INT32 i = 0; i < nColours; ++i) 00434 { 00435 GetRectForCell(i, &cell, controlHeight); 00436 if (cell.IsIntersectedWith(*pClipRect)) 00437 { 00438 BYTE r, g, b; 00439 r = m_Palette.GetRed(i); 00440 g = m_Palette.GetGreen(i); 00441 b = m_Palette.GetBlue(i); 00442 DrawCell(&cell, DocColour(r, g, b), m_Palette.GetFlags(i), pRender, 00443 IsColourWebSafe(r, g, b), i == m_SelectedCell); 00444 } 00445 } 00446 00447 // Draw the mouse over high light 00448 if (m_MouseOverCell != INVALID_COLOUR_VALUE) 00449 { 00450 GetRectForCell(m_MouseOverCell, &cell, controlHeight); 00451 pRender->SetFillColour(COLOUR_TRANS); 00452 pRender->SetLineColour(COLOUR_WHITE); 00453 pRender->DrawRect(&cell); 00454 } 00455 00456 }
|
|
Definition at line 347 of file bmpalctrl.cpp. 00348 { 00349 // Check the selection and mouse over colour are valid as the palette has probably changed 00350 if (m_SelectedCell > m_Palette.GetNumberOfColours()) 00351 m_SelectedCell = INVALID_COLOUR_VALUE; 00352 if (m_MouseOverCell > m_Palette.GetNumberOfColours()) 00353 m_MouseOverCell = INVALID_COLOUR_VALUE; 00354 00355 DialogManager::InvalidateGadget(m_WindowID, _R(IDC_T2_PALETTE_CONTROL)); 00356 }
|
|
Definition at line 154 of file bmpalctrl.cpp. 00155 { 00156 m_Palette.SetPaletteSortType(newSortType); 00157 }
|
|
Definition at line 313 of file bmpalctrl.cpp. 00314 { 00315 return SetHighlightedCellFromSortedIndex(pInfo, m_Palette.RealValueToSortedValue(paletteIndex)); 00316 }
|
|
Definition at line 318 of file bmpalctrl.cpp. 00319 { 00320 if (paletteIndex == m_MouseOverCell) 00321 return false; 00322 00323 // Invalidate the old cell 00324 if (m_MouseOverCell != INVALID_COLOUR_VALUE) 00325 InvalidateCell(pInfo, m_MouseOverCell); 00326 00327 m_MouseOverCell = paletteIndex; 00328 00329 // See if the mouse is in a valid cell 00330 if (m_MouseOverCell == INVALID_COLOUR_VALUE) 00331 return true; 00332 00333 // Invalidate the new cell so it will be redrawn 00334 InvalidateCell(pInfo, m_MouseOverCell); 00335 00336 return true; 00337 }
|
|
Definition at line 277 of file bmpalctrl.cpp. 00278 { 00279 return SetSelectedCellFromSortedIndex(pInfo, m_Palette.RealValueToSortedValue(paletteIndex)); 00280 }
|
|
Definition at line 292 of file bmpalctrl.cpp. 00293 { 00294 if (paletteIndex == m_SelectedCell) 00295 return false; 00296 00297 // Invalidate the old cell 00298 if (m_SelectedCell != INVALID_COLOUR_VALUE) 00299 InvalidateCell(pInfo, m_SelectedCell); 00300 00301 m_SelectedCell = paletteIndex; 00302 00303 // See if the mouse is in a valid cell 00304 if (m_SelectedCell == INVALID_COLOUR_VALUE) 00305 return true; 00306 00307 // Invalidate the new cell so it will be redrawn 00308 InvalidateCell(pInfo, m_SelectedCell); 00309 00310 return true; 00311 }
|
|
Definition at line 519 of file bmpalctrl.cpp. 00520 { 00521 m_Palette.SetFlags(m_SelectedCell, m_Palette.GetFlags(m_SelectedCell) ^ DELETED_COLOUR); 00522 if (GetSelectedColourDeleted()) 00523 BmapPrevDlg::m_pExportOptions->MakePaletteEntryUnreadable(m_Palette.SortedValueToRealValue(m_SelectedCell)); 00524 else 00525 BmapPrevDlg::m_pExportOptions->InvalidatePalette(); 00526 }
|
|
Definition at line 458 of file bmpalctrl.cpp. 00459 { 00460 m_Palette.SetFlags(m_SelectedCell, m_Palette.GetFlags(m_SelectedCell) ^ LOCKED_COLOUR); 00461 if (!GetSelectedColourLocked()) 00462 BmapPrevDlg::m_pExportOptions->InvalidatePalette(); 00463 }
|
|
Definition at line 510 of file bmpalctrl.cpp. 00511 { 00512 m_Palette.SetFlags(m_SelectedCell, m_Palette.GetFlags(m_SelectedCell) ^ TRANSPARENT_COLOUR); 00513 // if we have turned off transp for the background return TRUE to let the caller know 00514 if (m_SelectedCell == 0 && ((m_Palette.GetFlags(m_SelectedCell) & TRANSPARENT_COLOUR) == 0)) 00515 return true; 00516 else 00517 return false; 00518 }
|
|
Definition at line 491 of file bmpalctrl.cpp. 00492 { 00493 INT32 realIndex = m_Palette.SortedValueToRealValue(m_SelectedCell); 00494 00495 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00496 ERROR3IF(!palette, "There is no palette - This should never happen"); 00497 00498 if (!GetSelectedColourLocked()) 00499 SetSelectedColourToggleLocked(); 00500 00501 palette->Data[realIndex].PreEditedRed = palette->Data[realIndex].Red; 00502 palette->Data[realIndex].PreEditedGreen = palette->Data[realIndex].Green; 00503 palette->Data[realIndex].PreEditedBlue = palette->Data[realIndex].Blue; 00504 00505 MakeColourWebSafe(&palette->Data[realIndex].Red); 00506 MakeColourWebSafe(&palette->Data[realIndex].Green); 00507 MakeColourWebSafe(&palette->Data[realIndex].Blue); 00508 }
|
|
Definition at line 131 of file bmpalctrl.h. |
|
Definition at line 143 of file bmpalctrl.h. |
|
Definition at line 141 of file bmpalctrl.h. |
|
Definition at line 144 of file bmpalctrl.h. |
|
Definition at line 142 of file bmpalctrl.h. |
|
Definition at line 140 of file bmpalctrl.h. |
|
Definition at line 139 of file bmpalctrl.h. |
|
Definition at line 146 of file bmpalctrl.h. |
|
Definition at line 134 of file bmpalctrl.h. |
|
Definition at line 132 of file bmpalctrl.h. |
|
Definition at line 136 of file bmpalctrl.h. |