wxAboutDialogInfo - How to center align text in SetLicense()?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
apoorv569
Super wx Problem Solver
Super wx Problem Solver
Posts: 426
Joined: Tue Oct 20, 2020 3:35 pm

wxAboutDialogInfo - How to center align text in SetLicense()?

Post by apoorv569 »

I am creating a about dialog for my application and having some text alignment problem with the SetLicense(). In the beginning I have my application name, and under it I have the line that says "Copyright (c) (year) Author" both of the lines I want to center align. Below these lines the actual license starts. For now I just tried adding a lot of spaces until it looked in the center. Is there a better way to do it? Here is the function that creates the about dialog,

Code: Select all

void MainFrame::OnSelectAbout(wxCommandEvent& event)
{
    wxAboutDialogInfo aboutInfo;

    aboutInfo.SetName("SampleHive");
    aboutInfo.SetIcon(wxIcon(ICON_APP));
    aboutInfo.AddArtist("Apoorv");
    aboutInfo.SetVersion("0.1", "Version 0.1");
    aboutInfo.SetDescription("A simple, modern audio sample browser/manager for GNU/Linux.");
    aboutInfo.SetCopyright("(C) 2020-2021");
    aboutInfo.SetWebSite("http://samplehive.gitlab.io");
    aboutInfo.AddDeveloper("Apoorv");
    aboutInfo.SetLicence(wxString::FromAscii(
                             "                                                          SampleHive  \n"
                             "                                      Copyright (C) 2021  Apoorv      \n"
                             "\n"
                             "This program is free software: you can redistribute it and/or modify\n"
                             "it under the terms of the GNU General Public License as published by\n"
                             "the Free Software Foundation, either version 3 of the License, or\n"
                             "(at your option) any later version.\n"
                             "\n"
                             "This program is distributed in the hope that it will be useful,\n"
                             "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
                             "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
                             "GNU General Public License for more details.\n"
                             "\n"
                             "You should have received a copy of the GNU General Public License\n"
                             "along with this program.  If not, see <https://www.gnu.org/licenses/>.\n"
                         ));

    wxAboutBox(aboutInfo);
}
And it looks like this,
Image

Also is it necessary to have wxString::FromAscii(), in the SetLicense(). I grabbed that from dialog demo in wx source.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxAboutDialogInfo - How to center align text in SetLicense()?

Post by doublemax »

Looking through both the API and the actual source code, i'd say it's not possible.

Personally, i just use a wxHtmlWindow which is capable enough for stuff like this.
Use the source, Luke!
apoorv569
Super wx Problem Solver
Super wx Problem Solver
Posts: 426
Joined: Tue Oct 20, 2020 3:35 pm

Re: wxAboutDialogInfo - How to center align text in SetLicense()?

Post by apoorv569 »

doublemax wrote: Wed Jul 07, 2021 8:06 pm Looking through both the API and the actual source code, i'd say it's not possible.

Personally, i just use a wxHtmlWindow which is capable enough for stuff like this.
I see, is there a demo sample for wxHtmlWindow that I can view?
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxAboutDialogInfo - How to center align text in SetLicense()?

Post by doublemax »

<wxdir>/samples/html/about/
Use the source, Luke!
apoorv569
Super wx Problem Solver
Super wx Problem Solver
Posts: 426
Joined: Tue Oct 20, 2020 3:35 pm

Re: wxAboutDialogInfo - How to center align text in SetLicense()?

Post by apoorv569 »

doublemax wrote: Wed Jul 07, 2021 11:29 pm <wxdir>/samples/html/about/
Interesting, if I understand correctly, this wxHtmlWindow, basically is a wxDialog with a Html widget that displays a Html document/file i.e for example some file on my system called file.html? And I can format the Html document as I like.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxAboutDialogInfo - How to center align text in SetLicense()?

Post by doublemax »

wxHtmlWindow is just a control that can display simple HTML 1.0(!) code. No CSS, JS, etc. The data can also be a string, it doesn't have to be an external file, so you can easily build it at runtime.
Use the source, Luke!
Post Reply