|
@@ -83,6 +83,7 @@ __fastcall TPreferencesDialog::TPreferencesDialog(
|
|
|
FCustomCommandsHintItem = NULL;
|
|
|
FAddedExtensions.reset(CreateSortedStringList());
|
|
|
FCustomCommandOptions.reset(new TStringList());
|
|
|
+ FHideFocus = false;
|
|
|
UseSystemSettings(this);
|
|
|
|
|
|
FCustomCommandsScrollOnDragOver = new TListViewScrollOnDragOver(CustomCommandsView, true);
|
|
@@ -235,6 +236,22 @@ TTabSheet * __fastcall TPreferencesDialog::FindPageForTreeNode(TTreeNode * Node)
|
|
|
return NULL;
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
+TTreeNode * TPreferencesDialog::FindTreeNodeForPage(TTabSheet * Sheet)
|
|
|
+{
|
|
|
+ TTreeNode * Result = NULL;
|
|
|
+ for (int Index = 0; Index < NavigationTree->Items->Count; Index++)
|
|
|
+ {
|
|
|
+ TTreeNode * Node = NavigationTree->Items->Item[Index];
|
|
|
+ if (Node->SelectedIndex == Sheet->Tag)
|
|
|
+ {
|
|
|
+ Result = Node;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result;
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
void __fastcall TPreferencesDialog::PrepareNavigationTree(TTreeView * Tree)
|
|
|
{
|
|
|
Tree->FullExpand();
|
|
@@ -1137,6 +1154,12 @@ TInterface __fastcall TPreferencesDialog::GetInterface()
|
|
|
return CommanderInterfaceButton2->Checked ? ifCommander : ifExplorer;
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
+void TPreferencesDialog::SetActivePage(TTabSheet * Page)
|
|
|
+{
|
|
|
+ PageControl->ActivePage = Page;
|
|
|
+ PageControlChange(NULL);
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
void __fastcall TPreferencesDialog::FormShow(TObject * /*Sender*/)
|
|
|
{
|
|
|
// Load only now, particularly so that we have handles allocated already.
|
|
@@ -1154,20 +1177,24 @@ void __fastcall TPreferencesDialog::FormShow(TObject * /*Sender*/)
|
|
|
|
|
|
PrepareNavigationTree(NavigationTree);
|
|
|
|
|
|
+ UnicodeString SearchBanner = LoadStr(SEARCH_EDIT);
|
|
|
+ SearchEdit->Perform(EM_SETCUEBANNER, false, SearchBanner.c_str());
|
|
|
+
|
|
|
+ TTabSheet * InitialPage;
|
|
|
switch (FPreferencesMode) {
|
|
|
- case pmEditor: PageControl->ActivePage = EditorSheet; break;
|
|
|
- case pmCustomCommands: PageControl->ActivePage = CustomCommandsSheet; break;
|
|
|
- case pmQueue: PageControl->ActivePage = QueueSheet; break;
|
|
|
- case pmLogging: PageControl->ActivePage = LogSheet; break;
|
|
|
- case pmUpdates: PageControl->ActivePage = UpdatesSheet; break;
|
|
|
- case pmPresets: PageControl->ActivePage = CopyParamListSheet; break;
|
|
|
- case pmEditors: PageControl->ActivePage = EditorSheet; break;
|
|
|
- case pmCommander: PageControl->ActivePage = CommanderSheet; break;
|
|
|
- case pmEditorInternal: PageControl->ActivePage = EditorInternalSheet; break;
|
|
|
- case pmFileColors: PageControl->ActivePage = FileColorsSheet; break;
|
|
|
- default: PageControl->ActivePage = PreferencesSheet; break;
|
|
|
- }
|
|
|
- PageControlChange(NULL);
|
|
|
+ case pmEditor: InitialPage = EditorSheet; break;
|
|
|
+ case pmCustomCommands: InitialPage = CustomCommandsSheet; break;
|
|
|
+ case pmQueue: InitialPage = QueueSheet; break;
|
|
|
+ case pmLogging: InitialPage = LogSheet; break;
|
|
|
+ case pmUpdates: InitialPage = UpdatesSheet; break;
|
|
|
+ case pmPresets: InitialPage = CopyParamListSheet; break;
|
|
|
+ case pmEditors: InitialPage = EditorSheet; break;
|
|
|
+ case pmCommander: InitialPage = CommanderSheet; break;
|
|
|
+ case pmEditorInternal: InitialPage = EditorInternalSheet; break;
|
|
|
+ case pmFileColors: InitialPage = FileColorsSheet; break;
|
|
|
+ default: InitialPage = PreferencesSheet; break;
|
|
|
+ }
|
|
|
+ SetActivePage(InitialPage);
|
|
|
ActiveControl = NavigationTree;
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
@@ -1243,6 +1270,13 @@ void __fastcall TPreferencesDialog::UpdateControls()
|
|
|
{
|
|
|
if (FNoUpdate == 0)
|
|
|
{
|
|
|
+ NavigationTree->HideSelection = (FSearchResults.get() != NULL);
|
|
|
+ if ((SearchEdit->ButtonWidth != 0) != !SearchEdit->Text.IsEmpty()) // optimization
|
|
|
+ {
|
|
|
+ SearchEdit->ButtonWidth = SearchEdit->Text.IsEmpty() ? 0 : ScaleByTextHeight(SearchEdit, 19);
|
|
|
+ }
|
|
|
+ NavigationTree->TabStop = !SearchEdit->Focused() || (FSearchResults.get() == NULL) || (FSearchResults->Count == 0);
|
|
|
+
|
|
|
EnableControl(DDTransferConfirmationCheck2, ConfirmTransferringCheck->Checked);
|
|
|
EnableControl(BeepOnFinishAfterEdit, BeepOnFinishCheck->Checked);
|
|
|
EnableControl(BeepOnFinishAfterText, BeepOnFinishCheck->Checked);
|
|
@@ -2162,28 +2196,25 @@ void __fastcall TPreferencesDialog::NavigationTreeChange(TObject * /*Sender*/,
|
|
|
void __fastcall TPreferencesDialog::PageControlChange(TObject * /*Sender*/)
|
|
|
{
|
|
|
// this is probably only ever called from FormShow (explicitly)
|
|
|
- bool Found = false;
|
|
|
if (DebugAlwaysTrue(PageControl->ActivePage->Tag > 0))
|
|
|
{
|
|
|
- for (int Index = 0; Index < NavigationTree->Items->Count; Index++)
|
|
|
+ TTreeNode * Node = FindTreeNodeForPage(PageControl->ActivePage);
|
|
|
+ if (Node != NULL)
|
|
|
{
|
|
|
- if (NavigationTree->Items->Item[Index]->SelectedIndex ==
|
|
|
- PageControl->ActivePage->Tag)
|
|
|
- {
|
|
|
- NavigationTree->Items->Item[Index]->Selected = true;
|
|
|
- Found = true;
|
|
|
- }
|
|
|
+ Node->Selected = true;
|
|
|
+ UpdateControls();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (DebugAlwaysTrue(Found))
|
|
|
- {
|
|
|
- UpdateControls();
|
|
|
- }
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
void __fastcall TPreferencesDialog::CMDialogKey(TWMKeyDown & Message)
|
|
|
{
|
|
|
+ if ((Message.CharCode == VK_TAB) ||
|
|
|
+ ((Message.CharCode >= VK_LEFT) && (Message.CharCode >= VK_DOWN)))
|
|
|
+ {
|
|
|
+ FHideFocus = false;
|
|
|
+ }
|
|
|
+
|
|
|
if (Message.CharCode == VK_TAB)
|
|
|
{
|
|
|
TShiftState Shift = KeyDataToShiftState(Message.KeyData);
|
|
@@ -2206,6 +2237,13 @@ void __fastcall TPreferencesDialog::CMDialogKey(TWMKeyDown & Message)
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+ else if ((Message.CharCode == VK_ESCAPE) && (FSearchResults.get() != NULL))
|
|
|
+ {
|
|
|
+ SearchEdit->Clear();
|
|
|
+ NavigationTree->SetFocus();
|
|
|
+ Message.Result = 1;
|
|
|
+ return;
|
|
|
+ }
|
|
|
TForm::Dispatch(&Message);
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
@@ -2213,10 +2251,13 @@ void __fastcall TPreferencesDialog::WMHelp(TWMHelp & Message)
|
|
|
{
|
|
|
DebugAssert(Message.HelpInfo != NULL);
|
|
|
|
|
|
- if (Message.HelpInfo->iContextType == HELPINFO_WINDOW)
|
|
|
+ TControl * Control = FindControl(static_cast<HWND>(Message.HelpInfo->hItemHandle));
|
|
|
+ // Invoke help for the active page (not for whole form), regardless of a focus
|
|
|
+ // (e.g. even if the focus is on a control outside pagecontrol).
|
|
|
+ // Except when the control has its own help (SearchEdit).
|
|
|
+ if (((Control == NULL) || Control->HelpKeyword.IsEmpty()) &&
|
|
|
+ (Message.HelpInfo->iContextType == HELPINFO_WINDOW))
|
|
|
{
|
|
|
- // invoke help for active page (not for whole form), regardless of focus
|
|
|
- // (e.g. even if focus is on control outside pagecontrol)
|
|
|
Message.HelpInfo->hItemHandle = PageControl->ActivePage->Handle;
|
|
|
}
|
|
|
TForm::Dispatch(&Message);
|
|
@@ -2239,6 +2280,17 @@ void TPreferencesDialog::WMActivate(TWMActivate & Message)
|
|
|
TForm::Dispatch(&Message);
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
+void TPreferencesDialog::CMFocusChanged(TMessage & Message)
|
|
|
+{
|
|
|
+ if (FHideFocus)
|
|
|
+ {
|
|
|
+ FHideFocus = false;
|
|
|
+ HideFocus(UIS_SET);
|
|
|
+ }
|
|
|
+ UpdateControls();
|
|
|
+ TForm::Dispatch(&Message);
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
void __fastcall TPreferencesDialog::Dispatch(void *Message)
|
|
|
{
|
|
|
TMessage * M = reinterpret_cast<TMessage*>(Message);
|
|
@@ -2259,6 +2311,10 @@ void __fastcall TPreferencesDialog::Dispatch(void *Message)
|
|
|
{
|
|
|
WMActivate(*((TWMActivate *)Message));
|
|
|
}
|
|
|
+ else if (M->Msg == CM_FOCUSCHANGED)
|
|
|
+ {
|
|
|
+ CMFocusChanged(*M);
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
TForm::Dispatch(Message);
|
|
@@ -2986,12 +3042,78 @@ void __fastcall TPreferencesDialog::CustomCommandsViewMouseMove(TObject * /*Send
|
|
|
}
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
+void TPreferencesDialog::HideFocus(int State)
|
|
|
+{
|
|
|
+ Perform(WM_CHANGEUISTATE, MAKEWPARAM(State, UISF_HIDEFOCUS), 0);
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void TPreferencesDialog::SetFocusIfEnabled(TControl * Control)
|
|
|
+{
|
|
|
+ TWinControl * WinControl = dynamic_cast<TWinControl *>(Control);
|
|
|
+ if ((WinControl != NULL) && WinControl->Enabled)
|
|
|
+ {
|
|
|
+ WinControl->SetFocus();
|
|
|
+ }
|
|
|
+ else if (Control->Parent != NULL)
|
|
|
+ {
|
|
|
+ SetFocusIfEnabled(Control->Parent);
|
|
|
+ }
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void TPreferencesDialog::FocusAndHighlightControl(TControl * Control, const UnicodeString & Text)
|
|
|
+{
|
|
|
+ bool HighlightInside = true;
|
|
|
+ TLabel * Label = dynamic_cast<TLabel *>(Control);
|
|
|
+ if ((Label != NULL) && (Label->FocusControl != NULL))
|
|
|
+ {
|
|
|
+ Control = Label->FocusControl;
|
|
|
+ HighlightInside = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ TRadioButton * RadioButton = dynamic_cast<TRadioButton *>(Control);
|
|
|
+ // cannot focus non-checked radio as that would check it
|
|
|
+ if ((RadioButton != NULL) && !RadioButton->Checked)
|
|
|
+ {
|
|
|
+ TWinControl * RadioParent = RadioButton->Parent;
|
|
|
+ bool Found = false;
|
|
|
+ for (int Index = 0; Index < RadioParent->ControlCount; Index++)
|
|
|
+ {
|
|
|
+ TRadioButton * RadioSibling = dynamic_cast<TRadioButton *>(RadioParent->Controls[Index]);
|
|
|
+ if ((RadioSibling != NULL) && RadioSibling->Checked)
|
|
|
+ {
|
|
|
+ SetFocusIfEnabled(RadioSibling);
|
|
|
+ Found = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Found)
|
|
|
+ {
|
|
|
+ SetFocusIfEnabled(RadioParent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SetFocusIfEnabled(Control);
|
|
|
+
|
|
|
+ if (HighlightInside)
|
|
|
+ {
|
|
|
+ TComboBox * ComboBox = dynamic_cast<TComboBox *>(Control);
|
|
|
+ if ((ComboBox != NULL) && (ComboBox->Style == csDropDownList) && (ComboBox->Text != Text))
|
|
|
+ {
|
|
|
+ ComboBox->DroppedDown = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ FHideFocus = ((Perform(WM_QUERYUISTATE, 0, 0) & UISF_HIDEFOCUS) != 0);
|
|
|
+ HideFocus(UIS_CLEAR);
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
void __fastcall TPreferencesDialog::BackgroundConfirmationsLinkClick(TObject * /*Sender*/)
|
|
|
{
|
|
|
- PageControl->ActivePage = QueueSheet;
|
|
|
- PageControlChange(NULL);
|
|
|
- QueueNoConfirmationCheck->SetFocus();
|
|
|
- QueueNoConfirmationCheck->Perform(WM_CHANGEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 0);
|
|
|
+ SetActivePage(QueueSheet);
|
|
|
+ FocusAndHighlightControl(QueueNoConfirmationCheck, EmptyStr);
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
void __fastcall TPreferencesDialog::ConfigureCommandButtonClick(TObject * /*Sender*/)
|
|
@@ -3411,3 +3533,261 @@ void __fastcall TPreferencesDialog::ConfigureSshHostCAsButtonClick(TObject *)
|
|
|
ExecuteShellChecked(Program, L"-host-ca");
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
+void __fastcall TPreferencesDialog::SearchEditButtonClick(TObject *)
|
|
|
+{
|
|
|
+ SearchEdit->Clear();
|
|
|
+ SearchEdit->SetFocus();
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+int __fastcall TPreferencesDialog::CompareControlByLocation(void * Item1, void * Item2)
|
|
|
+{
|
|
|
+ TControl * Control1 = static_cast<TControl *>(Item1);
|
|
|
+ TControl * Control2 = static_cast<TControl *>(Item2);
|
|
|
+
|
|
|
+ int Result = Control1->Top - Control2->Top;
|
|
|
+ if (Result == 0)
|
|
|
+ {
|
|
|
+ Result = Control1->Left - Control2->Left;
|
|
|
+ if (Result == 0)
|
|
|
+ {
|
|
|
+ Result = reinterpret_cast<IntPtr>(Control1) - reinterpret_cast<IntPtr>(Control2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result;
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void TPreferencesDialog::AddSearchResult(TStrings * Results, UnicodeString & Caption, TControl * Control, bool & NewResults)
|
|
|
+{
|
|
|
+ if (ContainsTextSemiCaseSensitive(Caption, SearchEdit->Text))
|
|
|
+ {
|
|
|
+ if ((FSearchResults.get() == NULL) ||
|
|
|
+ (FSearchResults->Count <= Results->Count) ||
|
|
|
+ (FSearchResults->Strings[Results->Count] != Caption) ||
|
|
|
+ (FSearchResults->Objects[Results->Count] != Control))
|
|
|
+ {
|
|
|
+ NewResults = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ Results->AddObject(Caption, Control);
|
|
|
+ }
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+UnicodeString TPreferencesDialog::GetControlText(TControl * Control)
|
|
|
+{
|
|
|
+ UnicodeString Result;
|
|
|
+ TTabSheet * TabSheet = dynamic_cast<TTabSheet *>(Control);
|
|
|
+ if (TabSheet != NULL)
|
|
|
+ {
|
|
|
+ Result = DebugNotNull(FindTreeNodeForPage(TabSheet))->Text;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int TextLen = Control->GetTextLen();
|
|
|
+ Result.SetLength(TextLen);
|
|
|
+ Control->GetTextBuf(Result.c_str(), TextLen + 1);
|
|
|
+ }
|
|
|
+ return Result;
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void TPreferencesDialog::Search(TControl * Control, TStrings * Results, bool & NewResults)
|
|
|
+{
|
|
|
+ DebugAssert(Control != SearchSheet);
|
|
|
+
|
|
|
+ TCustomEdit * Edit = dynamic_cast<TCustomEdit *>(Control);
|
|
|
+ TComboBox * ComboBox = dynamic_cast<TComboBox *>(Control);
|
|
|
+ if ((Edit == NULL) &&
|
|
|
+ ((ComboBox == NULL) || (ComboBox->Style == csDropDownList)))
|
|
|
+ {
|
|
|
+ if (ComboBox != NULL)
|
|
|
+ {
|
|
|
+ for (int Index = 0; Index < ComboBox->Items->Count; Index++)
|
|
|
+ {
|
|
|
+ UnicodeString Item = ComboBox->Items->Strings[Index];
|
|
|
+ AddSearchResult(Results, Item, Control, NewResults);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ UnicodeString Caption = StripHotkey(GetControlText(Control));
|
|
|
+ if (Caption.Length() >= 4) // do not search unit labels (like "s")
|
|
|
+ {
|
|
|
+ AddSearchResult(Results, Caption, Control, NewResults);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ TWinControl * WinControl = dynamic_cast<TWinControl *>(Control);
|
|
|
+ if (WinControl != NULL)
|
|
|
+ {
|
|
|
+ std::unique_ptr<TList> Controls(new TList());
|
|
|
+ for (int Index = 0; Index < WinControl->ControlCount; Index++)
|
|
|
+ {
|
|
|
+ TControl * ChildControl = WinControl->Controls[Index];
|
|
|
+ if (ChildControl->Visible)
|
|
|
+ {
|
|
|
+ Controls->Add(ChildControl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Controls->Sort(CompareControlByLocation);
|
|
|
+
|
|
|
+ for (int Index = 0; Index < Controls->Count; Index++)
|
|
|
+ {
|
|
|
+ TControl * ChildControl = static_cast<TControl *>(Controls->Items[Index]);
|
|
|
+ Search(ChildControl, Results, NewResults);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void __fastcall TPreferencesDialog::SearchResultClick(TObject * Sender)
|
|
|
+{
|
|
|
+ TStaticText * LinkLabel = DebugNotNull(dynamic_cast<TStaticText *>(Sender));
|
|
|
+ UnicodeString Caption = FSearchResults->Strings[LinkLabel->Tag];
|
|
|
+ TControl * Control = dynamic_cast<TControl *>(FSearchResults->Objects[LinkLabel->Tag]);
|
|
|
+
|
|
|
+ FSearchResults.reset(NULL);
|
|
|
+
|
|
|
+ TControl * Parent = Control;
|
|
|
+ TTabSheet * Page;
|
|
|
+ while ((Page = dynamic_cast<TTabSheet *>(Parent)) == NULL)
|
|
|
+ {
|
|
|
+ Parent = Parent->Parent;
|
|
|
+ }
|
|
|
+
|
|
|
+ SetActivePage(Page);
|
|
|
+ FocusAndHighlightControl(Control, Caption);
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+TWinControl * TPreferencesDialog::GetSearchParent(TControl * Control)
|
|
|
+{
|
|
|
+ TWinControl * Result;
|
|
|
+ TTabSheet * ParentTabSheet = dynamic_cast<TTabSheet *>(Control);
|
|
|
+ if (ParentTabSheet != NULL)
|
|
|
+ {
|
|
|
+ TTreeNode * TreeNode = FindTreeNodeForPage(ParentTabSheet);
|
|
|
+ Result = (TreeNode->Parent != NULL) ? FindPageForTreeNode(TreeNode->Parent) : NULL;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Result = Control->Parent;
|
|
|
+ }
|
|
|
+ return Result;
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void TPreferencesDialog::UpdateSearching(bool Searching)
|
|
|
+{
|
|
|
+ if (!Searching)
|
|
|
+ {
|
|
|
+ if (FSearchResults.get() != NULL)
|
|
|
+ {
|
|
|
+ NavigationTreeChange(NULL, NavigationTree->Selected);
|
|
|
+ FSearchResults.reset(NULL);
|
|
|
+ DeleteChildren(SearchGroup);
|
|
|
+ UpdateControls();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::unique_ptr<TStrings> Results(new TStringList());
|
|
|
+ bool NewResults = false;
|
|
|
+
|
|
|
+ // search the pages in the tree order
|
|
|
+ for (int Index = 0; Index < NavigationTree->Items->Count; Index++)
|
|
|
+ {
|
|
|
+ Search(PageControl->Pages[Index], Results.get(), NewResults);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (NewResults || (FSearchResults.get() == NULL) || (FSearchResults->Count > Results->Count))
|
|
|
+ {
|
|
|
+ FSearchResults.reset(Results.release());
|
|
|
+
|
|
|
+ DeleteChildren(SearchGroup);
|
|
|
+
|
|
|
+ int Top = PuttyPathLabel->Top;
|
|
|
+ int Left = PuttyPathLabel->Left;
|
|
|
+ if (FSearchResults->Count == 0)
|
|
|
+ {
|
|
|
+ TLabel * Label = new TLabel(this);
|
|
|
+ Label->Parent = SearchGroup;
|
|
|
+ Label->Top = Top;
|
|
|
+ Label->Left = Left;
|
|
|
+ Label->Caption = LoadStr(SEARCH_NO_RESULTS);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int Padding = ScaleByTextHeight(this, 8);
|
|
|
+ int Width = SearchGroup->ClientWidth - Left;
|
|
|
+ for (int Index = 0; Index < FSearchResults->Count; Index++)
|
|
|
+ {
|
|
|
+ UnicodeString Caption = FSearchResults->Strings[Index];
|
|
|
+ TControl * Control = dynamic_cast<TControl *>(FSearchResults->Objects[Index]);
|
|
|
+
|
|
|
+ UnicodeString Context;
|
|
|
+ TWinControl * Parent = GetSearchParent(Control);
|
|
|
+ while ((Parent != NULL) && DebugAlwaysTrue(Parent != PageControl))
|
|
|
+ {
|
|
|
+ UnicodeString ParentCaption = GetControlText(Parent);
|
|
|
+ if (!ParentCaption.IsEmpty())
|
|
|
+ {
|
|
|
+ Context = ParentCaption + L" " + ContextSeparator + L" " + Context;
|
|
|
+ }
|
|
|
+ Parent = GetSearchParent(Parent);
|
|
|
+ }
|
|
|
+
|
|
|
+ Context = DefaultStr(Context, ContextSeparator);
|
|
|
+
|
|
|
+ TLabel * ContextLabel = new TLabel(this);
|
|
|
+ ContextLabel->Parent = SearchGroup;
|
|
|
+ ContextLabel->Top = Top;
|
|
|
+ ContextLabel->Left = Left;
|
|
|
+ ContextLabel->ShowAccelChar = false;
|
|
|
+ ContextLabel->Caption = Context;
|
|
|
+
|
|
|
+ TStaticText * LinkLabel = new TStaticText(this);
|
|
|
+ LinkLabel->Parent = SearchGroup;
|
|
|
+ LinkLabel->Top = ContextLabel->Top + ContextLabel->Height;
|
|
|
+ LinkLabel->Left = Left;
|
|
|
+ LinkLabel->ShowAccelChar = false;
|
|
|
+ LinkLabel->Caption = Caption;
|
|
|
+ LinkLabel->Width = Width;
|
|
|
+ LinkLabel->Tag = Index;
|
|
|
+ LinkLabel->TabStop = true;
|
|
|
+ LinkLabel->OnClick = SearchResultClick;
|
|
|
+ AutoSizeLabel(LinkLabel);
|
|
|
+ if (LinkLabel->Top + LinkLabel->Height > SearchGroup->ClientHeight)
|
|
|
+ {
|
|
|
+ delete ContextLabel;
|
|
|
+ delete LinkLabel;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ LinkActionLabel(LinkLabel);
|
|
|
+
|
|
|
+ Top = LinkLabel->Top + LinkLabel->Height + Padding;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PageControl->ActivePage = SearchSheet;
|
|
|
+ UpdateControls();
|
|
|
+ }
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void __fastcall TPreferencesDialog::SearchEditChangeEnter(TObject *)
|
|
|
+{
|
|
|
+ UpdateSearching(!SearchEdit->Text.IsEmpty());
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void __fastcall TPreferencesDialog::NavigationTreeEnter(TObject *)
|
|
|
+{
|
|
|
+ UpdateSearching(false);
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void __fastcall TPreferencesDialog::FormShortCut(TWMKey & Msg, bool & Handled)
|
|
|
+{
|
|
|
+ if ((Msg.CharCode == L'F') && KeyDataToShiftState(Msg.KeyData).Contains(ssCtrl))
|
|
|
+ {
|
|
|
+ SearchEdit->SetFocus();
|
|
|
+ Handled = true;
|
|
|
+ }
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|