[GME-commit] GMESRC/GME/MgaUtil GmeDlg.cpp,1.10,1.11 GmeDlg.h,1.9,1.10 MgaRegistrar.cpp,1.41,1.42 MgaRegistrar.h,1.18,1.19 MgaUtil.rc,1.46,1.47 resource.h,1.27,1.28

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Tue Jun 21 20:40:41 CDT 2005


Update of /project/gme-repository/GMESRC/GME/MgaUtil
In directory escher:/tmp/cvs-serv8888

Modified Files:
	GmeDlg.cpp GmeDlg.h MgaRegistrar.cpp MgaRegistrar.h MgaUtil.rc 
	resource.h 
Log Message:
Default zoom value setting introduced.


CVS User: Zoltan Molnar, ISIS (zolmol)

Index: MgaUtil.rc
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/MgaUtil.rc,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** MgaUtil.rc	21 Apr 2005 21:55:23 -0000	1.46
--- MgaUtil.rc	21 Jun 2005 19:40:38 -0000	1.47
***************
*** 65,72 ****
  END
  
! IDD_GMEDLG DIALOG  0, 0, 247, 366
  STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
  CAPTION "GME properties"
! FONT 8, "MS Sans Serif"
  BEGIN
      EDITTEXT        IDC_ICONPATH,10,15,190,15,ES_AUTOHSCROLL
--- 65,72 ----
  END
  
! IDD_GMEDLG DIALOGEX 0, 0, 247, 386
  STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
  CAPTION "GME properties"
! FONT 8, "MS Sans Serif", 0, 0, 0x0
  BEGIN
      EDITTEXT        IDC_ICONPATH,10,15,190,15,ES_AUTOHSCROLL
***************
*** 95,103 ****
                      WS_BORDER | WS_TABSTOP,84,240,152,74
      CONTROL         "Open model in multiple views",IDC_MULTIPLE_OPEN,"Button",
!                     BS_AUTOCHECKBOX | WS_TABSTOP,10,325,107,10
      CONTROL         "Enable Event Logging",IDC_EVENT_LOGGING,"Button",
!                     BS_AUTOCHECKBOX | WS_TABSTOP,125,325,86,10
!     DEFPUSHBUTTON   "OK",IDOK,48,342,50,15
!     PUSHBUTTON      "Cancel",IDCANCEL,139,342,50,15
      GROUPBOX        "User Icon Path",IDC_STATIC,5,5,235,30
      GROUPBOX        "System Icon Path",IDC_STATIC,5,40,235,30
--- 95,103 ----
                      WS_BORDER | WS_TABSTOP,84,240,152,74
      CONTROL         "Open model in multiple views",IDC_MULTIPLE_OPEN,"Button",
!                     BS_AUTOCHECKBOX | WS_TABSTOP,10,351,107,10
      CONTROL         "Enable Event Logging",IDC_EVENT_LOGGING,"Button",
!                     BS_AUTOCHECKBOX | WS_TABSTOP,125,351,86,10
!     DEFPUSHBUTTON   "OK",IDOK,48,370,50,15
!     PUSHBUTTON      "Cancel",IDCANCEL,139,370,50,15
      GROUPBOX        "User Icon Path",IDC_STATIC,5,5,235,30
      GROUPBOX        "System Icon Path",IDC_STATIC,5,40,235,30
***************
*** 109,112 ****
--- 109,117 ----
      GROUPBOX        "Scripting",IDC_STATIC,6,230,235,90
      LTEXT           "Current script engine:",IDC_STATIC,11,241,72,11
+     COMBOBOX        IDC_ZOOMS,174,329,50,272,CBS_DROPDOWN | WS_VSCROLL | 
+                     WS_TABSTOP
+     LTEXT           "Use this Zooming value when opening models:",IDC_STATIC,
+                     12,332,152,9
+     GROUPBOX        "Zooming",IDC_STATIC,7,321,233,23
  END
  
***************
*** 676,680 ****
          RIGHTMARGIN, 240
          TOPMARGIN, 7
!         BOTTOMMARGIN, 357
      END
  
--- 681,685 ----
          RIGHTMARGIN, 240
          TOPMARGIN, 7
!         BOTTOMMARGIN, 385
      END
  

Index: GmeDlg.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/GmeDlg.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** GmeDlg.cpp	26 Jan 2005 17:30:52 -0000	1.10
--- GmeDlg.cpp	21 Jun 2005 19:40:38 -0000	1.11
***************
*** 9,23 ****
  #include "comcat.h"
  //#include "basetyps.h"
