[GME-commit] GMESRC/GME/Gme ModelPropertiesDlgBar.h,1.1,1.2 ModelPropertiesDlgBar.cpp,1.3,1.4

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Thu Mar 11 12:05:11 CST 2004


Update of /var/lib/gme/GMESRC/GME/Gme
In directory braindrain:/tmp/cvs-serv8495

Modified Files:
	ModelPropertiesDlgBar.h ModelPropertiesDlgBar.cpp 
Log Message:
zoom problem solved and enhanced

CVS User: bogyom

Index: ModelPropertiesDlgBar.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Gme/ModelPropertiesDlgBar.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ModelPropertiesDlgBar.h	5 Jul 2000 19:20:00 -0000	1.1
--- ModelPropertiesDlgBar.h	11 Mar 2004 18:05:07 -0000	1.2
***************
*** 11,14 ****
--- 11,18 ----
  // CModelPropertiesDlgBar dialog
  
+ #define MAX_ZOOM 100
+ 
+ #define WM_USER_ZOOM	(WM_USER+111)
+ 
  class CModelPropertiesDlgBar : public CDialogBar
  {
***************
*** 17,23 ****
--- 21,46 ----
  	CModelPropertiesDlgBar();   // standard constructor
  
+ 	// Dialog Data
+ 	//{{AFX_DATA(CModelPropertiesDlgBar)
+ 	enum { IDD = CG_IDD_MODELPROPERTIESBAR };
+ 	//}}AFX_DATA
+ 
  	void ShowInstance();
  	void ShowType();
  
+ // Overrides
+ 	// ClassWizard generated virtual function overrides
+ 	//{{AFX_VIRTUAL(CModelPropertiesDlgBar)
+ 	//}}AFX_VIRTUAL
+ 	void SetZoomList(int *list);
+ 	void SetZoomVal(int kk);
+ 	void NextZoomVal(int &kk);
+ 	void PrevZoomVal(int &kk);
+ 
+ private:
+ 	int m_zoomlist[MAX_ZOOM];
+ 
+ 	void writeNumToEdit(CEdit *edit, int kk);
+ 
  // Implementation
  protected:
***************
*** 25,28 ****
--- 48,52 ----
  	//{{AFX_MSG(CGMEViewDlgBar)
  	virtual void OnOK();
+ 	afx_msg void OnSelEnd();
  	//}}AFX_MSG
  	DECLARE_MESSAGE_MAP()

Index: ModelPropertiesDlgBar.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Gme/ModelPropertiesDlgBar.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ModelPropertiesDlgBar.cpp	7 Feb 2003 15:22:47 -0000	1.3
--- ModelPropertiesDlgBar.cpp	11 Mar 2004 18:05:07 -0000	1.4
***************
*** 5,8 ****
--- 5,9 ----
  #include "GMEApp.h"
  #include "ModelPropertiesDlgBar.h"
+ #include "GMEstd.h"
  
  #ifdef _DEBUG
***************
*** 21,24 ****
--- 22,26 ----
  
  BEGIN_MESSAGE_MAP(CModelPropertiesDlgBar, CDialogBar)
+ 	ON_CBN_SELENDOK(IDC_ZOOMS, OnSelEnd)
  	ON_COMMAND(IDOK, OnOK)
  END_MESSAGE_MAP()
***************
*** 43,49 ****
--- 45,182 ----
  // CModelPropertiesDlgBar message handlers
  
+ void CModelPropertiesDlgBar::writeNumToEdit(CEdit *edit, int kk)
+ {
+ 	if (!edit)
+ 	{
+ 		CWnd* zoom = GetDlgItem(IDC_ZOOMS);
+ 		edit = (CEdit*)(zoom->GetDlgItem(1001));
+ 	}
+ 	char buff[100];
+ 	edit->SetSel(0, -1);
+ 	itoa(kk, buff, 10);
+ 	CString str = buff;
+ 	str += "%";
+ 	edit->ReplaceSel(str);
+ }
+ 
  void CModelPropertiesDlgBar::OnOK()
  {
+ 	// enter pressed on which item
+ 	CWnd* fwin = GetFocus();
+ 	CWnd* zoom = GetDlgItem(IDC_ZOOMS);
+ 	CEdit* edit = (CEdit*)(zoom->GetDlgItem(1001));
+ 	if (fwin->m_hWnd == edit->m_hWnd)
+ 	{
+ 		char buff[100];
+ 		int len = edit->GetLine(0, buff, sizeof(buff)-1);
+ 		int kk = atoi(buff);
+ 		kk = abs(kk);
+ 		if (!kk)
+ 			kk = 100;
+ 		// send message to zoom with (userdefined=true, kk)
+ 		((CFrameWnd*)GetParent())->GetActiveView()->PostMessage(WM_USER_ZOOM, (WPARAM)TRUE, (LPARAM)kk);
+ 		writeNumToEdit(edit, kk);
+ 	}
  	((CFrameWnd*)GetParent())->GetActiveView()->SetFocus();
  }
+ 
+ 
+ void CModelPropertiesDlgBar::OnSelEnd()
+ {
+ 	// item chosen from list -> zoom 
+ 	CComboBox* zoom = (CComboBox*)GetDlgItem(IDC_ZOOMS);
+ 	int item = zoom->GetCurSel();
+ 	if (item != CB_ERR)
+ 	{
+ 		int kk = m_zoomlist[item];
+ 		// send message to zoom with (userdefined=false, kk)
+ 		((CFrameWnd*)GetParent())->GetActiveView()->PostMessage(WM_USER_ZOOM, (WPARAM)FALSE, (LPARAM)kk);
+ 	}
+ 	((CFrameWnd*)GetParent())->GetActiveView()->SetFocus();
+ }
+ 
+ void CModelPropertiesDlgBar::SetZoomList(int *list)
+ {
+ 	// supposed it is sorted
+ 	if (!list)
+ 		return;
+ 	for (int i=0; list[i] && i<MAX_ZOOM-1; i++)
+ 	{
+ 		m_zoomlist[i] = list[i];
+ 	}
+ 	m_zoomlist[i] = 0;
+ 	CComboBox* zoom = (CComboBox*)GetDlgItem(IDC_ZOOMS);
+ 	for (int k=0; m_zoomlist[k]; k++)
+ 	{
+ 		CString str;
+ 		if (m_zoomlist[k] > 0)
+ 		{
+ 			char buff[100];
+ 			itoa(m_zoomlist[k], buff, 10);
+ 			str = buff;
+ 			str += "%";
+ 		}
+ 		else
+ 		{
+ 			switch (m_zoomlist[k])
+ 			{
+ 			case ZOOM_WIDTH:
+ 				str = "Fit Width";
+ 				break;
+ 			case ZOOM_HEIGHT:
+ 				str = "Fit Height";
+ 				break;
+ 			case ZOOM_ALL:
+ 				str = "Fit All";
+ 				break;
+ 			}
+ 		}
+ 		zoom->AddString(str);
+ 	}
+ }
+ 
+ void CModelPropertiesDlgBar::SetZoomVal(int kk)
+ {
+ 	// only to the edit box
+ 	if (kk <= 0)
+ 		return;
+ 	writeNumToEdit(NULL, kk);
+ }
+ 
+ void CModelPropertiesDlgBar::NextZoomVal(int &kk)
+ {
+ 	// related to the current one in the edit box 
+ 	CComboBox* zoom = (CComboBox*)GetDlgItem(IDC_ZOOMS);
+ 	CEdit* edit = (CEdit*)(zoom->GetDlgItem(1001));
+ 	char buff[100];
+ 	int len = edit->GetLine(0, buff, sizeof(buff)-1);
+ 	kk = atoi(buff);
+ 	if (!kk)
+ 		kk = 100;
+ 	for (int i=0; m_zoomlist[i]  &&  m_zoomlist[i]<=kk; i++);
+ 	if (m_zoomlist[i])
+ 	{
+ 		kk = m_zoomlist[i];
+ 		writeNumToEdit(edit, kk);
+ 	}
+ }
+ 
+ void CModelPropertiesDlgBar::PrevZoomVal(int &kk)
+ {
+ 	// related to the current one in the edit box 
+ 	CComboBox* zoom = (CComboBox*)GetDlgItem(IDC_ZOOMS);
+ 	CEdit* edit = (CEdit*)(zoom->GetDlgItem(1001));
+ 	char buff[100];
+ 	int len = edit->GetLine(0, buff, sizeof(buff)-1);
+ 	kk = atoi(buff);
+ 	if (!kk)
+ 		kk = 100;
+ 	for (int i=0; m_zoomlist[i]  &&  m_zoomlist[i]<kk; i++);
+ 	if (m_zoomlist[i]  &&  i)
+ 	{
+ 		kk = m_zoomlist[i-1];
+ 		writeNumToEdit(edit, kk);
+ 	}
+ }
+ 
  



More information about the GME-commit mailing list