GME
13
|
00001 // ModelPropertiesDlgBar.cpp : implementation file 00002 // 00003 00004 #include "stdafx.h" 00005 #include "GMEApp.h" 00006 #include "ModelPropertiesDlgBar.h" 00007 #include "GMEstd.h" 00008 00009 #ifdef _DEBUG 00010 #define new DEBUG_NEW 00011 #undef THIS_FILE 00012 static char THIS_FILE[] = __FILE__; 00013 #endif 00014 00016 // CModelPropertiesDlgBar dialog 00017 00018 IMPLEMENT_DYNCREATE(CModelPropertiesDlgBar, CPaneDialog) 00019 00020 00021 CModelPropertiesDlgBar::CModelPropertiesDlgBar() 00022 : CPaneDialog() 00023 { 00024 } 00025 00026 BEGIN_MESSAGE_MAP(CModelPropertiesDlgBar, CPaneDialog) 00027 ON_CBN_SELENDOK(IDC_ZOOMS, OnSelEnd) 00028 ON_COMMAND(IDOK, OnOK) 00029 END_MESSAGE_MAP() 00030 00031 void CModelPropertiesDlgBar::ShowType() 00032 { 00033 // FIXME: fix for DPI 00034 GetDlgItem(IDC_TYPEMARK)->MoveWindow(6,8,16,16); 00035 GetDlgItem(IDC_TYPEMARK)->ShowWindow(SW_SHOW); 00036 GetDlgItem(IDC_INSTANCEMARK)->ShowWindow(SW_HIDE); 00037 GetDlgItem(IDC_BASETYPE_LABEL)->SetWindowText(_T("Base:")); 00038 } 00039 00040 void CModelPropertiesDlgBar::ShowInstance() 00041 { 00042 // FIXME: fix for DPI 00043 GetDlgItem(IDC_TYPEMARK)->ShowWindow(SW_HIDE); 00044 GetDlgItem(IDC_INSTANCEMARK)->MoveWindow(6,8,16,16); 00045 GetDlgItem(IDC_INSTANCEMARK)->ShowWindow(SW_SHOW); 00046 GetDlgItem(IDC_BASETYPE_LABEL)->SetWindowText(_T("Type:")); 00047 } 00048 00050 // CModelPropertiesDlgBar message handlers 00051 00052 void CModelPropertiesDlgBar::writeNumToEdit(CEdit *edit, int kk) 00053 { 00054 if (!edit) 00055 { 00056 CWnd* zoom = GetDlgItem(IDC_ZOOMS); 00057 edit = (CEdit*)(zoom->GetDlgItem(IDC_TYPENAME)); 00058 } 00059 char buff[100]; 00060 edit->SetSel(0, -1); 00061 _itoa(kk, buff, 10); 00062 CString str = buff; 00063 str += _T("%"); 00064 edit->ReplaceSel(str); 00065 } 00066 00067 void CModelPropertiesDlgBar::OnOK() 00068 { 00069 // enter pressed on which item 00070 CWnd* fwin = GetFocus(); 00071 if (!fwin) 00072 return; 00073 CWnd* zoom = GetDlgItem(IDC_ZOOMS); 00074 if (!zoom) 00075 return; 00076 CEdit* edit = (CEdit*)(zoom->GetDlgItem(IDC_TYPENAME)); 00077 if (!edit) 00078 return; 00079 if (fwin->m_hWnd == edit->m_hWnd) 00080 { 00081 CString buff = CEditGetLine(*edit, 0); 00082 int kk = _ttoi(buff); 00083 kk = abs(kk); 00084 if (!kk) 00085 kk = 100; 00086 // send message to zoom with (userdefined=true, kk) 00087 ((CFrameWnd*)GetParent())->GetActiveView()->PostMessage(WM_USER_ZOOM, (WPARAM)TRUE, (LPARAM)kk); 00088 writeNumToEdit(edit, kk); 00089 } 00090 ((CFrameWnd*)GetParent())->GetActiveView()->SetFocus(); 00091 } 00092 00093 00094 void CModelPropertiesDlgBar::OnSelEnd() 00095 { 00096 // item chosen from list -> zoom 00097 CComboBox* zoom = (CComboBox*)GetDlgItem(IDC_ZOOMS); 00098 int item = zoom->GetCurSel(); 00099 if (item != CB_ERR) 00100 { 00101 int kk = m_zoomlist[item]; 00102 // send message to zoom with (userdefined=false, kk) 00103 ((CFrameWnd*)GetParent())->GetActiveView()->PostMessage(WM_USER_ZOOM, (WPARAM)FALSE, (LPARAM)kk); 00104 } 00105 ((CFrameWnd*)GetParent())->GetActiveView()->SetFocus(); 00106 } 00107 00108 void CModelPropertiesDlgBar::SetZoomList(int *list) 00109 { 00110 // supposed it is sorted 00111 if (!list) 00112 return; 00113 int i; 00114 for (i=0; list[i] && i<MAX_ZOOM-1; i++) 00115 { 00116 m_zoomlist[i] = list[i]; 00117 } 00118 m_zoomlist[i] = 0; 00119 CComboBox* zoom = (CComboBox*)GetDlgItem(IDC_ZOOMS); 00120 for (int k=0; m_zoomlist[k]; k++) 00121 { 00122 CString str; 00123 if (m_zoomlist[k] > 0) 00124 { 00125 TCHAR buff[100]; 00126 _itot(m_zoomlist[k], buff, 10); 00127 str = buff; 00128 str += _T("%"); 00129 } 00130 else 00131 { 00132 switch (m_zoomlist[k]) 00133 { 00134 case ZOOM_WIDTH: 00135 str = _T("Fit Width"); 00136 break; 00137 case ZOOM_HEIGHT: 00138 str = _T("Fit Height"); 00139 break; 00140 case ZOOM_ALL: 00141 str = _T("Fit All"); 00142 break; 00143 } 00144 } 00145 zoom->AddString(str); 00146 } 00147 } 00148 00149 void CModelPropertiesDlgBar::SetZoomVal(int kk) 00150 { 00151 // only to the edit box 00152 if (kk <= 0) 00153 return; 00154 writeNumToEdit(NULL, kk); 00155 } 00156 00157 void CModelPropertiesDlgBar::NextZoomVal(int &kk) 00158 { 00159 // related to the current one in the edit box 00160 CComboBox* zoom = (CComboBox*)GetDlgItem(IDC_ZOOMS); 00161 if (!zoom) 00162 return; 00163 CEdit* edit = (CEdit*)(zoom->GetDlgItem(IDC_TYPENAME)); 00164 if (!edit) 00165 return; 00166 CString buff = CEditGetLine(*edit, 0); 00167 kk = _ttoi(buff); 00168 if (!kk) 00169 kk = 100; 00170 int i; 00171 for (i=0; m_zoomlist[i] && m_zoomlist[i]<=kk; i++); 00172 if (m_zoomlist[i]) 00173 { 00174 kk = m_zoomlist[i]; 00175 writeNumToEdit(edit, kk); 00176 } 00177 } 00178 00179 void CModelPropertiesDlgBar::PrevZoomVal(int &kk) 00180 { 00181 // related to the current one in the edit box 00182 CComboBox* zoom = (CComboBox*)GetDlgItem(IDC_ZOOMS); 00183 if (!zoom) 00184 return; 00185 CEdit* edit = (CEdit*)(zoom->GetDlgItem(IDC_TYPENAME)); 00186 if (!edit) 00187 return; 00188 CString buff = CEditGetLine(*edit, 0); 00189 kk = _ttoi(buff); 00190 if (!kk) 00191 kk = 100; 00192 int i; 00193 for (i=0; m_zoomlist[i] && m_zoomlist[i]<kk; i++); 00194 if (m_zoomlist[i] && i) 00195 { 00196 kk = m_zoomlist[i-1]; 00197 writeNumToEdit(edit, kk); 00198 } 00199 } 00200 00201