home *** CD-ROM | disk | FTP | other *** search
- // FracCdlg.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "FracCompress.h"
- #include "FracCdlg.h"
- #include "frac.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
-
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
-
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- CBitmapButton m_picture;
- //}}AFX_DATA
-
- // Implementation
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //{{AFX_MSG(CAboutDlg)
- virtual BOOL OnInitDialog();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
-
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
-
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- DDX_Control(pDX, IDC_PIC, m_picture);
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg message handlers
-
- BOOL CAboutDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CenterWindow();
-
- // TODO: Add extra about dlg initialization here
- m_picture.LoadBitmaps("IDB_NBALL");
- m_picture.SizeToContent();
-
- return TRUE; // return TRUE unless you set the focus to a control
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CFracCompressDlg dialog
-
- CFracCompressDlg::CFracCompressDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CFracCompressDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CFracCompressDlg)
- m_fileIn = _T("");
- m_fileOut = _T("");
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- m_Compress = FALSE;
- m_Done = FALSE;
-
- }
-
- void CFracCompressDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CFracCompressDlg)
- DDX_Control(pDX, IDC_OFN, m_of);
- DDX_Control(pDX, IDC_IFN, m_if);
- DDX_Control(pDX, IDOK, m_okbutton);
- DDX_Text(pDX, IDC_IFNSTRING, m_fileIn);
- DDX_Text(pDX, IDC_OFNSTRING, m_fileOut);
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CFracCompressDlg, CDialog)
- //{{AFX_MSG_MAP(CFracCompressDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_OFN, OnOfn)
- ON_BN_CLICKED(IDC_IFN, OnIfn)
- ON_BN_CLICKED(IDC_DECOMPRESS, OnDecompress)
- ON_BN_CLICKED(IDC_COMPRESS, OnCompress)
- ON_BN_CLICKED(IDC_OPTIONS, OnOptions)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CFracCompressDlg message handlers
-
- BOOL CFracCompressDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CenterWindow();
- m_Compress = TRUE;
- m_if.LoadBitmaps("IDB_DOWNUP","IDB_DOWND");
- m_if.SizeToContent( );
- m_of.LoadBitmaps("IDB_DOWNUP","IDB_DOWND");
- m_of.SizeToContent( );
- CheckRadioButton(IDC_COMPRESS,IDC_DECOMPRESS,IDC_COMPRESS);
- CString LpRegister = AfxRegisterWndClass(CS_CLASSDC,0,CreateSolidBrush(RGB(255,255,255)),0);
- m_viewer.CreateEx(WM_PARENTNOTIFY,LpRegister,"Processing...",WS_CAPTION|WS_POPUPWINDOW,0,0,256,256,GetSafeHwnd(),0);
- m_viewer.CenterWindow();
- // Add "About..." menu item to system menu.
-
- // IDM_ABOUTBOX must be in the system command range.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
-
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
-
- // TODO: Add extra initialization here
-
- return TRUE; // return TRUE unless you set the focus to a control
- }
-
- void CFracCompressDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
-
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
-
- void CFracCompressDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
-
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CFracCompressDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
-
-
- void CFracCompressDlg::OnOfn()
- {
- // TODO: Add your control notification handler code here
- if(m_Done)
- return;
- CFileDialog *fileDialog;
- if(m_Compress)
- fileDialog = new CFileDialog(FALSE,"FIC","*.*",OFN_HIDEREADONLY,
- "FIC Files (*.FIC)|*.FIC|Trans File (*.TRN)|*.TRN|All Files (*.*)|*.*||");
- else
- fileDialog = new CFileDialog(FALSE,"DAT","*.*",OFN_HIDEREADONLY,
- "Raw Files (*.DAT)|*.DAT|All Files (*.*)|*.*||");
-
-
- if(fileDialog->DoModal() == IDOK)
- {
- m_fileOut = fileDialog->GetPathName();
- UpdateData(FALSE);
- }
- delete fileDialog;
-
-
- }
-
- void CFracCompressDlg::OnIfn()
- {
- // TODO: Add your control notification handler code here
- if(m_Done)
- return;
- CFileDialog *fileDialog;
- if(m_Compress)
- fileDialog = new CFileDialog(TRUE,"DAT","*.*",OFN_HIDEREADONLY,
- "Raw Files (*.DAT)|*.DAT|All Files (*.*)|*.*||");
- else
- fileDialog = new CFileDialog(TRUE,"FIC","*.*",OFN_HIDEREADONLY,
- "FIC Files (*.FIC)|*.FIC|Trans File (*.TRN)|*.TRN|All Files (*.*)|*.*||");
-
- if(fileDialog->DoModal() == IDOK)
- {
- m_fileIn = fileDialog->GetPathName();
- UpdateData(FALSE);
- }
- delete fileDialog;
-
- }
-
-
-
- void CFracCompressDlg::OnOK()
- {
- // TODO: Add extra validation here
- if(m_Done)
- {
- CDialog::OnOK();
- return;
- }
- UpdateData(TRUE);
- CFracComp *FracComp = new CFracComp(GetSafeHwnd(),IDC_STATUS);
- FracComp->SetFileName(m_fileIn,m_fileOut);
- if(m_Compress)
- if(coption.m_change)
- {
- if(coption.m_display)
- {
- FracComp->Compress(m_viewer.GetSafeHwnd(),coption.m_tol,coption.m_height,coption.m_width,coption.m_rd,
- coption.m_rd2,coption.m_dpss,atoi(coption.m_step),coption.m_slb,coption.m_ofb,coption.m_msl,coption.m_dsm,coption.m_pos,
- coption.m_24dc,coption.m_3dc);
- m_viewer.SaveDC(FracComp->HandleDC());
- }
- else
- FracComp->Compress(NULL,coption.m_tol,coption.m_height,coption.m_width,coption.m_rd,
- coption.m_rd2,coption.m_dpss,atoi(coption.m_step),coption.m_slb,coption.m_ofb,coption.m_msl,coption.m_dsm,coption.m_pos,
- coption.m_24dc,coption.m_3dc);
- }
- else
- {
- FracComp->Compress(m_viewer.GetSafeHwnd());
- m_viewer.SaveDC(FracComp->HandleDC());
- }
- else
- {
- if(doption.m_change)
- {
- if(doption.m_display)
- {
-
- FracComp->Decompress(m_viewer.GetSafeHwnd(),doption.m_sc,doption.m_nit,
- doption.m_post,doption.m_msl,doption.m_sb,doption.m_ofs,doption.m_out);
- m_viewer.SaveDC(FracComp->HandleDC());
- }
- else
- FracComp->Decompress(NULL,doption.m_sc,doption.m_nit,doption.m_post,
- doption.m_msl,doption.m_sb,doption.m_ofs,doption.m_out);
- }
- else
- {
-
- FracComp->Decompress(m_viewer.GetSafeHwnd());
- m_viewer.SaveDC(FracComp->HandleDC());
- }
-
-
-
- }
- delete FracComp;
- m_Done = TRUE;
- m_okbutton.SetWindowText("Close");
-
- }
-
- void CFracCompressDlg::OnDecompress()
- {
- // TODO: Add your control notification handler code here
- if(m_Done)
- return;
- m_Compress = FALSE;
- CheckRadioButton(IDC_COMPRESS,IDC_DECOMPRESS,IDC_DECOMPRESS);
-
- }
-
- void CFracCompressDlg::OnCompress()
- {
- // TODO: Add your control notification handler code here
- if(m_Done)
- return;
- m_Compress = TRUE;
- CheckRadioButton(IDC_COMPRESS,IDC_DECOMPRESS,IDC_COMPRESS);
-
- }
-
- void CFracCompressDlg::OnOptions()
- {
- // TODO: Add your control notification handler code here
- if(m_Done)
- return;
- if(m_Compress)
- coption.DoModal();
- else
- doption.DoModal();
-
- }
-