summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFabien Costantini <fabien@onepost.net>2008-11-05 12:54:39 +0000
committerFabien Costantini <fabien@onepost.net>2008-11-05 12:54:39 +0000
commitc6b9818f4a2a969460a515e46d36c4655a703c58 (patch)
tree63dd537542c375e6c396a888d1075df2a2370baf /src
parent8094043bcb0a2b010bae7cfc461fd3886f710383 (diff)
Got inspired from manolo STR#2067 proposal to fix OSX window title not utf8 aware, but generalized it so that all Fl_mac.cxx calls the same new q_set_window_title() function(). Now OSX Window shows UTF8 title correctly. old code is still present but factorized in the new q_set_window_title() function(BTW the Str255 truncation was omitted in one part of the old code), please review so that we can remove that old non-UTF8 aware code.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6498 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_mac.cxx36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index c7737213c..5d5f5cfce 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -1956,7 +1956,24 @@ static pascal OSErr dndReceiveHandler( WindowPtr w, void *userData, DragReferenc
breakMacEventLoop();
return noErr;
}
-
+// fc:
+static void q_set_window_title(Window xid, const char * name ) {
+#if 1
+ CFStringRef utf8_title = CFStringCreateWithCString(NULL, (name ? name : ""), kCFStringEncodingUTF8);
+ SetWindowTitleWithCFString(xid, utf8_title);
+ CFRelease(utf8_title);
+#else // old non-utf8 code to remove after new utf8 code approval :
+ Str255 pTitle;
+ if (name) {
+ if (strlen(name) > 255) pTitle[0] = 255;
+ else pTitle[0] = strlen(name);
+ memcpy(pTitle+1, name, pTitle[0]);
+ }
+ else
+ pTitle[0] = 0;
+ SetWTitle(xid, pTitle);
+#endif
+}
/**
* go ahead, create that (sub)window
@@ -2068,13 +2085,6 @@ void Fl_X::make(Fl_Window* w)
wRect.right = w->x() + w->w(); if (wRect.right<=wRect.left) wRect.right = wRect.left+1;
const char *name = w->label();
- Str255 pTitle;
- if (name) {
- if (strlen(name) > 255) pTitle[0] = 255;
- else pTitle[0] = strlen(name);
-
- memcpy(pTitle+1, name, pTitle[0]);
- } else pTitle[0] = 0;
Fl_X* x = new Fl_X;
x->other_xid = 0; // room for doublebuffering image map. On OS X this is only used by overlay windows
@@ -2087,7 +2097,7 @@ void Fl_X::make(Fl_Window* w)
winattr &= GetAvailableWindowAttributes( winclass ); // make sure that the window will open
CreateNewWindow( winclass, winattr, &wRect, &(x->xid) );
- SetWTitle(x->xid, pTitle);
+ q_set_window_title(x->xid, name);
MoveWindow(x->xid, wRect.left, wRect.top, 1); // avoid Carbon Bug on old OS
if (w->non_modal() && !w->modal()) {
// Major kludge: this is to have the regular look, but stay above the document windows
@@ -2224,12 +2234,10 @@ const char *fl_filename_name( const char *name )
*/
void Fl_Window::label(const char *name,const char */*iname*/) {
Fl_Widget::label(name);
- Str255 pTitle;
-
- if (name) { pTitle[0] = strlen(name); memcpy(pTitle+1, name, pTitle[0]); }
- else pTitle[0] = 0;
- if (shown() || i) SetWTitle(fl_xid(this), pTitle);
+ if (shown() || i) {
+ q_set_window_title(fl_xid(this), name);
+ }
}