void dialog_about::CreateNotebookPage( wxAuiNotebook* aParent, const wxString& aCaption, const wxBitmap& aIcon, const Contributors& aContributors ) { wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL ); wxScrolledWindow* m_scrolledWindow1 = new wxScrolledWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); m_scrolledWindow1->SetScrollRate( 5, 5 ); /* Panel for additional space at the left, * but can also be used to show an additional bitmap. */ wxPanel* panel1 = new wxPanel( m_scrolledWindow1 ); wxFlexGridSizer* fgSizer1 = CreateFlexGridSizer(); for( size_t i=0; i<aContributors.GetCount(); ++i ) { Contributor* contributor = &aContributors.Item( i ); // Icon at first column wxStaticBitmap* m_bitmap1 = CreateStaticBitmap( m_scrolledWindow1, contributor->GetIcon() ); fgSizer1->Add( m_bitmap1, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, 5 ); // Name of contributor at second column if ( contributor->GetName() != wxEmptyString ) { wxStaticText* m_staticText1 = new wxStaticText( m_scrolledWindow1, wxID_ANY, contributor->GetName(), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->Wrap( -1 ); fgSizer1->Add( m_staticText1, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); } else { fgSizer1->AddSpacer( 5 ); } // Email address of contributor at third column if ( contributor->GetEMail() != wxEmptyString ) { wxHyperlinkCtrl* hyperlink = CreateHyperlink( m_scrolledWindow1, contributor->GetEMail() ); fgSizer1->Add( hyperlink, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); } else { fgSizer1->AddSpacer( 5 ); } } bSizer->Add( panel1, 1, wxEXPAND|wxALL, 10 ); bSizer->Add( fgSizer1, 7, wxEXPAND|wxALL, 10 ); // adjust width of panel with first int value m_scrolledWindow1->SetSizer( bSizer ); m_scrolledWindow1->Layout(); bSizer->Fit( m_scrolledWindow1 ); aParent->AddPage( m_scrolledWindow1, aCaption, false, aIcon ); }
XMLHyperlink::XMLHyperlink(Element * inParent, const AttributesMapping & inAttr) : Element(XMLHyperlink::TagName(), inParent, CreateHyperlink(inParent->component(), inAttr)) { }
virtual void RecreateWidget() { CreateHyperlink(); }
void dialog_about::CreateNotebookPageByCategory(wxAuiNotebook* aParent, const wxString& aCaption, const wxBitmap& aIcon, const Contributors& aContributors) { wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL ); wxScrolledWindow* m_scrolledWindow1 = new wxScrolledWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); m_scrolledWindow1->SetScrollRate( 5, 5 ); /* Panel for additional space at the left, * but can also be used to show an additional bitmap. */ wxPanel* panel1 = new wxPanel( m_scrolledWindow1 ); wxFlexGridSizer* fgSizer1 = CreateFlexGridSizer(); for( size_t i=0; i < aContributors.GetCount(); ++i ) { Contributor* contributor = &aContributors.Item( i ); wxBitmap* icon = contributor->GetIcon(); wxString category = contributor->GetCategory(); /* to construct the next row we expect to have * a category and a contributor that was not considered up to now */ if( ( category != wxEmptyString ) && !( contributor->IsChecked() ) ) { // Icon at first column wxStaticBitmap* m_bitmap1 = CreateStaticBitmap( m_scrolledWindow1, icon ); fgSizer1->Add( m_bitmap1, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, 5 ); // Category name at second column wxStaticText* m_staticText1 = new wxStaticText( m_scrolledWindow1, wxID_ANY, contributor->GetCategory() + wxT( ":" ), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->SetFont( wxFont( -1, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); // bold font m_staticText1->Wrap( -1 ); fgSizer1->Add( m_staticText1, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); // Nothing at third column fgSizer1->AddSpacer( 5 ); // Now, all contributors of the same category will follow for( size_t j=0; j < aContributors.GetCount(); ++j ) { Contributor* sub_contributor = &aContributors.Item( j ); if ( sub_contributor->GetCategory() == category ) { // First column is empty fgSizer1->AddSpacer(5); // Name of contributor at second column wxStaticText* m_staticText2 = new wxStaticText( m_scrolledWindow1, wxID_ANY, wxT(" • ") + sub_contributor->GetName(), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->Wrap( -1 ); fgSizer1->Add( m_staticText2, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); // Email address of contributor at third column if( sub_contributor->GetEMail() != wxEmptyString ) { wxHyperlinkCtrl* hyperlink = CreateHyperlink( m_scrolledWindow1, sub_contributor->GetEMail() ); fgSizer1->Add( hyperlink, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); } else { fgSizer1->AddSpacer( 5 ); } /* this contributor was added to the GUI, * thus can be ignored next time */ sub_contributor->SetChecked( true ); } } } else { continue; } } /* Now, lets list the remaining contributors that have not been considered * because they were not assigned to any category. */ for ( size_t k=0; k < aContributors.GetCount(); ++k ) { Contributor* contributor = &aContributors.Item( k ); if ( contributor->IsChecked() ) continue; // Icon at first column wxStaticBitmap* m_bitmap1 = CreateStaticBitmap( m_scrolledWindow1, contributor->GetIcon() ); fgSizer1->Add( m_bitmap1, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, 5 ); // Name of contributor at second column if( contributor->GetName() != wxEmptyString ) { wxStaticText* m_staticText1 = new wxStaticText( m_scrolledWindow1, wxID_ANY, contributor->GetName(), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->Wrap( -1 ); fgSizer1->Add( m_staticText1, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); } else { fgSizer1->AddSpacer( 5 ); } // Email address of contributor at third column if ( contributor->GetEMail() != wxEmptyString ) { wxHyperlinkCtrl* hyperlink = CreateHyperlink( m_scrolledWindow1, contributor->GetEMail() ); fgSizer1->Add( hyperlink, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); } else { fgSizer1->AddSpacer( 5 ); } } bSizer->Add( panel1, 1, wxEXPAND|wxALL, 10 ); bSizer->Add( fgSizer1, 7, wxEXPAND|wxALL, 10 ); // adjust width of panel with first int value m_scrolledWindow1->SetSizer( bSizer ); m_scrolledWindow1->Layout(); bSizer->Fit( m_scrolledWindow1 ); aParent->AddPage( m_scrolledWindow1, aCaption, false, aIcon ); }
void SMessageLogMessageListRow::CreateMessage(const TSharedRef<SHorizontalBox>& InHorzBox, const TSharedRef<IMessageToken>& InMessageToken, float Padding) { TSharedPtr<SWidget> RowContent; FName IconBrushName; TAttribute<EVisibility> TokenContentVisbility; switch (InMessageToken->GetType()) { case EMessageToken::Image: { const TSharedRef<FImageToken> ImageToken = StaticCastSharedRef<FImageToken>(InMessageToken); if (ImageToken->GetImageName() != NAME_None) { if (InMessageToken->GetOnMessageTokenActivated().IsBound()) { RowContent = SNew(SButton) .OnClicked(this, &SMessageLogMessageListRow::HandleTokenButtonClicked, InMessageToken) .Content() [ SNew(SImage) .Image(FEditorStyle::GetBrush(ImageToken->GetImageName())) ]; } else { RowContent = SNew(SImage) .Image(FEditorStyle::GetBrush(ImageToken->GetImageName())); } } } break; case EMessageToken::Object: { const TSharedRef<FUObjectToken> UObjectToken = StaticCastSharedRef<FUObjectToken>(InMessageToken); IconBrushName = FName("PropertyWindow.Button_Browse"); UObject* Object = nullptr; // Due to blueprint reconstruction, we can't directly use the Object as it will get trashed during the blueprint reconstruction and the message token will no longer point to the right UObject. // Instead we will retrieve the object from the name which should always be good. if (UObjectToken->GetObject().IsValid()) { if (!UObjectToken->ToText().ToString().Equals(UObjectToken->GetObject().Get()->GetName())) { Object = FindObject<UObject>(nullptr, *UObjectToken->GetOriginalObjectPathName()); } else { Object = const_cast<UObject*>(UObjectToken->GetObject().Get()); } } else { // We have no object (probably because is now stale), try finding the original object linked to this message token to see if it still exist Object = FindObject<UObject>(nullptr, *UObjectToken->GetOriginalObjectPathName()); } RowContent = CreateHyperlink(InMessageToken, FUObjectToken::DefaultOnGetObjectDisplayName().IsBound() ? FUObjectToken::DefaultOnGetObjectDisplayName().Execute(Object, true) : UObjectToken->ToText()); } break; case EMessageToken::URL: { const TSharedRef<FURLToken> URLToken = StaticCastSharedRef<FURLToken>(InMessageToken); IconBrushName = FName("MessageLog.Url"); RowContent = CreateHyperlink(InMessageToken, FText::FromString(URLToken->GetURL())); } break; case EMessageToken::EdGraph: { IconBrushName = FName("PropertyWindow.Button_Browse"); RowContent = CreateHyperlink(InMessageToken, InMessageToken->ToText()); } break; case EMessageToken::Action: { const TSharedRef<FActionToken> ActionToken = StaticCastSharedRef<FActionToken>(InMessageToken); IconBrushName = FName("MessageLog.Action"); RowContent = SNew(SHyperlink) .Text(InMessageToken->ToText()) .ToolTipText(ActionToken->GetActionDescription()) .TextStyle(FEditorStyle::Get(), "MessageLog") .OnNavigate(this, &SMessageLogMessageListRow::HandleActionHyperlinkNavigate, ActionToken); TokenContentVisbility = TAttribute<EVisibility>::Create(TAttribute<EVisibility>::FGetter::CreateRaw(this, &SMessageLogMessageListRow::GetActionLinkVisibility, ActionToken)); } break; case EMessageToken::AssetName: { const TSharedRef<FAssetNameToken> AssetNameToken = StaticCastSharedRef<FAssetNameToken>(InMessageToken); IconBrushName = FName("PropertyWindow.Button_Browse"); RowContent = CreateHyperlink(InMessageToken, AssetNameToken->ToText()); } break; #if WITH_EDITOR case EMessageToken::Documentation: { const TSharedRef<FDocumentationToken> DocumentationToken = StaticCastSharedRef<FDocumentationToken>(InMessageToken); IconBrushName = FName("MessageLog.Docs"); RowContent = SNew(SHyperlink) .Text(LOCTEXT("DocsLabel", "Docs")) .ToolTip(IDocumentation::Get()->CreateToolTip( LOCTEXT("DocumentationTokenToolTip", "Click to open documentation"), NULL, DocumentationToken->GetPreviewExcerptLink(), DocumentationToken->GetPreviewExcerptName()) ) .TextStyle(FEditorStyle::Get(), "MessageLog") .OnNavigate(this, &SMessageLogMessageListRow::HandleDocsHyperlinkNavigate, DocumentationToken->GetDocumentationLink()); } break; case EMessageToken::Text: { if (InMessageToken->GetOnMessageTokenActivated().IsBound()) { RowContent = CreateHyperlink(InMessageToken, InMessageToken->ToText()); } else { FString MessageString = InMessageToken->ToText().ToString(); // ^((?:[\w]\:|\\)(?:(?:\\[a-z_\-\s0-9\.]+)+)\.(?:cpp|h))\((\d+)\) // https://regex101.com/r/vV4cV7/1 FRegexPattern FileAndLinePattern(TEXT("^((?:[\\w]\\:|\\\\)(?:(?:\\\\[a-z_\\-\\s0-9\\.]+)+)\\.(?:cpp|h))\\((\\d+)\\)")); FRegexMatcher FileAndLineRegexMatcher(FileAndLinePattern, MessageString); TSharedRef<SWidget> SourceLink = SNullWidget::NullWidget; if ( FileAndLineRegexMatcher.FindNext() ) { FString FileName = FileAndLineRegexMatcher.GetCaptureGroup(1); int32 LineNumber = FCString::Atoi(*FileAndLineRegexMatcher.GetCaptureGroup(2)); // Remove the hyperlink from the message, since we're splitting it into its own string. MessageString = MessageString.RightChop(FileAndLineRegexMatcher.GetMatchEnding()); SourceLink = SNew(SHyperlink) .Style(FEditorStyle::Get(), "Common.GotoNativeCodeHyperlink") .TextStyle(FEditorStyle::Get(), "MessageLog") .OnNavigate_Lambda([=] { FSlateApplication::Get().GotoLineInSource(FileName, LineNumber); }) .Text(FText::FromString(FileAndLineRegexMatcher.GetCaptureGroup(0))); } RowContent = SNew(SHorizontalBox) + SHorizontalBox::Slot() .AutoWidth() .Padding(0) [ SourceLink ] + SHorizontalBox::Slot() .AutoWidth() .Padding(0) [ SNew(STextBlock) .ColorAndOpacity(FSlateColor::UseSubduedForeground()) .Text(FText::FromString(MessageString)) ]; } } break; case EMessageToken::Tutorial: { const TSharedRef<FTutorialToken> TutorialToken = StaticCastSharedRef<FTutorialToken>(InMessageToken); IconBrushName = FName("MessageLog.Tutorial"); RowContent = SNew(SHyperlink) .Text(LOCTEXT("TutorialLabel", "Tutorial")) .ToolTipText(LOCTEXT("TutorialTokenToolTip", "Click to open tutorial")) .TextStyle(FEditorStyle::Get(), "MessageLog") .OnNavigate(this, &SMessageLogMessageListRow::HandleTutorialHyperlinkNavigate, TutorialToken->GetTutorialAssetName()); } break; #endif } if (RowContent.IsValid()) { InHorzBox->AddSlot() .AutoWidth() .VAlign(VAlign_Center) .Padding(Padding, 0.0f, 0.0f, 0.0f) [ SNew(SHorizontalBox) .Visibility(TokenContentVisbility.IsBound() ? TokenContentVisbility : EVisibility::Visible) + SHorizontalBox::Slot() .AutoWidth() .VAlign(VAlign_Center) [ (IconBrushName == NAME_None) ? SNullWidget::NullWidget : static_cast<TSharedRef<SWidget>>(SNew(SImage) .ColorAndOpacity(FSlateColor::UseForeground()) .Image(FEditorStyle::GetBrush(IconBrushName))) ] + SHorizontalBox::Slot() .AutoWidth() .VAlign(VAlign_Center) .Padding(2.0f, 0.0f, 0.0f, 0.0f) [ RowContent.ToSharedRef() ] ]; } }