- //#define INITGUID
- #if(0) //z7
- #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
-         const GUID name \
-                 = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } } 
- // DEFINE_GUID(CATID_ActiveScript, 0xf0b7a1a1, 0x9847, 0x11cf, 0x8f, 0x20, 0x0, 0x80, 0x5f, 0x2c, 0xd0, 0x64);
- #endif
- //DEFINE_GUID(CATID_ActiveScript, 0xf0b7a1a1, 0x9847, 0x11cf, 0x8f, 0x20, 0x0, 0x80, 0x5f, 0x2c, 0xd0, 0x64);
  const GUID CATID_ActiveScript = { 0xf0b7a1a1, 0x9847, 0x11cf, { 0x8f, 0x20, 0x0, 0x80, 0x5f, 0x2c, 0xd0, 0x64} };
- /*EXTERN_C*/ //GUID CATID_ActiveScript;
- //#include "activscp.h"
  
  #ifdef _DEBUG
--- 9,13 ----
***************
*** 27,30 ****
--- 17,24 ----
  #endif
  
+ /*static*/ const char * CGmeDlg::m_strZWidth   = "Fit Width";
+ /*static*/ const char * CGmeDlg::m_strZHeight  = "Fit Height";
+ /*static*/ const char * CGmeDlg::m_strZAll     = "Fit All";
+ 
  /////////////////////////////////////////////////////////////////////////////
  // CGmeDlg dialog
***************
*** 300,303 ****
--- 294,307 ----
  		if (m_scriptEngine == "")
  			m_scriptEngine = _T("JScript");
+ 
+ 		// Zoom
+ 		// COMMENT:
+ 		// commented out until GMEView and other classes are capable of drawing at once in ZOOM_WIDTH,Z_HEIGHT,Z_ALL mode
+ 		//int zommvals[] = {ZOOM_MIN, 10, 25, 50, 75, ZOOM_NO, 150, 200, 300, ZOOM_MAX,ZOOM_WIDTH,ZOOM_HEIGHT,ZOOM_ALL,0};
+ 		int zommvals[] = {ZOOM_MIN, 10, 25, 50, 75, ZOOM_NO, 150, 200, 300, ZOOM_MAX,0};
+ 		fillZoomComboBox( zommvals);
+ 
+ 		CString set_val = getZoomValueFromReg();
+ 		setZoomValue( set_val);
  	}
  	MSGCATCH("Error while initializing GmeDlg",;)
***************
*** 361,364 ****
--- 365,371 ----
  	COMTHROW( registrar->put_ScriptEngine(REGACCESS_USER, PutInBstr(m_scriptEngine)) );
  
+ 	// Zoom
+ 	CString val_sel = getZoomValue();
+ 	COMTHROW( registrar->SetDefZoomLevel( REGACCESS_USER, PutInBstr(val_sel)));
  }
  
***************
*** 447,448 ****
--- 454,601 ----
  	ExtControlManager();
  }
