//--------------------------------------------------------------------------- void __fastcall TEditorForm::PositionFindDialog(bool VerticalOnly) { assert(FLastFindDialog); if (!VerticalOnly) { FLastFindDialog->Left = Left + EditorMemo->Left + EditorMemo->Width / 2 - ScaleByTextHeight(this, 100); } FLastFindDialog->Top = Top + EditorMemo->Top + (EditorMemo->Height / 4) + (CursorInUpperPart() ? (EditorMemo->Height / 2) : 0) - ScaleByTextHeight(this, 40); }
//--------------------------------------------------------------------------- void __fastcall ApplySystemSettingsOnControl(TControl * Control) { #ifdef _DEBUG VerifyControl(Control); #endif // WORKAROUND // VCL does not scale status par panels (while for instance it does // scale list view headers). Remove this if they ever "fix" this. // For TBX status bars, this is implemented in TTBXCustomStatusBar.ChangeScale TStatusBar * StatusBar = dynamic_cast<TStatusBar *>(Control); if (StatusBar != NULL) { for (int Index = 0; Index < StatusBar->Panels->Count; Index++) { TStatusPanel * Panel = StatusBar->Panels->Items[Index]; Panel->Width = ScaleByTextHeight(StatusBar, Panel->Width); } } TWinControl * WinControl = dynamic_cast<TWinControl *>(Control); if (WinControl != NULL) { for (int Index = 0; Index < WinControl->ControlCount; Index++) { ApplySystemSettingsOnControl(WinControl->Controls[Index]); } } }
//--------------------------------------------------------------------------- void __fastcall TAuthenticateForm::Init(TTerminal * Terminal) { FTerminal = Terminal; FSessionData = Terminal->SessionData; UseSystemSettings(this); FShowAsModalStorage = NULL; FFocusControl = NULL; UseDesktopFont(LogView); FPromptParent = InstructionsLabel->Parent; FPromptLeft = InstructionsLabel->Left; FPromptTop = InstructionsLabel->Top; FPromptRight = FPromptParent->ClientWidth - InstructionsLabel->Width - FPromptLeft; FPromptEditGap = PromptEdit1->Top - PromptLabel1->Top - PromptLabel1->Height; FPromptsGap = PromptLabel2->Top - PromptEdit1->Top - PromptEdit1->Height; ClientHeight = ScaleByTextHeight(this, 270); ClearLog(); }
//--------------------------------------------------------------------------- void __fastcall CenterButtonImage(TButton * Button) { UncenterButtonImage(Button); // with themes disabled, the text seems to be drawn over the icon, // so that the padding spaces hide away most of the icon if (UseThemes()) { Button->ImageAlignment = iaCenter; int ImageWidth = Button->Images->Width; std::unique_ptr<TControlCanvas> Canvas(new TControlCanvas()); Canvas->Control = Button; UnicodeString Caption = Button->Caption; UnicodeString Padding; while (Canvas->TextWidth(Padding) < ImageWidth) { Padding += L" "; } Caption = Padding + Caption; Button->Caption = Caption; int CaptionWidth = Canvas->TextWidth(Caption); // The margins seem to extend the area over which the image is centered, // so we have to set it to a double of desired padding. // Note that (CaptionWidth / 2) - (ImageWidth / 2) // is approximatelly same as half of caption width before padding. Button->ImageMargins->Left = - 2 * ((CaptionWidth / 2) - (ImageWidth / 2) + ScaleByTextHeight(Button, 2)); } else { // at least do not draw it so near to the edge Button->ImageMargins->Left = 1; } }