Dialog_Columns and units Comments please


Subject: Dialog_Columns and units Comments please
From: Robert Altenburg (rca@xlation.com)
Date: Mon Feb 04 2002 - 22:32:51 CST


After making changes to ap_Dialog_Columns.cpp
so the units dialog matched the rulers, It was
brought to my attention that if you type
a value in the field, but forget to type
valid units, the value will be silently
ignored by ap_UnixDialog_Columns.cpp.

I took out that "filter" and patched
ap_Dialog_Columns.cpp to always assume the
default units if it doesn't recognize what
it gets. Since the gtk signal set up for this
box is "change" it makes it impossible to use
the box to change the units.

I am thinking it's fair to expect a user to change
unit preferences in one place (well currently two,
but that is another issue), but less so to
force them to type units when they enter values.

The attached diff (gtk only) applies this "fix".

Comments?

Index: src/wp/ap/unix/ap_UnixDialog_Columns.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixDialog_Columns.cpp,v
retrieving revision 1.18
diff -u -r1.18 ap_UnixDialog_Columns.cpp
--- src/wp/ap/unix/ap_UnixDialog_Columns.cpp 2002/02/01 18:11:38 1.18
+++ src/wp/ap/unix/ap_UnixDialog_Columns.cpp 2002/02/05 03:56:33
@@ -403,8 +403,8 @@
 void AP_UnixDialog_Columns::doMaxHeightEntry(void)
 {
         const char * szHeight = gtk_entry_get_text(GTK_ENTRY(m_wMaxColumnHeightEntry));
- if(UT_determineDimension(szHeight,DIM_none) != DIM_none)
- {
+ //if(UT_determineDimension(szHeight,DIM_none) != DIM_none)
+ //{
                 setMaxHeight(szHeight);
 
                 gtk_signal_handler_block(GTK_OBJECT(m_wMaxColumnHeightEntry), m_iMaxColumnHeightID);
@@ -412,14 +412,14 @@
                 gtk_entry_set_text( GTK_ENTRY(m_wMaxColumnHeightEntry),getHeightString() );
                 gtk_entry_set_position(GTK_ENTRY(m_wMaxColumnHeightEntry), pos);
                 gtk_signal_handler_unblock(GTK_OBJECT(m_wMaxColumnHeightEntry), m_iMaxColumnHeightID);
- }
+ //}
 }
 
 void AP_UnixDialog_Columns::doSpaceAfterEntry(void)
 {
         const char * szAfter = gtk_entry_get_text(GTK_ENTRY(m_wSpaceAfterEntry));
- if(UT_determineDimension(szAfter,DIM_none) != DIM_none)
- {
+ //if(UT_determineDimension(szAfter,DIM_none) != DIM_none)
+ //{
                 setSpaceAfter(szAfter);
 
                 gtk_signal_handler_block(GTK_OBJECT(m_wSpaceAfterEntry), m_iSpaceAfterID);
@@ -427,7 +427,7 @@
                 gtk_entry_set_text( GTK_ENTRY(m_wSpaceAfterEntry),getSpaceAfterString() );
                 gtk_entry_set_position(GTK_ENTRY(m_wSpaceAfterEntry), pos);
                 gtk_signal_handler_unblock(GTK_OBJECT(m_wSpaceAfterEntry),m_iSpaceAfterID);
- }
+ //}
 }
 
 void AP_UnixDialog_Columns::event_Cancel(void)
