Back to index

lightning-sunbird  0.9+nobinonly
nsAutoCompleteController.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is Mozilla Communicator client code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1998
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Joe Hewitt <hewitt@netscape.com> (Original Author)
00023  *   Masayuki Nakano <masayuki@d-toybox.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef __nsAutoCompleteController__
00040 #define __nsAutoCompleteController__
00041 
00042 #include "nsIAutoCompleteController.h"
00043 
00044 #include "nsIAutoCompleteInput.h"
00045 #include "nsIAutoCompletePopup.h"
00046 #include "nsIAutoCompleteResult.h"
00047 #include "nsIAutoCompleteSearch.h"
00048 #include "nsString.h"
00049 #include "nsITreeView.h"
00050 #include "nsITreeSelection.h"
00051 #include "nsISupportsArray.h"
00052 #include "nsITimer.h"
00053 #include "nsIRollupListener.h"
00054 #include "nsIWidget.h"
00055 
00056 class nsAutoCompleteController : public nsIAutoCompleteController_MOZILLA_1_8_BRANCH,
00057                                  public nsIAutoCompleteObserver,
00058                                  public nsIRollupListener,
00059                                  public nsITimerCallback,
00060                                  public nsITreeView
00061 {
00062 public:
00063   NS_DECL_ISUPPORTS
00064   NS_DECL_NSIAUTOCOMPLETECONTROLLER
00065   NS_DECL_NSIAUTOCOMPLETECONTROLLER_MOZILLA_1_8_BRANCH
00066   NS_DECL_NSIAUTOCOMPLETEOBSERVER
00067   NS_DECL_NSIROLLUPLISTENER
00068   NS_DECL_NSITREEVIEW
00069   NS_DECL_NSITIMERCALLBACK
00070    
00071   nsAutoCompleteController();
00072   virtual ~nsAutoCompleteController();
00073   
00074 protected:
00075   nsresult OpenPopup();
00076   nsresult ClosePopup();
00077 
00078   nsresult StartSearch();
00079   nsresult StopSearch();
00080   
00081   nsresult StartSearchTimer();
00082   nsresult ClearSearchTimer();
00083 
00084   nsresult ProcessResult(PRInt32 aSearchIndex, nsIAutoCompleteResult *aResult);
00085   nsresult PostSearchCleanup();
00086 
00087   nsresult EnterMatch();
00088   nsresult RevertTextValue();
00089 
00090   nsresult CompleteDefaultIndex(PRInt32 aSearchIndex);
00091   nsresult CompleteValue(nsString &aValue, PRBool selectDifference);
00092   nsresult GetResultValueAt(PRInt32 aIndex, PRBool aValueOnly, nsAString & _retval);
00093 
00094   nsresult ClearResults();
00095   
00096   nsresult RowIndexToSearch(PRInt32 aRowIndex, PRInt32 *aSearchIndex, PRInt32 *aItemIndex);
00097 
00098   nsIWidget* GetPopupWidget();
00099 
00100   // members //////////////////////////////////////////
00101   
00102   nsCOMPtr<nsIAutoCompleteInput> mInput;
00103   
00104   nsCOMPtr<nsISupportsArray> mSearches;
00105   nsCOMPtr<nsISupportsArray> mResults;
00106   
00107   nsCOMPtr<nsITimer> mTimer;
00108   nsCOMPtr<nsITreeSelection> mSelection;
00109   nsCOMPtr<nsITreeBoxObject> mTree;
00110 
00111   nsString mSearchString;
00112   PRPackedBool mEnterAfterSearch;
00113   PRPackedBool mDefaultIndexCompleted;
00114   PRPackedBool mBackspaced;
00115   PRPackedBool mPopupClosedByCompositionStart;
00116   PRPackedBool mIsIMEComposing;
00117   PRPackedBool mIgnoreHandleText;
00118   PRBool mIsOpen;
00119   PRUint16 mSearchStatus;
00120   PRUint32 mRowCount;
00121   PRUint32 mSearchesOngoing;
00122 };
00123 
00124 #endif /* __nsAutoCompleteController__ */