Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » FileSel&FileList, Path » FileSel bug when displaying Han characters
FileSel bug when displaying Han characters [message #14953] Sat, 22 March 2008 08:35 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I was just about to get started with giving FileSel the face lift I promised a while ago, when I noticed this bug. It is hard to see in the picture, but the last two items in the list have their extension drawn over the file name. The name of the file is correctly drawn in the file info portion bellow, so I think it is related to the way the extension is made to appear blue.

index.php?t=getfile&id=1095&private=0
  • Attachment: FileSel.PNG
    (Size: 19.23KB, Downloaded 804 times)
Re: FileSel bug when displaying Han characters [message #14969 is a reply to message #14953] Sun, 23 March 2008 12:06 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Here is the same dialog after the face lift:

index.php?t=getfile&id=1101&private=0

I think it looks now almost 100% native, even though the same U++ code runs in the background. No more strange looks on peoples faces when they click open! The best part is, it even has better functionality then the native one thanks to search box, column list column resizing and name/extension sorting.

There is a lot to be done yet:
1. The new quick link buttons are just for show. Need to implement functionality for them.

2. The images are embedded into the exe and I think it should be better to rip them directly from shell32.dll. I have no idea how to do this yet, or if the indexes of a given icon in the dll are constant across OS versions.

3. Must no forget about Linux! Since theming is Gtk based, I'll make it look like a Gtk FileSel dialog.
  • Attachment: FileSelXP.PNG
    (Size: 32.35KB, Downloaded 840 times)
Re: FileSel bug when displaying Han characters [message #14971 is a reply to message #14953] Sun, 23 March 2008 14:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
Well, looks like "GetTextSize" problem to me...

Maybe you can place a nice DDUMP into the routine.

Can you send me the file zipped? Smile (you can delete the content, I just have problems creating CJK filenames Smile

Mirek
Re: FileSel bug when displaying Han characters [message #14972 is a reply to message #14969] Sun, 23 March 2008 14:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
cbpporter wrote on Sun, 23 March 2008 07:06

Here is the same dialog after the face lift:

index.php?t=getfile&id=1101&private=0

I think it looks now almost 100% native, even though the same U++ code runs in the background. No more strange looks on peoples faces when they click open! The best part is, it even has better functionality then the native one thanks to search box, column list column resizing and name/extension sorting.



Yeah, that is where I wish to be heading. I only do not like Open/Cancel buttons eating the space on right.

Quote:


2. The images are embedded into the exe and I think it should be better to rip them directly from shell32.dll. I have no idea how to do this yet, or if the indexes of a given icon in the dll are constant across OS versions.



AFAIK, they are fixed. You can use

Image Win32DllIcon(const char *dll, int ii, bool large);

to retrieve them.

Mirek
Re: FileSel bug when displaying Han characters [message #14985 is a reply to message #14953] Mon, 24 March 2008 13:17 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
I feel like the Open/Cancel in facelifted version is smaller (I'm too lazy to measure it, that's why I just "feel").

Any good idea how make them bigger (more important)? The original version had IMO more appeal in it, and I think GTK has even more emphasize on such important buttons?
Re: FileSel bug when displaying Han characters [message #14987 is a reply to message #14985] Mon, 24 March 2008 14:07 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Quote:

AFAIK, they are fixed. You can use
Image Win32DllIcon(const char *dll, int ii, bool large);
to retrieve them.

Thanks. Works well. I'll implement the functionality too, but I think I'll have to refactor a little the FileSel code. You don't mind, do you?

Quote:

Can you send me the file zipped? (you can delete the content, I just have problems creating CJK filenames

I tried attaching a file with that name, but no luck. Also, zip does not allow those characters and in rar they where replaced by underscores. Talk about good Unicode support Smile. But you should be able to rename any file on your system by copy-pasting the name from here. The text was: 皆の日本語.

mr_ped wrote on Mon, 24 March 2008 14:17

I feel like the Open/Cancel in facelifted version is smaller (I'm too lazy to measure it, that's why I just "feel").

Any good idea how make them bigger (more important)?

I think they are the same size. What kind of idea do you need to make them bigger? Smile

Quote:

The original version had IMO more appeal in it, and I think GTK has even more emphasize on such important buttons?

I'm not sure I understand what you mean...
Re: FileSel bug when displaying Han characters [message #14988 is a reply to message #14987] Mon, 24 March 2008 14:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
cbpporter wrote on Mon, 24 March 2008 09:07

Quote:

AFAIK, they are fixed. You can use
Image Win32DllIcon(const char *dll, int ii, bool large);
to retrieve them.

Thanks. Works well. I'll implement the functionality too, but I think I'll have to refactor a little the FileSel code. You don't mind, do you?



Depends what you expect Smile U++ is BSD license, means you can do whatever you want. Accepting patch into the "main tree" is completely different issue Wink

Quote:

The text was: 皆の日本語.


I see just question marks here Smile

Mirek
Re: FileSel bug when displaying Han characters [message #14989 is a reply to message #14988] Mon, 24 March 2008 14:45 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
luzr wrote on Mon, 24 March 2008 15:29


I see just question marks here Smile

Mirek

Try this if you're willing to sacrifice about 200MB of disk space: http://www.microsoft.com/globaldev/handson/user/xpintlsupp.m spx
Re: FileSel bug when displaying Han characters [message #15014 is a reply to message #14988] Tue, 25 March 2008 23:22 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
[quote title=luzr wrote on Mon, 24 March 2008 15:29]
cbpporter wrote on Mon, 24 March 2008 09:07


Depends what you expect Smile U++ is BSD license, means you can do whatever you want. Accepting patch into the "main tree" is completely different issue Wink


Well I don't expect anything, but it would be nice if it were included, since I consider it a nice improvement and I really want my apps to look native (I guess you already figured that out by the number of visual bugs I commented upon). So following that idea, I kept any unnecessary modification which I would have done out, and practically only added some extra buttons, modified a function or two and an extra layout.

It works fine, but it does have some limitations. For example, .lnk files are not read and displayed as explorer would, Desktop link does not display all items on you desktop, only those which are physically present in you directory (explorer would pull those links from multiple dirs), and most importantly, network browsing doesn't work.

I'll reinstall Linux and emulate Gtk look next.
Re: FileSel bug when displaying Han characters [message #15022 is a reply to message #15014] Wed, 26 March 2008 10:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
[quote title=cbpporter wrote on Tue, 25 March 2008 18:22]
luzr wrote on Mon, 24 March 2008 15:29

cbpporter wrote on Mon, 24 March 2008 09:07


Depends what you expect Smile U++ is BSD license, means you can do whatever you want. Accepting patch into the "main tree" is completely different issue Wink


Well I don't expect anything, but it would be nice if it were included, since I consider it a nice improvement and I really want my apps to look native (I guess you already figured that out by the number of visual bugs I commented upon). So following that idea, I kept any unnecessary modification which I would have done out, and practically only added some extra buttons, modified a function or two and an extra layout.

It works fine, but it does have some limitations. For example, .lnk files are not read and displayed as explorer would, Desktop link does not display all items on you desktop, only those which are physically present in you directory (explorer would pull those links from multiple dirs), and most importantly, network browsing doesn't work.

I'll reinstall Linux and emulate Gtk look next.



Are you aware than in Vista, it looks different again?

What I want to say, yes, let us make it as familiar as possible, fix all issues and perhaps add something to make it better. But I would like to find some middle ground, having single layout for all XP/Vista/Gtk.

And yes, network browsing is a major problem. I have even started solving this (in Win32), but abandoned for the lack of time&energy. Anyway, preliminary support is already in Core.

The main problem with current FileSel code and network browing is that network browsing abandons the concept of "path" - you are just going through some nodes. This makes it a little bit difficult to e.g. serialize the current position of FileSel...

So basically, I ended at this. Anyway, further thinking was that perhaps we could emulate the path there, just introduce some arbitrary format to express network nodes. Something like
"::Network places::The Whole Network::Microsoft Windows::My Group::Server". The only problem is that entering Server you get "regular path" again like: \\server\share_c and the question is what is to happen if you press "Dir up" button here....

Mirek

Mirek
Re: FileSel bug when displaying Han characters [message #15023 is a reply to message #15022] Wed, 26 March 2008 11:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
Oh, great. Looks like GetTextSize does not work with CJK:

void MyApp::Paint(Draw& w)
{
	w.DrawRect(GetSize(), SWhite);
	String txt = "皆の日本語";
	Size sz = GetTextSize(txt, Arial(30));
	w.DrawRect(100, 100, sz.cx, sz.cy, LtGray());
	w.DrawText(100, 100, txt, Arial(30));
}

GUI_APP_MAIN
{
	SetDefaultCharset(CHARSET_UTF8);
	MyApp().Run();
}


I was going down and it finally turned out that "GetCharWidthABC" does not return correct sizes for whatever reason. Just great...

(in void FontInfo::Data::GetMetrics(int page, CharMetrics *t))

Mirek
Re: FileSel bug when displaying Han characters [message #15024 is a reply to message #15014] Wed, 26 March 2008 11:58 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
Quote:

... I really want my apps to look native ...

I think, it is much more simple to use Windows's built in file selector component to get native look and feel.
It is very simple using FileSelector class instead of FileSel.
Re: FileSel bug when displaying Han characters [message #15025 is a reply to message #15024] Wed, 26 March 2008 12:27 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Quote:

Are you aware than in Vista, it looks different again?

What I want to say, yes, let us make it as familiar as possible, fix all issues and perhaps add something to make it better. But I would like to find some middle ground, having single layout for all XP/Vista/Gtk.


Yes, I'm aware and I have no intention to emulate that look and would strongly advice against it, simply because Vista FileSel dialogs have very poor functionality and ergonomics. They are poorly suited for anything except If you want to open a file from you documents folder. I don't know who designed them, but certainly did a poor job.

As for a middle ground, I would propose basically the same layout that you had, only with a nav bar on the right. As you can see in the first two images, the dialogs are almost identical, but with a few items moved around, a navbar and OS icons, it looks familiar. Also, I looked over GTK one, and just remembered that it also has not the best ergonomics: it is without a path input field and has few locations in it's quick bar. The good part is that you can add extra ones and also has a nice folder navigation toolbar on top.
Re: FileSel bug when displaying Han characters [message #15026 is a reply to message #15023] Wed, 26 March 2008 13:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
OK, further investigation:

void MyApp::Paint(Draw& w)
{
	w.DrawRect(GetSize(), SWhite);
	WString txt = "皆の日本語";
	Size sz = GetTextSize(txt, StdFont(30));
	w.DrawRect(100, 100, sz.cx, sz.cy, LtGray());
	w.DrawText(100, 100, txt, StdFont(30));
	sz = GetTextSize(txt, Arial(30));
	w.DrawRect(100, 200, sz.cx, sz.cy, LtGray());
	w.DrawText(100, 200, txt, Arial(30));
}


...it looks like Win32 always paints it using some standard font other than Arial. Standard GUI font returns correct metrics for this font; Arial returns wrong metrics.

Now tell me what to do with this... Sad I certainly could take metrics from different font, but that sounds a little bit weird... (and I am not sure it would always work).

Mirek
Re: FileSel bug when displaying Han characters [message #15028 is a reply to message #15026] Wed, 26 March 2008 13:19 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
Nope, I was wrong:

void MyApp::Paint(Draw& w)
{
	w.DrawRect(GetSize(), SWhite);
	WString txt = "皆の日本語";
	Font fnt[4] = { StdFont(30), Arial(30), Roman(30), Courier(30) };
	for(int i = 0; i < 4; i++) {
		Size sz = GetTextSize(txt, fnt[i]);
		w.DrawRect(10, 100 + 50 * i, sz.cx, sz.cy, LtGray());
		w.DrawText(10, 100 + 50 * i, txt, fnt[i]);
	}
}


So it seems to return correct values for StdFont (which in fact is Tahoma) and Courier, wrong values for Arial, Times New Roman...

Damn it...

Mirek
Re: FileSel bug when displaying Han characters [message #15029 is a reply to message #15028] Wed, 26 March 2008 13:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
Just a bit improved testcase, to show it should work (with non-ASCII roman chars):

void MyApp::Paint(Draw& w)
{
	w.DrawRect(GetSize(), SWhite);
	WString txt = "?????";
	for(int q = 0; q < 2; q++) {
		Font fnt[4] = { StdFont(30), Arial(30), Roman(30), Courier(30) };
		for(int i = 0; i < 4; i++) {
			Size sz = GetTextSize(txt, fnt[i]);
			w.DrawRect(10 + q * 250, 100 + 50 * i, sz.cx, sz.cy, LtGray());
			w.DrawText(10 + q * 250, 100 + 50 * i, txt, fnt[i]);
		}
		txt = "ÈŠÌŠÈìšèìšè";
	}
}


Mirek
Re: FileSel bug when displaying Han characters [message #15037 is a reply to message #15029] Wed, 26 March 2008 16:18 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Proportions seem OK, except the fact that it displays only question marks and boxes. I know that under X11, when dealing with characters not available for a font, they are sometimes pulled from a different font (depends on windowmanager). Windows definitely does this, and it plain right changes the font sometimes to adapt to the characters. But I don't know how it works. Have to Google a little.

PS: How did you enter the CJK characters in that literal? Does that even compile?
Re: FileSel bug when displaying Han characters [message #15039 is a reply to message #15037] Wed, 26 March 2008 16:59 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
cbpporter wrote on Wed, 26 March 2008 11:18

Proportions seem OK, except the fact that it displays only question marks and boxes.



Well, then something more is wrong. It should display CJK, but background rectangle ("GetTextSize") is wrong...

Quote:


I know that under X11, when dealing with characters not available for a font, they are sometimes pulled from a different font (depends on windowmanager).



Yes, but that is the job of toolkit, not windows manager.

Quote:


PS: How did you enter the CJK characters in that literal? Does that even compile?



Set the file to utf-8 Wink

Mirek
Re: FileSel bug when displaying Han characters [message #15041 is a reply to message #15039] Wed, 26 March 2008 17:02 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
index.php?t=getfile&id=1108&private=0
  • Attachment: h.png
    (Size: 702.16KB, Downloaded 621 times)
Re: FileSel bug when displaying Han characters [message #15085 is a reply to message #15041] Sat, 29 March 2008 15:44 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13974
Registered: November 2005
Ultimate Member
OK, looks like I have found the workaround, so consider this fixed.

Well, in the process I had to refactor the whole Font infrastructure too, because workaround made it too slow... Smile

(Fix is to scattered to be posted here).

Mirek
Previous Topic: Getting the file type. (binary vs text files)
Next Topic: FileSel ExecuteSaveAs replace file prompt bug
Goto Forum:
  


Current Time: Tue Mar 19 04:41:13 CET 2024

Total time taken to generate the page: 0.01055 seconds