Index: src/wp/ap/xp/ap_Dialog_Columns.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Dialog_Columns.cpp,v
retrieving revision 1.13
diff -u -r1.13 ap_Dialog_Columns.cpp
--- src/wp/ap/xp/ap_Dialog_Columns.cpp 2002/02/02 12:25:02 1.13
+++ src/wp/ap/xp/ap_Dialog_Columns.cpp 2002/02/05 03:56:39
@@ -312,18 +312,22 @@
 void AP_Dialog_Columns::setMaxHeight(const char * szHeight)
 {
         UT_Dimension dim = UT_determineDimension(szHeight, DIM_none);
- if(dim != DIM_none)
+ if (dim == DIM_none)
         {
- m_bMaxHeightChanged = true;
- m_HeightString = szHeight;
- double dum = UT_convertToInches(getHeightString());
- if(dum < 0.0)
- {
- m_HeightString = UT_convertInchesToDimensionString(dim,0.0);
- }
- if(m_pColumnsPreview)
- m_pColumnsPreview->set(m_iColumns, m_bLineBetween);
+ double dval = UT_convertDimensionless(szHeight);
+ const char * pdname = UT_dimensionName(m_PreferedUnits);
+ const char * pval = UT_formatDimensionedValue(dval, pdname);
+ UT_XML_strncpy((XML_Char *) szHeight, 25, (const XML_Char *) pval);
         }
+ m_bMaxHeightChanged = true;
+ m_HeightString = szHeight;
+ double dum = UT_convertToInches(getHeightString());
+ if(dum < 0.0)
+ {
+ m_HeightString = UT_convertInchesToDimensionString(dim,0.0);
+ }
+ if(m_pColumnsPreview)
+ m_pColumnsPreview->set(m_iColumns, m_bLineBetween);
 }
 
 /*!
@@ -333,18 +337,22 @@
 void AP_Dialog_Columns::setSpaceAfter(const char * szAfter)
 {
         UT_Dimension dim = UT_determineDimension(szAfter, DIM_none);
- if(dim != DIM_none)
+ if (dim == DIM_none)
+ {
+ double dval = UT_convertDimensionless(szAfter);
+ const char * pdname = UT_dimensionName(m_PreferedUnits);
+ const char * pval = UT_formatDimensionedValue(dval, pdname);
+ UT_XML_strncpy((XML_Char *) szAfter, 25, (const XML_Char *) pval);
+ }
+ m_bSpaceAfterChanged = true;
+ m_SpaceAfterString = szAfter;
+ double dum = UT_convertToInches(getSpaceAfterString());
+ if(dum < 0.0)
         {
- m_bSpaceAfterChanged = true;
- m_SpaceAfterString = szAfter;
- double dum = UT_convertToInches(getSpaceAfterString());
- if(dum < 0.0)
- {
- m_SpaceAfterString = UT_convertInchesToDimensionString(dim,0.0);
- }
- if(m_pColumnsPreview)
- m_pColumnsPreview->set(m_iColumns, m_bLineBetween);
+ m_SpaceAfterString = UT_convertInchesToDimensionString(dim,0.0);
         }
+ if(m_pColumnsPreview)
+ m_pColumnsPreview->set(m_iColumns, m_bLineBetween);
 }
 
 
@@ -367,17 +375,14 @@
 */
 void AP_Dialog_Columns::_convertToPreferredUnits(XAP_Frame * pFrame,const char *sz, const XML_Char *pRet)
 {
- UT_Dimension PreferedUnits = DIM_none;
         const XML_Char * pszRulerUnits = NULL;
-
         if (pFrame->getApp()->getPrefsValue(AP_PREF_KEY_RulerUnits, &pszRulerUnits))
         {
- PreferedUnits = UT_determineDimension((char *)pszRulerUnits);
+ m_PreferedUnits = UT_determineDimension((char *)pszRulerUnits);
         };
- UT_XML_strncpy((XML_Char *) pRet, 25, (const XML_Char *) UT_reformatDimensionString(PreferedUnits,sz));
+ UT_XML_strncpy((XML_Char *) pRet, 25, (const XML_Char *) UT_reformatDimensionString(m_PreferedUnits,sz));
 }
 
-
 //////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////
 
Index: src/wp/ap/xp/ap_Dialog_Columns.h
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Dialog_Columns.h,v
retrieving revision 1.7
diff -u -r1.7 ap_Dialog_Columns.h
--- src/wp/ap/xp/ap_Dialog_Columns.h 2002/02/02 12:25:02 1.7
+++ src/wp/ap/xp/ap_Dialog_Columns.h 2002/02/05 03:56:40
@@ -135,6 +135,7 @@
         double m_dMarginBottom;
         double m_dMarginLeft;
         double m_dMarginRight;
+ UT_Dimension m_PreferedUnits;
 };
 
 #endif /* AP_Dialog_Columns_H */



This archive was generated by hypermail 2b25 : Mon Feb 04 2002 - 22:26:54 CST