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.
I'm writing a simple app to be run on a raspberry pi wherein the user selects a video file to run. VLC does this but the font is too small to read unless you walk right up to the TV. A File seclection dialog is perfect except both the dialog and font seem to be a fixed size, too small.
I want the Dialog to fill the screen and the font large enough to be read across the room. Here's my code:
#include "MovieServerApp.h"
IMPLEMENT_APP(MovieServerDlgApp)
bool MovieServerDlgApp::OnInit()
{
wxFileDialog* dialog = new wxFileDialog(NULL,"Select Film to watch");
wxFont font=dialog->GetFont();
font.Scale(5.0);
dialog->SetFont(font);
dialog->SetWildcard("Video files (*.mpg)|*.mpg");
dialog->SetDirectory("V:\\SageTV");
SetTopWindow(dialog);
while (dialog->ShowModal() == wxID_OK) // if the user clicks "Open" instead of "Cancel"
{
wxMessageBox("Selected "+ dialog->GetPath());
}
exit(0);
return true;
}
int MovieServerDlgApp::OnExit()
{
return 0;
}
The messageBox is to be changed later to wxExecute launching mplayer.
The above code has no effect no matter what value is passed to Scale().
Testing first in Windows. Haven't tried Linux yet.
Last edited by Tony0945 on Fri Feb 02, 2018 3:53 pm, edited 1 time in total.
#include "wx/generic/filedlgg.h"
...
wxGenericFileDialog dlg;
dlg.SetFont( GetFont().Scale(2.0) );
dlg.Create( this, "open file", "", "", "*.*", wxFD_OPEN|wxFD_FILE_MUST_EXIST );
//dlg.OnReport( wxCommandEvent() ); // ugly. don't try this at home
dlg.ShowModal();
But the wxGenericFileDialog code is not linked to the library when a native implementation exists. Therefore you have to add its source file to your project. ( <wxdir>/src/generic/filedlgg.cpp )
I tested it under Windows and there it works. I don't know about Linux.
Got it working on Windows with doublemax's suggestion. it's ugly but it scales. I can customize that generic dialog to look better. Also it always statrts at the top of the file hierarchy, instead of drive V: but I'm sure that can be fixed too.
Will report back with Linux results for those who care (like me) or are curious.
Yes, it works on Linux (wxGTK-3.0.2)! In fact it looks much better on Linux than windows. It may be my desktop theme but the directories are in blue and the files are in red. On Windows both are black. On Windows the buttons are skinny rectangular and it's hard to see the icons. On Linux, the buttons are square and the icons are distinct.
Since my intended target is Raspberry Pi, I'm only interested in the Linux. Was developing on Windows as a convenience.