Update of /cvsroot/mahogany/M/src/gui
In directory usw-pr-cvs1:/tmp/cvs-serv31571/src/gui

Modified Files:
        wxFiltersDialog.cpp 
Log Message:
more filter dialog improvements from Michael A. Chase

Index: wxFiltersDialog.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxFiltersDialog.cpp,v
retrieving revision 1.100
retrieving revision 1.101
diff -b -u -2 -r1.100 -r1.101
--- wxFiltersDialog.cpp 19 Oct 2002 14:12:47 -0000      1.100
+++ wxFiltersDialog.cpp 30 Oct 2002 12:51:17 -0000      1.101
@@ -117,5 +117,5 @@
          return i; \
    } \
-   CHECK(false, default, _T("choice not in " #T)); \
+   CHECK(false, default, _T("choice not implemented in " #T)); \
 }
 
@@ -214,7 +214,7 @@
 {
    // Must be in the same order as ORC_W_Swap[]
-   gettext_noop("in subject"),          // ORC_W_Subject
    gettext_noop("in from"),             // ORC_W_From
    gettext_noop("in to"),               // ORC_W_To
+   gettext_noop("in subject"),          // ORC_W_Subject
    gettext_noop("in sender"),           // ORC_W_Sender
    gettext_noop("in any recipient"),    // ORC_W_Recipients
@@ -233,7 +233,7 @@
 {
    // Must be in the same order as ORC_Where[]
-   ORC_W_Subject,
    ORC_W_From,
    ORC_W_To,
+   ORC_W_Subject,
    ORC_W_Sender,
    ORC_W_Recipients,
@@ -261,7 +261,7 @@
 {
    // Must be in the same order as OAC_T_Swap[]
-   gettext_noop("Delete"),              // OAC_T_Delete
-   gettext_noop("Copy to"),             // OAC_T_CopyTo
    gettext_noop("Move to"),             // OAC_T_MoveTo
+   gettext_noop("Copy to"),             // OAC_T_CopyTo
+   gettext_noop("Delete"),              // OAC_T_Delete
    gettext_noop("Expunge"),             // OAC_T_Expunge
    gettext_noop("Zap"),                 // OAC_T_Zap
@@ -286,7 +286,7 @@
 {
    // Must be in the same order as OAC_Types[]
-   OAC_T_Delete,
-   OAC_T_CopyTo,
    OAC_T_MoveTo,
+   OAC_T_CopyTo,
+   OAC_T_Delete,
    OAC_T_Expunge,
    OAC_T_Zap,
@@ -301,6 +301,6 @@
    OAC_T_ClearFlag
 };
-ENUM_fromSelect(MFDialogAction, OAC_T_Swap, OAC_TypesCountS, OAC_T_Delete)
-ENUM_toSelect(  MFDialogAction, OAC_T_Swap, OAC_TypesCountS, OAC_T_Delete)
+ENUM_fromSelect(MFDialogAction, OAC_T_Swap, OAC_TypesCountS, OAC_T_MoveTo)
+ENUM_toSelect(  MFDialogAction, OAC_T_Swap, OAC_TypesCountS, OAC_T_MoveTo)
 
 static const
@@ -497,6 +497,11 @@
    String GetArgument() const
    {
-      switch ( GetTest() )
+      MFDialogTest test = GetTest();
+      if ( ! FilterTestNeedsArgument(test) )
+         return ""; // Don't return the value if it won't be used
+
+      switch ( test )
       {
+         // spam tests or message flags are decoded separately
          case ORC_T_IsSpam: return GetSpamTestArgument();
          case ORC_T_HasFlag:
@@ -511,5 +516,6 @@
             }
             CHECK( false, "", _T("Invalid test message flag") );
-            break;
+
+         // Argument is used, but not for spam or message flag
          default: return m_Argument->GetValue();
       }
@@ -582,19 +588,23 @@
    m_btnSpam = NULL;
 
-   // only create the logical condition (And/Or) control if we have something
-   // to combine this one with
    if ( previous )
    {
+      // only create the logical condition (And/Or) control if we have
+      // something to combine this one with
       m_Logical = new wxChoice(parent, -1, wxDefaultPosition,
                                wxDefaultSize, ORC_LogicalCount,
                                ORC_Logical);
-      m_Not = new wxCheckBox(parent, -1, _("Not"));
+
+      // take the value from the preceding control, if any, instead of default
+      // as it is usually more convenient (user usually creates filter of the
+      // form "foo AND bar AND baz" or "foo OR bar OR baz"...)
+      wxChoice *prevLogical = previous->m_Logical;
+      m_Logical->SetSelection(prevLogical ? prevLogical->GetSelection()
+                              : ORC_L_Or);
    }
    else
-   {
       m_Logical = NULL;
-      m_Not = new wxCheckBox(parent, -1, _("Not"));
-   }
 
+   m_Not = new wxCheckBox(parent, -1, _("Not"));
    m_Type = new wxChoice(parent, -1, wxDefaultPosition,
                          wxDefaultSize, ORC_TypesCountS, ORC_Types);
@@ -607,14 +617,4 @@
    // set up the initial values or the code in UpdateProgram() would complain
    // about invalid values
-   if ( m_Logical )
-   {
-      // take the values from the preceding control, if any, instead of default
-      // as it is usually more convenient (user usually creates filter of the
-      // form "foo AND bar AND baz" or "foo OR bar OR baz"...)
-      wxChoice *prevLogical = previous->m_Logical;
-      m_Logical->SetSelection(prevLogical ? prevLogical->GetSelection()
-                              : ORC_L_Or);
-   }
-
    m_Type->SetSelection(MFDialogTest_toSelect(ORC_T_Contains));
    m_choiceFlags->SetSelection(ORC_MF_Unseen);
@@ -715,7 +715,4 @@
 OneCritControl::UpdateUI(wxTextCtrl *textProgram)
 {
-   if ( m_Type->GetSelection() == -1 ) // use raw selection value here
-      return; // do nothing if not a valid test
-
    // decide what to show and enable
    MFDialogTest test   = GetTest();
@@ -726,14 +723,4 @@
    bool enable_target  = FilterTestNeedsTarget(test);
 
-   // don't leave anything in the argument if it's not needed for this test
-   if ( !enable_arg )
-   {
-      // NB: don't call SetValue() unconditionally because it results in
-      //     another callback generated by wxGTK even if the text control
-      //     is already empty!
-      if ( !m_Argument->GetValue().empty() )
-         m_Argument->SetValue("");
-   }
-
    // disable everything if test not implemented
    if ( ! FilterTestImplemented(test) )
@@ -1101,4 +1088,9 @@
    String GetArgument() const
    {
+      MFDialogAction action = GetAction();
+      if ( ! FilterActionNeedsArg(action) )
+         return ""; // Don't return the value if it won't be used
+ 
+      // message flags are decoded separately
       if ( FilterActionMsgFlag(GetAction()) )
       {
@@ -1114,5 +1106,6 @@
          CHECK( false, "", _T("Invalid action message flag") );
       }
-      else
+
+      // Argument is used, but not for message flag
          return m_Argument->GetValue();
    }
@@ -1161,14 +1154,4 @@
    bool enable_folder  = FilterActionUsesFolder(type);
 
-   // don't leave anything in the argument if it's not needed for this action
-   if ( !enable_arg )
-   {
-      // NB: don't call SetValue() unconditionally because it results in
-      //     another callback generated by wxGTK even if the text control
-      //     is already empty!
-      if ( !m_Argument->GetValue().empty() )
-         m_Argument->SetValue("");
-   }
-
    // disable everything if action not implemented
    if ( ! FilterActionImplemented(type) )
@@ -1182,10 +1165,14 @@
    m_choiceFlags->Show(enable_msgflag);
    m_choiceFlags->Enable(enable_msgflag);
-   m_Argument->Show(enable_arg);
-   m_Argument->Enable(enable_arg);
    m_btnColour->Show(enable_colour);
    m_btnColour->Enable(enable_colour);
    m_btnFolder->Show(enable_folder);
    m_btnFolder->Enable(enable_folder);
+
+   // update the argument *after* updating the browse buttons because their
+   // Enable() disables the text control as well if they're disabled and so the
+   // text could end up disabled even when it should be enabled
+   m_Argument->Show(enable_arg);
+   m_Argument->Enable(enable_arg);
 }
 
@@ -1206,5 +1193,5 @@
 
    // select something or UpdateProgram() would complain about invalid action
-   m_Type->SetSelection(MFDialogAction_toSelect(OAC_T_Delete));
+   m_Type->SetSelection(MFDialogAction_toSelect(OAC_T_MoveTo));
    m_choiceFlags->SetSelection(OAC_MF_Unseen);
 }
@@ -1613,6 +1600,5 @@
    }
 
-   // MAC: The test and action controls were not getting hidden and
-   // MAC: disabled properly sometimes when the dialog started.
+   // show/enable the controls as needed
    DoUpdateUI();
 



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to