/*[]=====================================================================[]*/ /*[] LeadTools Run Time Library - Version 13 []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1991-2001 LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[]=====================================================================[]*/ #include "ImgPF.h" static L_BOOL OffsetDlg_OnInitDialog (HWND hWnd, HWND hWndFocus, LPARAM lParam); static L_BOOL OffsetDlg_OnCommand (HWND hWnd, L_INT nID, HWND hWndCtl, L_UINT codeNotify); static L_BOOL OffsetDlg_OnHScroll (HWND hWnd, HWND hWndCtl, L_UINT nCode, L_INT nPos); static L_VOID OffsetDlg_OnTimer (HWND hWnd, L_INT nID); static L_VOID OffsetDlg_OnPaint (HWND hWnd); static L_VOID L_ApplyFilter (HWND hWnd); L_BOOL CALLBACK OffsetDlgProc (HWND hWnd, L_UINT uMessage, WPARAM wParam, LPARAM lParam) { switch(uMessage) { HANDLE_MSG (hWnd, WM_COMMAND, OffsetDlg_OnCommand); HANDLE_MSG (hWnd, WM_INITDIALOG, OffsetDlg_OnInitDialog); HANDLE_MSG (hWnd, WM_HSCROLL, OffsetDlg_OnHScroll); HANDLE_MSG (hWnd, WM_PAINT, OffsetDlg_OnPaint); HANDLE_MSG (hWnd, WM_TIMER, OffsetDlg_OnTimer); case WM_USER_UPDATEVIEW: StatusProc.ProgressValue = 100; L_ApplyFilter (hWnd); break; } return FALSE; } static L_BOOL OffsetDlg_OnInitDialog (HWND hWnd, HWND hWndFocus, LPARAM lParam) { LPOFFSETDLGDATA pOffsetDlgData; HWND hWndParent; pCHILDDATA pData; L_INT nRangeMax[] = {255, 255}; L_INT nRangeMin[] = { 0, 0}; L_INT nPosInit [] = { 0, 0}; L_INT nSlider; L_BOOL bRegion; RECT rcRgn; hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pData = LOCKCHILDDATA (hWndParent); pOffsetDlgData = (LPOFFSETDLGDATA)lParam; SetWindowLong(hWnd,GWL_USERDATA,(LONG)pOffsetDlgData); ShowWindow(hWnd, SW_SHOW); bRegion = L_BitmapHasRgn(&pData->LeadBitmap); L_GetBitmapRgnBounds(&pData->LeadBitmap, NULL, &rcRgn); nRangeMax[0] = (bRegion ? (rcRgn.right - rcRgn.left - 1) : pData->LeadBitmap.Width - 1) * 2; nRangeMax[1] = (bRegion ? (rcRgn.bottom - rcRgn.top - 1) : pData->LeadBitmap.Height - 1) * 2; nRangeMin[0] = (bRegion ? -(rcRgn.right - rcRgn.left - 1) : -pData->LeadBitmap.Width + 1) * 2; nRangeMin[1] = (bRegion ? -(rcRgn.bottom - rcRgn.top - 1) : -pData->LeadBitmap.Height + 1) * 2; StatusProc.bProgress = TRUE; StatusProc.bInvalidate = FALSE; StatusProc.bEnd = FALSE; StatusProc.DlgWnd = hWnd; StatusProc.ProgressValue = 100; StatusProc.ProgWnd = GetDlgItem(hWnd, IDC_NOTPAP_PROG); Progress_SetRange(StatusProc.ProgWnd, 0, 100); Progress_SetPos(StatusProc.ProgWnd, 0); ComboBox_AddString(GetDlgItem(hWnd, IDC_OFFSET_FILL_COM), "Color"); ComboBox_AddString(GetDlgItem(hWnd, IDC_OFFSET_FILL_COM), "Repeat"); ComboBox_AddString(GetDlgItem(hWnd, IDC_OFFSET_FILL_COM), "Unchanged"); ComboBox_AddString(GetDlgItem(hWnd, IDC_OFFSET_FILL_COM), "Wrap Around"); //MEMDISK...// MemorizeAndCopyBitmap (hWndParent, &pOffsetDlgData->LeadBitmap); pOffsetDlgData->nSlideNum = 2; pOffsetDlgData->nSldBaseID = IDC_OFFSET_WDT_SLD; pOffsetDlgData->nEdtBaseID = IDC_OFFSET_WDT_EDT; pOffsetDlgData->nWidth = nPosInit[0]; pOffsetDlgData->nHeight = nPosInit[1]; pOffsetDlgData->crBackColor = RGB(0, 0, 0); pOffsetDlgData->uFlags = 0; ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_OFFSET_FILL_COM), 0); for (nSlider = 0; nSlider < pOffsetDlgData->nSlideNum; nSlider++) { Trackbar_SetRange(GetDlgItem(hWnd, pOffsetDlgData->nSldBaseID + nSlider), TRUE, nRangeMin[nSlider], nRangeMax[nSlider]); SetDlgItemInt(hWnd, pOffsetDlgData->nEdtBaseID + nSlider, nPosInit[nSlider], TRUE); SetNumericEditBox(GetDlgItem(hWnd, pOffsetDlgData->nEdtBaseID + nSlider), nRangeMin[nSlider], nRangeMax[nSlider], 1, 0, FALSE); } L_ApplyFilter (hWnd); pData->uTimerID = SetTimer(hWnd, 1, 100, NULL); return ( TRUE ); } static L_VOID OffsetDlg_OnTimer(HWND hWnd, L_INT nID) { Dialog_Timer(nID); } static L_BOOL OffsetDlg_OnCommand (HWND hWnd, L_INT nID, HWND hWndCtl, L_UINT uCodeNotify) { LPOFFSETDLGDATA pOffsetDlgData; HWND hWndParent; L_INT nIndex; L_INT nValue; pCHILDDATA pData; COLORREF crColor; hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pData = LOCKCHILDDATA (hWndParent); pOffsetDlgData = (LPOFFSETDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); if (nID >= pOffsetDlgData->nEdtBaseID && nID < pOffsetDlgData->nEdtBaseID + pOffsetDlgData->nSlideNum) { nValue = GetDlgItemInt(hWnd, nID, NULL, TRUE); nIndex = nID - pOffsetDlgData->nEdtBaseID; Trackbar_SetPos(GetDlgItem(hWnd, nID + pOffsetDlgData->nSlideNum), TRUE, nValue); switch (nIndex) { case 0: if (pOffsetDlgData->nWidth == nValue) return FALSE; pOffsetDlgData->nWidth = nValue; break; case 1: if (pOffsetDlgData->nHeight == nValue) return FALSE; pOffsetDlgData->nHeight = nValue; break; } L_ApplyFilter (hWnd); } switch(nID) { case IDC_OFFSET_CLR_BTN: crColor = pOffsetDlgData->crBackColor; pOffsetDlgData->crBackColor = ShowColorDialog(hWnd, crColor); if (pOffsetDlgData->crBackColor != crColor) { InvalidateRect(hWnd, NULL, FALSE); L_ApplyFilter(hWnd); } break; case IDC_OFFSET_FILL_COM: nValue = ComboBox_GetCurSel(hWndCtl); if (pOffsetDlgData->uFlags != (L_UINT)nValue) { Button_Enable(GetDlgItem(hWnd, IDC_OFFSET_CLR_BTN), !nValue); pOffsetDlgData->uFlags = nValue; InvalidateRect(hWnd, NULL, FALSE); InvalidateRect(hWndCtl, NULL, FALSE); L_ApplyFilter(hWnd); } break; case IDCANCEL: StatusProc.bProgress = FALSE; StatusProc.bKillProgress = TRUE; StatusProc.ProgressValue = 100; EndDialog(hWnd, FALSE); break; case IDOK: ShowStatusWindow(FALSE); StatusProc.bStillWork = TRUE; StatusProc.bInvalidate = TRUE; StatusProc.bEnd = TRUE; EndDialog(hWnd, TRUE); break; } return TRUE; } static L_BOOL OffsetDlg_OnHScroll (HWND hWnd, HWND hWndCtl, L_UINT nCode, L_INT nPos) { LPOFFSETDLGDATA pOffsetDlgData = (LPOFFSETDLGDATA) GetWindowLong(hWnd,GWL_USERDATA); return SetDlgItemInt(hWnd, GetDlgCtrlID(hWndCtl) - pOffsetDlgData->nSlideNum, Trackbar_GetPos(hWndCtl) , TRUE); } static L_VOID OffsetDlg_OnPaint(HWND hWnd) { LPOFFSETDLGDATA pOffsetDlgData; HDC hDC; PAINTSTRUCT ps; RECT rcRect; HBRUSH hBrush; pOffsetDlgData = (LPOFFSETDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); hDC = BeginPaint(GetDlgItem(hWnd, IDC_OFFSET_CLR_TXT), &ps); GetClientRect(GetDlgItem(hWnd, IDC_OFFSET_CLR_TXT), &rcRect); hBrush = CreateSolidBrush(pOffsetDlgData->crBackColor); FillRect(hDC, &rcRect,!pOffsetDlgData->uFlags ? hBrush :(HBRUSH)COLOR_WINDOW); DeleteBrush(hBrush); EndPaint(GetDlgItem(hWnd, IDC_OFFSET_CLR_TXT), &ps); } static L_VOID L_ApplyFilter (HWND hWnd) { pCHILDDATA pData; L_INT nRet = 1; HWND hWndParent; LPOFFSETDLGDATA pOffsetDlgData; if ( 100 != StatusProc.ProgressValue ) { StatusProc.bKillProgress = TRUE ; return ; } pOffsetDlgData = (LPOFFSETDLGDATA)GetWindowLong(hWnd,GWL_USERDATA); hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pData = LOCKCHILDDATA(hWndParent); FreeMemorizedBitmap (hWndParent); //MEMDISK// L_CopyBitmap(&pData->LeadBitmap, &pOffsetDlgData->LeadBitmap, sizeof(BITMAPHANDLE)); nRet = L_OffsetBitmap(&pData->LeadBitmap, pOffsetDlgData->nWidth, pOffsetDlgData->nHeight, pOffsetDlgData->crBackColor, pOffsetDlgData->uFlags); if(nRet == SUCCESS) { InvalidateRect(hWndParent, NULL, FALSE); StatusProc.ProgressValue = 100; Progress_SetPos(StatusProc.ProgWnd , 0); if(StatusProc.bEnd) { StatusProc.bProgress = FALSE; StatusProc.bKillProgress = TRUE ; } } }