Large wxFileDialog [SOLVED]

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
Tony0945
Earned some good credits
Earned some good credits
Posts: 105
Joined: Wed Oct 21, 2009 4:02 pm

Large wxFileDialog [SOLVED]

Post by Tony0945 »

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:

Code: Select all

#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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Large wxFileDialog

Post by ONEEYEMAN »

Hi,
I don't think you can play with the standard dialogues behaviour like this.
Keep in mind that the HiDPI stuff is still WIP and not finished yet.

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Large wxFileDialog

Post by doublemax »

I don't think there is a way to make the native filedialog do this.

You can however try to use the generic filedialog.

Code: Select all

#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.
Use the source, Luke!
Tony0945
Earned some good credits
Earned some good credits
Posts: 105
Joined: Wed Oct 21, 2009 4:02 pm

Re: Large wxFileDialog

Post by Tony0945 »

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.

Thank you once again, doublemax.
Tony0945
Earned some good credits
Earned some good credits
Posts: 105
Joined: Wed Oct 21, 2009 4:02 pm

Re: Large wxFileDialog

Post by Tony0945 »

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.

Many many thanks.
Post Reply