SF.net SVN: mahogany:[7527] trunk/M/src/gui/wxComposeView.cpp

[email protected] Wed, 06 Aug 2008 23:25:19 +0000
Newsgroups gmane.mail.mahogany.cvs
Message-ID <[email protected]>
Revision: 7527
          http://mahogany.svn.sourceforge.net/mahogany/?rev=7527&view=rev
Author:   vadz
Date:     2008-08-06 23:25:17 +0000 (Wed, 06 Aug 2008)

Log Message:
-----------
improve initial focus position; pressing Enter in the subject field now switches to the composer itself

Modified Paths:
--------------
    trunk/M/src/gui/wxComposeView.cpp

Modified: trunk/M/src/gui/wxComposeView.cpp
===================================================================
--- trunk/M/src/gui/wxComposeView.cpp	2008-08-06 23:12:56 UTC (rev 7526)
+++ trunk/M/src/gui/wxComposeView.cpp	2008-08-06 23:25:17 UTC (rev 7527)
@@ -482,11 +482,13 @@
 // wxSubjectTextCtrl: text control for the subject
 // ----------------------------------------------------------------------------
 
-class wxSubjectTextCtrl : public wxTextCtrlProcessingEnter
+class wxSubjectTextCtrl : public wxTextCtrl
 {
 public:
    wxSubjectTextCtrl(wxWindow *parent, wxComposeView *composeView)
-      : wxTextCtrlProcessingEnter(parent)
+      : wxTextCtrl(parent, wxID_ANY, "",
+                   wxDefaultPosition, wxDefaultSize,
+                   wxTE_PROCESS_ENTER)
    {
       m_composeView = composeView;
    }
@@ -498,14 +500,20 @@
       m_composeView->UpdateTitle();
    }
 
+   void OnEnter(wxCommandEvent& WXUNUSED(event))
+   {
+      m_composeView->SetFocusToComposer();
+   }
+
    wxComposeView *m_composeView;
 
    DECLARE_EVENT_TABLE()
    DECLARE_NO_COPY_CLASS(wxSubjectTextCtrl)
 };
 
-BEGIN_EVENT_TABLE(wxSubjectTextCtrl, wxTextCtrlProcessingEnter)
+BEGIN_EVENT_TABLE(wxSubjectTextCtrl, wxTextCtrl)
    EVT_TEXT(wxID_ANY, wxSubjectTextCtrl::OnChange)
+   EVT_TEXT_ENTER(wxID_ANY, wxSubjectTextCtrl::OnEnter)
 END_EVENT_TABLE()
 
 // ----------------------------------------------------------------------------
@@ -2875,23 +2883,33 @@
    // the composer text is initialized
 
    // the natural order is to enter recipients first and then the subject but
-   // put the cursor directly into the compose window if both of them already
-   // have reasonable default values as is the case when replying
-   switch ( m_kind )
+   // if we already have some recipients (e.g. because we're replying to an
+   // existing message or because there are some default recipients at the
+   // folder level even for the new messages) we give focus to the subject
+   // first and, finally, if the subject is also specified (as happens when
+   // replying or forwarding) we go directly to the composer
+
+   // notice that CC, BCC and FCC shouldn't count: even if we have them, we
+   // still need at least one recipient (usually)
+   const size_t numRcpts = m_rcptExtra.size();
+   for ( size_t n = 0; n < numRcpts; n++ )
    {
-      default:
-         FAIL_MSG( _T("unknown message kind") );
-         // fall through
+      switch ( m_rcptExtra[n]->GetType() )
+      {
+         case Recipient_To:
+         case Recipient_Newsgroup:
+            // we already have a recipient, go to the subject field
+            if ( m_txtSubject->GetValue().empty() )
+               m_txtSubject->SetFocus();
+            else // or directly to the composer if we already have subject too
+               SetFocusToComposer();
 
-      case Message_New:
-      case Message_Forward:
-         m_rcptMain->GetText()->SetFocus();
-         break;
+            return; // skip SetFocus() call below
+      }
+   }
 
-      case Message_Reply:
-         SetFocusToComposer();
-         break;
-   }
+   // no recipients yet, set the focus there
+   m_rcptMain->GetText()->SetFocus();
 }
 
 void


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/