+ 
+ void CGmeDlg::fillZoomComboBox(int *list)
+ {
+ 	if (!list) return;
+ 
+ 	// supposed it is sorted, copy the values into the member
+ 	for( int i=0; list[i] != 0 && i < MAX_ZOOM-1; ++i)
+ 	{
+ 		m_zoomList[i] = list[i];
+ 	}
+ 	if( i <= MAX_ZOOM-1) m_zoomList[i] = 0;
+ 
+ 	// transform the integer values to strings, and add to the comboBox
+ 	CComboBox* zoom = 0;
+ 	zoom = (CComboBox*)GetDlgItem(IDC_ZOOMS);
+ 	for( int k=0; m_zoomList[k] != 0; ++k)
+ 	{
+ 		CString str;
+ 		if (m_zoomList[k] > 0)
+ 		{
+ 			char buff[100];
+ 			itoa(m_zoomList[k], buff, 10);
+ 			str = buff;
+ 			str += "%";
+ 		}
+ 		/*else	// commented out for a while (see COMMENT above)
+ 		{
+ 			switch (m_zoomList[k])
+ 			{
+ 			case ZOOM_WIDTH:
+ 				str = m_strZWidth;
+ 				break;
+ 			case ZOOM_HEIGHT:
+ 				str = m_strZHeight;
+ 				break;
+ 			case ZOOM_ALL:
+ 				str = m_strZAll;
+ 				break;
+ 			}
+ 		}*/
+ 		zoom->AddString(str);
+ 	}
+ }
+ 
+ void CGmeDlg::setZoomValue(CString& val )
+ {
+ 	CWnd* zoom = 0;
+ 	zoom = GetDlgItem(IDC_ZOOMS);
+ 	if( zoom) 
+ 	{
+ 		CEdit* edit = 0;
+ 		edit = (CEdit*)(zoom->GetDlgItem(1001));
+ 		if( edit) 
+ 		{
+ 			edit->ReplaceSel( val);
+ 		}
+ 	}
+ }
+ 
+ CString CGmeDlg::getZoomValue()
+ {
+ 	CString res("100");
+ 	CWnd* zoom = 0;
+ 	zoom = GetDlgItem(IDC_ZOOMS);
+ 	if (zoom)
+ 	{
+ 		CEdit* edit = 0;
+ 		edit = (CEdit*)(zoom->GetDlgItem(1001));
+ 		if (edit)
+ 		{
+ 			char buff[100];
+ 			edit->GetLine(0, buff, sizeof(buff)-1);
+ 
+ 			int zv = 0;
+ 			/* for now accept only positive numbers, commented out, see COMMENT above
+ 			if( strcmp( m_strZWidth, buff) == 0)
+ 				zv = ZOOM_WIDTH;
+ 			else if( strcmp( m_strZHeight, buff) == 0)
+ 				zv = ZOOM_HEIGHT;
+ 			else if( strcmp( m_strZAll, buff) == 0)
+ 				zv = ZOOM_ALL;
+ 			else
+ 			{
+ 				int l = _stscanf( buff, _T("%d"), &zv);
+ 				if( l != 1 || zv < ZOOM_MIN || zv > ZOOM_MAX)
+ 					zv = 100;
+ 			}
+ 			
+ 			if( !zv || zv > 0 && zv < ZOOM_MIN || zv > 0 && zv > ZOOM_MAX 
+ 				|| zv < 0 && zv != ZOOM_WIDTH && zv != ZOOM_HEIGHT && zv != ZOOM_ALL) 
+ 				zv = 100;
+ 			*/
+ 
+ 			int l = _stscanf( buff, _T("%d"), &zv);
+ 			if( l != 1 || zv < ZOOM_MIN || zv > ZOOM_MAX)
+ 				zv = 100;
+ 
+ 			itoa(zv, buff, 10);
+ 			res = buff;
+ 		}
+ 	}
+ 	return res;
+ }
+ 
+ CString CGmeDlg::getZoomValueFromReg()
+ {
+ 	CString def_zoom;
+ 	CComBSTR bs_def_zoom;
+ 	COMTHROW( registrar->GetDefZoomLevel( REGACCESS_USER, &bs_def_zoom));
+ 	if( bs_def_zoom) 
+ 		CopyTo( bs_def_zoom, def_zoom);
+ 
+ 	int level = 100;
+ 	int zv = 0;
+ 	int l = _stscanf( (LPCTSTR) def_zoom, _T("%d"), &zv);
+ 	if( l == 1 && zv )
+ 		level = zv;
+ 
+ 	CString str;
+ 	if (level > 0)
+ 	{
+ 		char buff[100];
+ 		itoa(level, buff, 10);
+ 		str = buff;
+ 		str += "%";
+ 	}
+ 	/*else // for now do not accept: ZOOM_WIDTH, ZOOM_HEIGHT, ZOOM_ALL values from the registry, see COMMENT above
+ 	{
+ 		switch (level)
+ 		{
+ 		case ZOOM_WIDTH:
+ 			str = m_strZWidth;
+ 			break;
+ 		case ZOOM_HEIGHT:
+ 			str = m_strZHeight;
+ 			break;
+ 		case ZOOM_ALL:
+ 			str = m_strZAll;
+ 			break;
+ 		}
+ 	}*/
+ 	
+ 	if( str.IsEmpty())
+ 		str = "100%";
+ 	return str;
+ }
\ No newline at end of file

Index: MgaRegistrar.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/MgaRegistrar.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** MgaRegistrar.cpp	26 Jan 2005 17:30:52 -0000	1.41
--- MgaRegistrar.cpp	21 Jun 2005 19:40:38 -0000	1.42
***************
*** 605,608 ****
--- 605,658 ----
  }
  
