#include <sgallery.h>
Inheritance diagram for SGallerySearchDlg:
Public Member Functions | |
SGallerySearchDlg () | |
Constructor. | |
~SGallerySearchDlg () | |
destructor | |
MsgResult | Message (Msg *Message) |
Standard DialogOp message handler, for the Gallery display dialogue. | |
void | Do (OpDescriptor *) |
'Does' a gallery display dialogue op. DO NOT call this method - it must be invoked via DoWithParam | |
void | DoWithParam (OpDescriptor *, OpParam *Param) |
'Does' a gallery display dialogue op. Shows the dialogue. | |
BOOL | Create () |
Creates a gallery display dialogue box. | |
Static Public Member Functions | |
static BOOL | Init () |
Initialises the colour sort dialogue op. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
Get the state of the Colour sort dialogue op. | |
static void | InvokeDialog (SuperGallery *Parent) |
Creates a new instance of this dialogue type, connects it to the given gallery, and opens the dialogue on screen. | |
Static Public Attributes | |
static const UINT32 | IDD = _R(IDD_SGSEARCH) |
static const CDlgMode | Mode = MODELESS |
Protected Member Functions | |
void | InitValues (void) |
Initialises the gallery display dialogue, and sets its controls Scope: private. | |
void | SetControls (void) |
(Re)Initialises the colour manager dialogue controls (This simply sets the combo boxes etc up from the current settings) | |
void | Search (BOOL FindFirst) |
Applies the current settings in the dialogue to its parent gallery. Searches for the first/next matching gallery item. Selects the matched item. Search for next searches from the first selected item onwards. Search is case insensitive. | |
SGDisplayItem * | SearchFindNextItem (SGDisplayItem *LastItem, Progress *Hourglass=NULL) |
Get the next item to compare. | |
SGDisplayItem * | SearchFindStartItem (BOOL FindFirst) |
Get the first item to start the search with. | |
BOOL | DoComparison (SGDisplayItem *Item, StringBase *SearchText, BOOL UseKeywords=FALSE, BOOL ItsALibrary=FALSE, BOOL FullInfo=FALSE) |
The search routine's main comparison point. All items will go through this, so it must be fairly speedy in operation. | |
Protected Attributes | |
SuperGallery * | ParentGallery |
Static Protected Attributes | |
static BOOL | LastSearchFullInfo = FALSE |
static String_64 | LastSearchText |
Definition at line 858 of file sgallery.h.
|
Constructor.
Definition at line 4693 of file sgallery.cpp. 04694 : DialogOp(SGallerySearchDlg::IDD, SGallerySearchDlg::Mode) 04695 { 04696 ParentGallery = NULL; 04697 }
|
|
destructor
Definition at line 4712 of file sgallery.cpp. 04713 { 04714 if (ParentGallery != NULL) 04715 ParentGallery->CurrentSearchDlg = NULL; 04716 }
|
|
Creates a gallery display dialogue box.
Reimplemented from DialogOp. Definition at line 5327 of file sgallery.cpp. 05328 { 05329 ERROR3IF(ParentGallery == NULL, "My ParentGallery is NULL!"); 05330 05331 if (DialogOp::Create()) 05332 { 05333 ParentGallery->CurrentSearchDlg = this; 05334 05335 InitValues(); 05336 return(TRUE); 05337 } 05338 05339 return(FALSE); 05340 }
|
|
'Does' a gallery display dialogue op. DO NOT call this method - it must be invoked via DoWithParam
Reimplemented from Operation. Definition at line 5361 of file sgallery.cpp. 05362 { 05363 ERROR3("SGallerySearchDlg - You must use DoWithParam (Call InvokeDialog)"); 05364 End(); 05365 }
|
|
The search routine's main comparison point. All items will go through this, so it must be fairly speedy in operation.
Definition at line 5102 of file sgallery.cpp. 05103 { 05104 String_256 ItemText; 05105 05106 // Set these if we did a quick compare via TCHAR *'s... 05107 BOOL CheckedTitle = FALSE; 05108 BOOL CheckedFilename = FALSE; 05109 05110 #if 0 05111 // If we are a library, we can use SpeedSearch(TM) technology... 05112 // Note that this won't do wildcard searches, but if we don't match, we do normal, slow, 05113 // searching later on... 05114 CheckedTitle = CheckedFilename = FALSE; 05115 if (ItsALibrary) 05116 { 05117 TCHAR *pSpeedyResult; 05118 BOOL CouldGetPointer = ((SGLibDisplayItem *)Item)->GetNameTextPtr(&pSpeedyResult); 05119 if (CouldGetPointer) 05120 { 05121 // Compare two title TCHAR *'s... 05122 if(CompareString(LOCALE_USER_DEFAULT, 05123 (NORM_IGNORECASE|NORM_IGNOREKANATYPE|NORM_IGNOREWIDTH), 05124 pSpeedyResult, -1, (TCHAR *)LastSearchText, -1) == 2) 05125 return TRUE; 05126 CheckedTitle = TRUE; 05127 } 05128 05129 CouldGetPointer = ((SGLibDisplayItem *)Item)->GetFileNamePtr(&pSpeedyResult); 05130 if(CouldGetPointer) 05131 { 05132 // Compare two filename TCHAR *'s... 05133 if(CompareString(LOCALE_USER_DEFAULT, 05134 (NORM_IGNORECASE|NORM_IGNOREKANATYPE|NORM_IGNOREWIDTH), 05135 pSpeedyResult, -1, (TCHAR *)LastSearchText, -1) == 2) 05136 return TRUE; 05137 CheckedFilename = TRUE; 05138 } 05139 } 05140 #endif 05141 05142 // Check normal name 05143 if(!CheckedTitle) 05144 { 05145 Item->GetNameText(&ItemText); 05146 ItemText.toLower(); 05147 if (ItemText.Sub(*SearchText, 0, TCHAR('*')) >= 0) 05148 return TRUE; 05149 } 05150 05151 // Check filenames if told to 05152 if (ItsALibrary && !CheckedFilename) 05153 { 05154 ((SGLibDisplayItem *)Item)->GetFileName(&ItemText); 05155 ItemText.toLower(); 05156 if (ItemText.Sub(*SearchText, 0, TCHAR('*')) >= 0) 05157 return TRUE; 05158 } 05159 05160 // For galleries which support it, check keywords 05161 if (UseKeywords) 05162 { 05163 Item->GetKeyWords(&ItemText); 05164 ItemText.toLower(); 05165 05166 // Check if there's a possibility of the string matching before the absolute check 05167 if (ItemText.Sub(*SearchText, 0, TCHAR('*')) >= 0) 05168 { 05169 // ItemText will be a string such as 'bat |animal|bird| mammal' 05170 // 'LastSearchText' will be a string such as 'animal' 05171 // We need to check whole words, so that 'nima' won't provide a match 05172 05173 // change ItemText to be: '|bat||animal|bird||mammal|', then search for '|animal|' 05174 05175 if (GenerateIndexFile::ReplaceCharacters(&ItemText, ' ', '|')) 05176 { 05177 String_256 NewItemText; 05178 NewItemText = _T("|"); 05179 NewItemText += ItemText; 05180 NewItemText += _T("|"); 05181 05182 String_256 NewSearchText; 05183 NewSearchText = _T("|"); 05184 NewSearchText += *SearchText; 05185 NewSearchText += _T("|"); 05186 05187 if (NewItemText.Sub(NewSearchText, 0, TCHAR('*')) >= 0) 05188 return TRUE; 05189 } 05190 } 05191 } 05192 05193 // Check text in full info modes 05194 if (FullInfo) 05195 { 05196 Item->GetFullInfoText(&ItemText); 05197 ItemText.toLower(); 05198 if (ItemText.Sub(*SearchText, 0, TCHAR('*')) >= 0) 05199 return TRUE; 05200 } 05201 05202 return FALSE; 05203 }
|
|
'Does' a gallery display dialogue op. Shows the dialogue.
Reimplemented from Operation. Definition at line 5386 of file sgallery.cpp. 05387 { 05388 ERROR3IF(Param == NULL, "Null parameters are illegal"); 05389 05390 ParentGallery = ((GalDlgParam *)Param)->ParentGal; 05391 05392 ERROR3IF(ParentGallery == NULL, "SGallerySearchDlg needs a non-NULL parent gallery!"); 05393 05394 if (ParentGallery != NULL && Create()) 05395 Open(); 05396 else 05397 End(); 05398 }
|
|
Get the state of the Colour sort dialogue op.
Definition at line 5276 of file sgallery.cpp. 05277 { 05278 OpState OpSt; 05279 return(OpSt); 05280 }
|
|
Initialises the colour sort dialogue op.
Reimplemented from SimpleCCObject. Definition at line 5299 of file sgallery.cpp. 05300 { 05301 return (RegisterOpDescriptor( 05302 0, 05303 _R(IDS_SGSEARCHDLG), 05304 CC_RUNTIME_CLASS(SGallerySearchDlg), 05305 OPTOKEN_SGSEARCHDLG, 05306 SGallerySearchDlg::GetState, 05307 _R(IDST_GALLERY_MENU), // Status line help **** !!!! 05308 _R(IDBBL_GALLERY_MENU), // Bubble help **** !!!! 05309 0 /* bitmap ID */ 05310 )); 05311 }
|
|
Initialises the gallery display dialogue, and sets its controls Scope: private.
Definition at line 4734 of file sgallery.cpp. 04735 { 04736 if (ParentGallery == NULL) 04737 { 04738 ERROR3("SGallerySearchDlg MUST be given a valid parent pointer"); 04739 return; 04740 } 04741 04742 // Fill in the combo boxes etc with the current settings 04743 SetControls(); 04744 }
|
|
Creates a new instance of this dialogue type, connects it to the given gallery, and opens the dialogue on screen.
Definition at line 4764 of file sgallery.cpp. 04765 { 04766 if (Parent->CurrentSearchDlg != NULL) // There's one already open! 04767 { 04768 // Bring it to the front of the window stack, then return 04769 Parent->CurrentSearchDlg->BringToTop(); 04770 return; 04771 } 04772 04773 GalDlgParam GalSearchInfo(Parent); 04774 OpDescriptor *Dlg = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(SGallerySearchDlg)); 04775 04776 ERROR3IF(Dlg == NULL, "I can't find the Dialog OpDescriptor"); 04777 04778 if (Dlg != NULL) 04779 Dlg->Invoke(&GalSearchInfo); 04780 }
|
|
Standard DialogOp message handler, for the Gallery display dialogue.
Reimplemented from DialogOp. Definition at line 5219 of file sgallery.cpp. 05220 { 05221 if (!(IS_OUR_DIALOG_MSG(Message))) return DialogOp::Message(Message); 05222 05223 DialogMsg* TheMsg = (DialogMsg*)Message; 05224 05225 switch(TheMsg->DlgMsg) 05226 { 05227 case DIM_CREATE: 05228 SetKeyboardFocus (_R(IDC_SGSEARCH_TEXT)) ; 05229 HighlightText (_R(IDC_SGSEARCH_TEXT)) ; 05230 break ; 05231 case DIM_COMMIT: // OK clicked 05232 case DIM_SOFT_COMMIT: // OK "adjust clicked" 05233 Search(FALSE); 05234 05235 // The 'OK' button ('Find Next') does not close the dialogue - it will stay 05236 // open until the user explicitly chooses 'Close'. 05237 break; 05238 05239 case DIM_CANCEL: // Cancel clicked 05240 Close(); 05241 End(); 05242 return OK; 05243 break; 05244 05245 case DIM_LFT_BN_CLICKED: 05246 if (TheMsg->GadgetID == _R(IDC_SGSEARCH_FINDFIRST)) 05247 Search(TRUE); 05248 break; 05249 05250 default: 05251 break; 05252 } 05253 05254 return DialogOp::Message(Message); 05255 05256 return OK; 05257 }
|
|
Applies the current settings in the dialogue to its parent gallery. Searches for the first/next matching gallery item. Selects the matched item. Search for next searches from the first selected item onwards. Search is case insensitive.
Definition at line 4832 of file sgallery.cpp. 04833 { 04834 if(ParentGallery == NULL) 04835 { 04836 ERROR3("No parent gallery!"); 04837 return; 04838 } 04839 04840 BOOL Valid = FALSE; 04841 String_256 SearchText = GetStringGadgetValue(_R(IDC_SGSEARCH_TEXT), &Valid); 04842 04843 if(!Valid) return; 04844 04845 // Truncate the search tet into the last-search-text buffer 04846 SearchText.Left((StringBase *) &LastSearchText, 63); 04847 LastSearchText.toLower(); 04848 04849 if(LastSearchText.Length() < 1) 04850 { 04851 InformWarning(_R(IDE_SGSEARCH_BADTEXT), _R(IDS_OK)); 04852 return; 04853 } 04854 04855 // And remember the last used options for the radio buttons 04856 LastSearchFullInfo = GetBoolGadgetSelected(_R(IDC_SGSEARCH_FULLINFO)); 04857 04858 // Now, apply the search 04859 if(ParentGallery == NULL || ParentGallery->DisplayTree == NULL) 04860 return; 04861 04862 // Should we use keywords ? 04863 BOOL UseKeywords = ParentGallery->CanSearchKeywords(); 04864 04865 // Need this if Devirtualising library indexes proves bad... 04866 ParentGallery->SetQuietStatus(FALSE); 04867 04868 // Find the first selected item (if any) and get the next item to start searching from 04869 // If there is no selection, then get the first item 04870 SGDisplayItem *Item = SearchFindStartItem(FindFirst); 04871 04872 // Work out how many groups we're dealing with... 04873 INT32 HourglassCount = -1; 04874 if (Item != NULL) 04875 { 04876 SGDisplayGroup *GroupCountItem = (SGDisplayGroup *)Item->GetParent(); 04877 04878 while(GroupCountItem != NULL) 04879 { 04880 GroupCountItem = (SGDisplayGroup *)GroupCountItem->GetNext(); 04881 HourglassCount ++; 04882 } 04883 } 04884 04885 // Start up the hourglass 04886 Progress Hourglass(_R(IDS_SGSEARCH_SEARCHING), HourglassCount, TRUE); 04887 04888 // This really needs moving out to sglbase sometime soon... 04889 BOOL ItsALibrary = ParentGallery->IsLibraryGalleryWithNonLibraryGroups(); 04890 04891 // We shouldn't really check for escape for every item 04892 INT32 ProgressCounterRate = 30; 04893 INT32 ProgressCounter = ProgressCounterRate; 04894 04895 // Actually loop through the items and compare each with the given search string 04896 while(Item != NULL) 04897 { 04898 // Possibly update progress indicator; if ESCAPE pressed, abort! 04899 if(!(--ProgressCounter)) 04900 ProgressCounter = ProgressCounterRate; 04901 else 04902 if(ProgressCounter == 1 && !Hourglass.Update(Hourglass.GetCount(), TRUE)) 04903 { 04904 EndSlowJob(); 04905 InformMessage(_R(IDE_SGSEARCH_ABORTED), _R(IDS_OK)); 04906 return; 04907 } 04908 04909 if(DoComparison(Item, &LastSearchText, UseKeywords, ItsALibrary, LastSearchFullInfo)) 04910 break; 04911 04912 if(HourglassCount == -1) 04913 Item = SearchFindNextItem(Item, NULL); 04914 else 04915 Item = SearchFindNextItem(Item, &Hourglass); 04916 } 04917 04918 if(Item == NULL) 04919 { 04920 InformMessage(_R(IDE_SGSEARCH_NOMATCH), _R(IDS_OK)); 04921 return; 04922 } 04923 04924 ParentGallery->SelectItems(FALSE); // Clear existing selection 04925 Item->Flags.Selected = TRUE; // And select this item 04926 Item->ForceRedrawOfMyself(); // Ensuring it redraws itself 04927 04928 ParentGallery->ForceGroupFolded((SGDisplayGroup *)Item->GetParent(), FALSE); 04929 04930 DocRect ScrollToRect; 04931 Item->GetFormatRect(&ScrollToRect); 04932 ParentGallery->ScrollToShow(&ScrollToRect); // Scroll to make seln visible on screen 04933 04934 ParentGallery->SelectionHasChanged(); // Update gallery for the new selection 04935 }
|
|
Get the next item to compare.
Definition at line 4958 of file sgallery.cpp. 04959 { 04960 SGDisplayNode *Item = LastItem; 04961 04962 if (Item->GetNext() == NULL) // Skip to next group 04963 { 04964 ERROR3IF(Item->GetParent() == NULL, "Tree linkage corruption"); 04965 04966 // Make Item = Next group 04967 if (Item->GetParent()->GetNext() != NULL) 04968 Item = Item->GetParent()->GetNext(); 04969 else 04970 Item = NULL; 04971 04972 BOOL DevirtualisedGroups = FALSE; 04973 04974 // Skip through groups until we find one with items 04975 while(Item != NULL && Item->GetChild() == NULL) 04976 { 04977 BOOL DeVirted = FALSE; 04978 if(((SGDisplayGroup *)Item)->IsVirtualised()) 04979 DeVirted = ((SGDisplayGroup *)Item)->DeVirtualise(); 04980 04981 // Update the progress bar for each group jumped 04982 if(Hourglass) 04983 Hourglass->GetCount(1); 04984 04985 DevirtualisedGroups = TRUE; 04986 04987 if(!DeVirted) 04988 Item = Item->GetNext(); 04989 } 04990 04991 if(!DevirtualisedGroups && Hourglass) 04992 { 04993 // We jumped a group, but didn't bother with devirtualising stuff, because 04994 // we didn't need to, so update the progress bar 04995 Hourglass->GetCount(1); 04996 } 04997 04998 // Get first item in new group 04999 if(Item != NULL) 05000 Item = Item->GetChild(); // Always get the first item in a group 05001 } 05002 else 05003 Item = Item->GetNext(); // Get next sibling item 05004 05005 return (SGDisplayItem *)Item; 05006 }
|
|
Get the first item to start the search with.
Definition at line 5023 of file sgallery.cpp. 05024 { 05025 SGDisplayNode *Item = ParentGallery->DisplayTree->FindNextSelectedItem(NULL); 05026 05027 if (Item == NULL || FindFirst) 05028 { 05029 Item = ParentGallery->DisplayTree->GetChild(); // Find the first leaf node 05030 05031 // Skip through groups until we find one with items 05032 while(Item != NULL && Item->GetChild() == NULL) 05033 { 05034 BOOL DeVirted = FALSE; 05035 if(((SGDisplayGroup *)Item)->IsVirtualised()) 05036 DeVirted = ((SGDisplayGroup *)Item)->DeVirtualise(); 05037 05038 if(!DeVirted) 05039 Item = Item->GetNext(); 05040 } 05041 05042 while (Item != NULL && Item->GetChild() != NULL) 05043 Item = Item->GetChild(); 05044 } 05045 else 05046 { 05047 // Find next item, skipping to the next group if necessary 05048 if (Item->GetNext() == NULL) // Skip to next group 05049 { 05050 ERROR3IF(Item->GetParent() == NULL, "Tree linkage corruption"); 05051 05052 // Make Item = Next group 05053 if (Item->GetParent()->GetNext() != NULL) 05054 Item = Item->GetParent()->GetNext(); 05055 else 05056 Item = NULL; 05057 05058 // Skip through groups until we find one with items 05059 while(Item != NULL && Item->GetChild() == NULL) 05060 { 05061 BOOL DeVirted = FALSE; 05062 if(((SGDisplayGroup *)Item)->IsVirtualised()) 05063 DeVirted = ((SGDisplayGroup *)Item)->DeVirtualise(); 05064 05065 if(!DeVirted) 05066 Item = Item->GetNext(); 05067 } 05068 05069 // Get first item in new group 05070 if(Item != NULL) 05071 Item = Item->GetChild(); 05072 } 05073 else 05074 Item = Item->GetNext(); // Get next sibling item 05075 } 05076 05077 return (SGDisplayItem *)Item; 05078 }
|
|
(Re)Initialises the colour manager dialogue controls (This simply sets the combo boxes etc up from the current settings)
Definition at line 4796 of file sgallery.cpp. 04797 { 04798 if (ParentGallery == NULL) 04799 { 04800 ERROR3("ParentGallery is NULL!"); 04801 return; 04802 } 04803 04804 // Set the search-text field 04805 SetStringGadgetValue(_R(IDC_SGSEARCH_TEXT), LastSearchText); 04806 04807 // Set the name-only/full-info radio buttons 04808 SetBoolGadgetSelected(_R(IDC_SGSEARCH_NAMEONLY), !(LastSearchFullInfo)); 04809 SetBoolGadgetSelected(_R(IDC_SGSEARCH_FULLINFO), LastSearchFullInfo); 04810 }
|
|
Definition at line 875 of file sgallery.h. |
|
Definition at line 895 of file sgallery.h. |
|
Definition at line 896 of file sgallery.h. |
|
Definition at line 876 of file sgallery.h. |
|
Definition at line 882 of file sgallery.h. |