void VertexPaint::PaletteButton(HWND hWnd) { IColorSwatch* iPal = GetIColorSwatch(hWnd); if (iPal && iColor) { iColor->SetColor(iPal->GetColor(), TRUE); } }
static void SaveColorFile(HWND hWnd,TSTR &name) { MaxSDK::Util::TextFile::Writer file; Interface14 *iface = GetCOREInterface14(); UINT codepage = iface-> DefaultTextSaveCodePage(true); //dll\PaintLayerMod\ColorPaletteTool.cpp :: SaveColorFile, UTF8 allowed, keep to same. if(!file.Open(fname, false, MaxSDK::Util::TextFile::Writer::WRITE_BOM | codepage )){ TSTR buf2 = GetString(IDS_RB_COLORCLIPBOARD); TSTR buf1; buf1.printf(GetString(IDS_RB_CANTOPENFILE),fname); MessageBox(hWnd,buf1,buf2,MB_ICONEXCLAMATION); return; } for (int i=0; i<12; i++) { int r, g, b; IColorSwatch *cs = GetIColorSwatch(GetDlgItem(hWnd,csIDs[i])); COLORREF col = cs->GetColor(); ReleaseIColorSwatch(cs); r = GetRValue(col); g = GetGValue(col); b = GetBValue(col); file.Printf(_T("%d %d %d\n"), r, g, b); } for (int i=0; i<12; i++) { IColorSwatch *cs = GetIColorSwatch(GetDlgItem(hWnd,csIDs[i])); AColor col = cs->GetAColor(); ReleaseIColorSwatch(cs); file.Printf(_T("%f %f %f %f\n"), col.r, col.g, col.b, col.a); } SetupTitle(hWnd,name); file.Close(); }
void VertexPaint::SavePalettes() { IColorSwatch* c; for (int i=0; i<NUMPALETTES; i++) { c = GetIColorSwatch(hPaletteWnd[i]); palColors[i] = c->GetColor(); ReleaseIColorSwatch(c); } // Save Gradient Palettes. lastGradientColor[0]= iColorGradient[0]->GetColor(); lastGradientColor[1]= iColorGradient[1]->GetColor(); }
static INT_PTR CALLBACK VertexPaintDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { int numPoints; VertexPaint *mod = (VertexPaint*)GetWindowLongPtr(hWnd,GWLP_USERDATA); if (!mod && msg!=WM_INITDIALOG) return FALSE; int comboResult; // Manages Spinners. if (((msg==CC_SPINNER_BUTTONUP) && HIWORD(wParam)) || ((msg==CC_SPINNER_CHANGE) )) { ISpinnerControl *spin; spin = (ISpinnerControl *) lParam; switch (LOWORD(wParam)) { case IDC_TINT_SPIN: if ((msg == CC_SPINNER_CHANGE)) { mod->fTint = spin->GetFVal()/100; } break; case IDC_BEND_SPIN: if ((msg == CC_SPINNER_CHANGE)) { mod->fGradientBend = spin->GetFVal()/100; } break; } } switch (msg) { case WM_INITDIALOG: LoadImages(); mod = (VertexPaint*)lParam; SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam); mod->hParams = hWnd; mod->iPaintButton = GetICustButton(GetDlgItem(hWnd, IDC_PAINT)); mod->iPaintButton->SetType(CBT_CHECK); mod->iPaintButton->SetHighlightColor(GREEN_WASH); mod->iPaintButton->SetCheck(mod->ip->GetCommandMode()->ID() == CID_PAINT && !((PaintMouseProc *)mod->ip->GetCommandMode()->MouseProc(&numPoints))->GetPickMode()); mod->iPaintButton->SetImage(hButtonImages,0,0,0,0,15,14); mod->iPaintButton->SetTooltip (TRUE, GetString (IDS_PAINT)); mod->iPickButton = GetICustButton(GetDlgItem(hWnd, IDC_PICK)); mod->iPickButton->SetType(CBT_CHECK); mod->iPickButton->SetHighlightColor(GREEN_WASH); mod->iPickButton->SetCheck(mod->ip->GetCommandMode()->ID() == CID_PAINT && ((PaintMouseProc *)mod->ip->GetCommandMode()->MouseProc(&numPoints))->GetPickMode()); mod->iPickButton->SetImage(hButtonImages,1,1,1,1,15,14); mod->iPickButton->SetTooltip (TRUE, GetString (IDS_PICK)); mod->iColor = GetIColorSwatch(GetDlgItem(hWnd, IDC_COLOR)); // change current Color according to editMode mod->reloadBkupColor(); // Get interface For ZGradient, reload bkuped colors mod->iColorGradient[0] = GetIColorSwatch(GetDlgItem(hWnd, IDC_PALETTE_GRAD0)); mod->iColorGradient[1] = GetIColorSwatch(GetDlgItem(hWnd, IDC_PALETTE_GRAD1)); mod->iColorGradient[0]->SetColor(mod->lastGradientColor[0]); mod->iColorGradient[1]->SetColor(mod->lastGradientColor[1]); // Init comboBox SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Tree Weight"); SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Phase Level 1"); SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Phase Level 2"); SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_SETCURSEL, mod->getEditionType(), 0); // If paint mode at last edit. if(mod->_LastPaintMode) { // ActivatePaint / check button. mod->ActivatePaint(TRUE); mod->iPaintButton->SetCheck(TRUE); } break; case WM_POSTINIT: mod->InitPalettes(); break; case CC_COLOR_CHANGE: if (LOWORD(wParam) == IDC_COLOR) { IColorSwatch* iCol = (IColorSwatch*)lParam; switch(mod->getEditionType()) { case 0: mod->lastWeightColor = iCol->GetColor(); break; case 1: case 2: mod->lastPhaseColor = iCol->GetColor(); break; } } break; case WM_DESTROY: mod->SavePalettes(); mod->iPaintButton = NULL; mod->iPickButton = NULL; mod->iColor = NULL; mod->iColorGradient[0] = NULL; mod->iColorGradient[1] = NULL; break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_PAINT: mod->ActivatePaint(mod->iPaintButton->IsChecked()); break; case IDC_PICK: mod->ActivatePaint(mod->iPickButton->IsChecked(),TRUE); break; case IDC_VC_ON: mod->TurnVCOn(FALSE); break; case IDC_SHADED: mod->TurnVCOn(TRUE); break; case IDC_COMBO_TYPE: // Init default type. comboResult= SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0); mod->setEditionType(comboResult); break; case IDC_BUTTON_FILL: mod->fillSelectionColor(); break; case IDC_BUTTON_GRADIENT: mod->fillSelectionGradientColor(); break; case IDC_BUTTON_GRAD0: mod->iColorGradient[0]->SetColor(RGB(0,0,0)); mod->iColorGradient[1]->SetColor(RGB(85,85,85)); break; case IDC_BUTTON_GRAD1: mod->iColorGradient[0]->SetColor(RGB(85,85,85)); mod->iColorGradient[1]->SetColor(RGB(170,170,170)); break; case IDC_BUTTON_GRAD2: mod->iColorGradient[0]->SetColor(RGB(170,170,170)); mod->iColorGradient[1]->SetColor(RGB(255,255,255)); break; } break; default: return FALSE; } return TRUE; }