+ STDMETHODIMP CMgaRegistrar::GetDefZoomLevel(regaccessmode_enum p_mode, BSTR *p_zlev)
+ {
+ 	CHECK_OUT(p_zlev);
+ 	COMTRY
+ 	{
+ 		LONG res;
+ 		CString str;
+ 		if(p_mode & RM_USER) {
+ 			CRegKey mga;
+ 			res = mga.Open(HKEY_CURRENT_USER, rootreg, KEY_READ);
+ 			if(res != ERROR_SUCCESS && res != ERROR_ACCESS_DENIED && res != ERROR_FILE_NOT_FOUND) ERRTHROW(res);
+ 			if(res == ERROR_SUCCESS) {
+ 				str	= QueryValue(mga, "DefaultZoomLevel");
+ 				if(!str.IsEmpty()) REVOKE_SYS2(p_mode);
+ 			}
+ 		}
+ 		if(p_mode & (RM_SYSDOREAD)) {
+ 			CRegKey mga;
+ 			res = mga.Open(HKEY_LOCAL_MACHINE, rootreg, KEY_READ);
+ 			if(res != ERROR_SUCCESS && res != ERROR_ACCESS_DENIED && res != ERROR_FILE_NOT_FOUND) ERRTHROW(res);
+ 			if(res == ERROR_SUCCESS) {
+ 				str = QueryValue(mga, "DefaultZoomLevel");
+ 			}
+ 		}
+ 		CopyTo(str, p_zlev);
+ 	}
+ 	COMCATCH(;)
+ 
+ }
+ 
+ STDMETHODIMP CMgaRegistrar::SetDefZoomLevel(regaccessmode_enum p_mode, BSTR p_zlev)
+ {
+ 	COMTRY
+ 	{
+ 		CString str;
+ 		CopyTo(p_zlev, str);
+ 		if(p_mode & RM_USER) {
+ 			CRegKey mga;
+ 			ERRTHROW( mga.Create(HKEY_CURRENT_USER, rootreg) );
+ 			ERRTHROW( mga.SetStringValue( "DefaultZoomLevel", str));
+ 		}
+ 		if(p_mode & (RM_SYS | RM_TEST)) {
+ 			CRegKey mga;
+ 			ERRTHROW( mga.Create(HKEY_LOCAL_MACHINE, rootreg) );
+ 			if(p_mode & RM_SYS) ERRTHROW( mga.SetStringValue( "DefaultZoomLevel", str));
+ 		}
+ 	}
+ 	COMCATCH(;)
+ }
+ 
  STDMETHODIMP CMgaRegistrar::get_Paradigms(regaccessmode_enum mode, VARIANT *names)
  {

Index: MgaRegistrar.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/MgaRegistrar.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** MgaRegistrar.h	2 Dec 2004 22:02:14 -0000	1.18
--- MgaRegistrar.h	21 Jun 2005 19:40:38 -0000	1.19
***************
*** 49,52 ****
--- 49,54 ----
  	STDMETHOD(get_ScriptEngine)(regaccessmode_enum mode, BSTR *path);
  	STDMETHOD(put_ScriptEngine)(regaccessmode_enum mode, BSTR path);
+ 	STDMETHOD(GetDefZoomLevel)(regaccessmode_enum mode, BSTR *zlevel);
+ 	STDMETHOD(SetDefZoomLevel)(regaccessmode_enum mode, BSTR zlevel);
  
  	STDMETHOD(get_Paradigms)(regaccessmode_enum mode, VARIANT *names);

Index: resource.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/resource.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** resource.h	29 Sep 2004 21:00:28 -0000	1.27
--- resource.h	21 Jun 2005 19:40:38 -0000	1.28
***************
*** 1,4 ****
  //{{NO_DEPENDENCIES}}
! // Microsoft Developer Studio generated include file.
  // Used by MgaUtil.rc
  //
--- 1,4 ----
  //{{NO_DEPENDENCIES}}
! // Microsoft Visual C++ generated include file.
  // Used by MgaUtil.rc
  //
***************
*** 7,10 ****
--- 7,11 ----
  #define IDD_CONNPROPERTIES_DIALOG       157
  #define IDD_REGISTRY_BROWSER            169
+ #define IDC_ZOOMS                       1008
  #define IDC_OBJECTID                    1016
  #define IDC_LIBRARY                     1017

Index: GmeDlg.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/GmeDlg.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** GmeDlg.h	26 Jan 2005 17:30:52 -0000	1.9
--- GmeDlg.h	21 Jun 2005 19:40:38 -0000	1.10
***************
*** 8,11 ****
--- 8,20 ----
  //
  
+ // copied from GmeStd.h, keep in sync with that!
+ #define ZOOM_WIDTH	-1
+ #define ZOOM_HEIGHT	-2
+ #define ZOOM_ALL	-3
+ #define ZOOM_MIN	5
+ #define ZOOM_MAX	500
+ #define ZOOM_NO		100
+ #define MAX_ZOOM	100  // the number of zoom levels
+ 
  /////////////////////////////////////////////////////////////////////////////
  // CGmeDlg dialog
***************
*** 71,74 ****
--- 80,93 ----
  private:
  	void fillScripEngineList();
+ 
+ 	CString getZoomValueFromReg();
+ 	void fillZoomComboBox(int *list);
+ 	void setZoomValue(CString& val);
+ 	CString getZoomValue();
+ 	int m_zoomList[MAX_ZOOM];
+ 
+ 	static const char * m_strZWidth;   // "Fit Width";
+ 	static const char * m_strZHeight;  // "Fit Height";
+ 	static const char * m_strZAll;     // "Fit All";
  
  };



More information about the GME-commit mailing list