INT_PTR CALLBACK rvGETransformer::DlgProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { rvGETransformer* trans = (rvGETransformer*) GetWindowLong ( hWnd, GWL_USERDATA ); switch ( msg ) { case WM_DESTROY: if ( gTransHook ) { UnhookWindowsHookEx( gTransHook ); } gTransDlg = NULL; break; case WM_INITDIALOG: trans = (rvGETransformer*) lParam; trans->mDlg = hWnd; SetWindowLong ( hWnd, GWL_USERDATA, lParam ); NumberEdit_Attach ( GetDlgItem ( hWnd, IDC_GUIED_ITEMRECTX ) ); NumberEdit_Attach ( GetDlgItem ( hWnd, IDC_GUIED_ITEMRECTY ) ); NumberEdit_Attach ( GetDlgItem ( hWnd, IDC_GUIED_ITEMRECTW ) ); NumberEdit_Attach ( GetDlgItem ( hWnd, IDC_GUIED_ITEMRECTH ) ); gTransDlg = hWnd; gTransHook = SetWindowsHookEx( WH_GETMESSAGE, GetMsgProc, NULL, GetCurrentThreadId() ); break; case WM_COMMAND: if ( LOWORD ( wParam ) == IDOK ) { SendMessage ( hWnd, WM_NEXTDLGCTL, 0, 0 ); } else if ( HIWORD ( wParam ) == EN_KILLFOCUS && trans && trans->mWorkspace ) { char temp[64]; int value; GetWindowText ( GetDlgItem ( hWnd, LOWORD(wParam) ), temp, 64 ); value = atoi ( temp ); idRectangle rect = trans->mWorkspace->GetSelectionMgr().GetRect ( ); trans->mWorkspace->WindowToWorkspace ( rect ); // The transformer coords are relative to the botto most selected window's parent so // adjust the rect accordingly if ( trans->mRelative ) { idRectangle& screenRect = rvGEWindowWrapper::GetWrapper ( trans->mRelative )->GetScreenRect ( ); rect.x -= screenRect.x; rect.y -= screenRect.y; } switch ( LOWORD ( wParam ) ) { case IDC_GUIED_ITEMRECTX: if ( value - rect[0] ) { trans->mWorkspace->AddModifierMove ( "Transform Move", value - rect[0], 0, false ); } break; case IDC_GUIED_ITEMRECTY: if ( value - rect[1] ) { trans->mWorkspace->AddModifierMove ( "Transform Move", 0, value - rect[1], false ); } break; case IDC_GUIED_ITEMRECTW: if ( value - rect[2] ) { trans->mWorkspace->AddModifierSize ( "Transform Size", 0, 0, value - rect[2], 0, false ); } break; case IDC_GUIED_ITEMRECTH: if ( value - rect[3] ) { trans->mWorkspace->AddModifierSize ( "Transform Size", 0, 0, 0, value - rect[3], false ); } break; } } break; } return FALSE; }
/* ================ AlphaSelectDlg_WndProc Window procedure for the alpha select dialog ================ */ INT_PTR CALLBACK AlphaSelectDlg_WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch ( msg ) { case WM_INITDIALOG: { int color; gAlphaDlg = hwnd; gAlphaHook = SetWindowsHookEx( WH_GETMESSAGE, AlphaSelectDlg_GetMsgProc, NULL, GetCurrentThreadId() ); color = GetRValue(ColorButton_GetColor ((HWND)lParam)); // The lParam for the alpha select dialog is the window handle of the button pressed SetWindowLong ( hwnd, GWL_USERDATA, lParam ); // Subclass the alpha SetWindowLong ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA, MAKELONG(0,color) ); // Numbers only on the edit box and start it with the current alpha value. NumberEdit_Attach ( GetDlgItem ( hwnd, IDC_GUIED_ALPHA ) ); SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_ALPHA ), va("%.3f", ((float)color / 255.0f) ) ); break; } case WM_DESTROY: UnhookWindowsHookEx( gAlphaHook ); ReleaseCapture ( ); gAlphaDlg = NULL; break; case WM_ACTIVATE: if ( !LOWORD(wParam) ) { EndDialog ( hwnd, 0 ); } break; case WM_COMMAND: switch ( LOWORD(wParam) ) { case IDC_GUIED_ALPHA: { char temp[64]; float value; // Get the current text in the window and convert it to a float GetDlgItemText ( hwnd, IDC_GUIED_ALPHA, temp, 64 ); value = atof ( temp ); if ( value < 0.0f ) { value = 0.0f; } else if ( value > 1.0f ) { value = 1.0f; } // Set the current alpha value in the slider SetWindowLong ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA, MAKELONG(0,(255.0f * value)) ); break; } case IDC_GUIED_ALPHASLIDER: case IDOK: { int color = (short)HIWORD(GetWindowLong ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA )); ColorButton_SetColor ( (HWND)GetWindowLong ( hwnd, GWL_USERDATA ), RGB(color,color,color) ); EndDialog ( hwnd, 0 ); break; } case IDCANCEL: EndDialog ( hwnd, 0 ); break; } break; } return FALSE; }