/* PaletteEntryPanel::duplicate * Make a copy of the current palette and add it to the list *******************************************************************/ bool PaletteEntryPanel::duplicate() { Palette8bit* newpalette = new Palette8bit; if (!newpalette) return false; newpalette->copyPalette(palettes[cur_palette]); palettes.push_back(newpalette); // Refresh the display to show the updated amount of palettes showPalette(cur_palette); setModified(); return true; }
/* PaletteEntryPanel::testPalette * A "lite" version of addCustomPalette, which does not add to the * palette folder so the palette is only available for the current * session. *******************************************************************/ bool PaletteEntryPanel::testPalette() { // Get name to export as string name = "Test: " + wxGetTextFromUser("Enter name for Palette:", "Test Palettes"); // Add to palette manager and main palette chooser Palette8bit* pal = new Palette8bit(); pal->copyPalette(palettes[cur_palette]); thePaletteManager->addPalette(pal, name); thePaletteChooser->addPalette(name); thePaletteChooser->selectPalette(name); return true; }
/* PaletteEntryPanel::tweak * Tweaks the colours of the current palette *******************************************************************/ bool PaletteEntryPanel::tweak() { Palette8bit* pal = new Palette8bit; if (pal == NULL) return false; pal->copyPalette(palettes[cur_palette]); PaletteColourTweakDialog pctd(theMainWindow, pal); if (pctd.ShowModal() == wxID_OK) { palettes[cur_palette]->copyPalette(pctd.getFinalPalette()); showPalette(cur_palette); setModified(); } delete pal; return true; }
/* PaletteEntryPanel::generatePalette * Just a helper for generatePalettes to make the code less redundant *******************************************************************/ void PaletteEntryPanel::generatePalette(int r, int g, int b, int shift, int steps) { // Create a new palette Palette8bit* pal = new Palette8bit; if (pal == NULL) return; // Seed it with the basic palette pal->copyPalette(palettes[0]); // Tint palette with given values pal->idtint(r, g, b, shift, steps); // Add it to the palette list palettes.push_back(pal); }
/* PaletteEntryPanel::addCustomPalette * Adds the current palette to the custom user palettes folder, so * it can be selected via the palette selector *******************************************************************/ bool PaletteEntryPanel::addCustomPalette() { // Get name to export as string name = wxGetTextFromUser("Enter name for Palette:", "Add to Palettes"); if (name.IsEmpty()) return false; // Write current palette to the user palettes directory string path = appPath(S_FMT("palettes/%s.pal", name), DIR_USER); palettes[cur_palette]->saveFile(path); // Add to palette manager and main palette chooser Palette8bit* pal = new Palette8bit(); pal->copyPalette(palettes[cur_palette]); thePaletteManager->addPalette(pal, name); thePaletteChooser->addPalette(name); return true; }