Rewrite Fl_Window::label(const char *name, const char *mininame) under the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11394 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
9ba3889ae5
commit
3f34aba828
@ -74,6 +74,7 @@ public:
|
||||
virtual void draw_end();
|
||||
void draw();
|
||||
virtual void make_current();
|
||||
virtual void label(const char *name, const char *mininame);
|
||||
|
||||
virtual Fl_X *makeWindow() { /* FIXME: move Fl_X::make(Fl_Window*) here for OSX, MSWin, and X11 */ return 0; }
|
||||
virtual void wait_for_expose() {} // TODO: check
|
||||
|
@ -487,6 +487,12 @@ void Fl_Window::make_current()
|
||||
current_ = this;
|
||||
}
|
||||
|
||||
void Fl_Window::label(const char *name, const char *mininame) {
|
||||
Fl_Widget::label(name);
|
||||
iconlabel_ = mininame;
|
||||
pWindowDriver->label(name, mininame);
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -43,6 +43,7 @@ unsigned char Fl_Window_Driver::size_range_set() {return pWindow->size_range_set
|
||||
void Fl_Window_Driver::flush_single() { pWindow->Fl_Window::flush(); }
|
||||
void Fl_Window_Driver::draw() { pWindow->draw(); }
|
||||
void Fl_Window_Driver::make_current() { }
|
||||
void Fl_Window_Driver::label(const char *name, const char *mininame) {}
|
||||
|
||||
|
||||
void Fl_Window_Driver::take_focus()
|
||||
|
@ -3135,11 +3135,9 @@ const char *fl_filename_name( const char *name )
|
||||
/*
|
||||
* set the window title bar name
|
||||
*/
|
||||
void Fl_Window::label(const char *name, const char *mininame) {
|
||||
Fl_Widget::label(name);
|
||||
iconlabel_ = mininame;
|
||||
if (shown() || i) {
|
||||
q_set_window_title(i->xid, name, mininame);
|
||||
void Fl_Cocoa_Window_Driver::label(const char *name, const char *mininame) {
|
||||
if (pWindow->shown() || Fl_X::i(pWindow)) {
|
||||
q_set_window_title(fl_xid(pWindow), name, mininame);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1990,23 +1990,6 @@ const char *fl_filename_name(const char *name) {
|
||||
return q;
|
||||
}
|
||||
|
||||
void Fl_Window::label(const char *name,const char *iname) {
|
||||
Fl_Widget::label(name);
|
||||
iconlabel_ = iname;
|
||||
if (shown() && !parent()) {
|
||||
if (!name) name = "";
|
||||
size_t l = strlen(name);
|
||||
// WCHAR *lab = (WCHAR*) malloc((l + 1) * sizeof(short));
|
||||
// l = fl_utf2unicode((unsigned char*)name, l, (xchar*)lab);
|
||||
unsigned wlen = fl_utf8toUtf16(name, (unsigned) l, NULL, 0); // Pass NULL to query length
|
||||
wlen++;
|
||||
unsigned short * lab = (unsigned short*)malloc(sizeof(unsigned short)*wlen);
|
||||
wlen = fl_utf8toUtf16(name, (unsigned) l, lab, wlen);
|
||||
lab[wlen] = 0;
|
||||
SetWindowTextW(i->xid, (WCHAR *)lab);
|
||||
free(lab);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
|
15
src/Fl_x.cxx
15
src/Fl_x.cxx
@ -2872,18 +2872,17 @@ const char *fl_filename_name(const char *name) {
|
||||
return q;
|
||||
}
|
||||
|
||||
void Fl_Window::label(const char *name,const char *iname) {
|
||||
Fl_Widget::label(name);
|
||||
iconlabel_ = iname;
|
||||
if (shown() && !parent()) {
|
||||
void Fl_X11_Window_Driver::label(const char *name, const char *iname) {
|
||||
if (pWindow->shown() && !pWindow->parent()) {
|
||||
if (!name) name = "";
|
||||
int namelen = strlen(name);
|
||||
if (!iname) iname = fl_filename_name(name);
|
||||
int inamelen = strlen(iname);
|
||||
XChangeProperty(fl_display, i->xid, fl_NET_WM_NAME, fl_XaUtf8String, 8, 0, (uchar*)name, namelen); // utf8
|
||||
XChangeProperty(fl_display, i->xid, XA_WM_NAME, XA_STRING, 8, 0, (uchar*)name, namelen); // non-utf8
|
||||
XChangeProperty(fl_display, i->xid, fl_NET_WM_ICON_NAME, fl_XaUtf8String, 8, 0, (uchar*)iname, inamelen); // utf8
|
||||
XChangeProperty(fl_display, i->xid, XA_WM_ICON_NAME, XA_STRING, 8, 0, (uchar*)iname, inamelen); // non-utf8
|
||||
Window win = fl_xid(pWindow);
|
||||
XChangeProperty(fl_display, win, fl_NET_WM_NAME, fl_XaUtf8String, 8, 0, (uchar*)name, namelen); // utf8
|
||||
XChangeProperty(fl_display, win, XA_WM_NAME, XA_STRING, 8, 0, (uchar*)name, namelen); // non-utf8
|
||||
XChangeProperty(fl_display, win, fl_NET_WM_ICON_NAME, fl_XaUtf8String, 8, 0, (uchar*)iname, inamelen); // utf8
|
||||
XChangeProperty(fl_display, win, XA_WM_ICON_NAME, XA_STRING, 8, 0, (uchar*)iname, inamelen); // non-utf8
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
virtual void draw_begin();
|
||||
virtual void draw_end();
|
||||
virtual void make_current();
|
||||
virtual void label(const char *name, const char *mininame);
|
||||
|
||||
virtual void shape(const Fl_Image* img);
|
||||
// that one is implemented in Fl_Cocoa.mm because it uses Objective-c
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
virtual void flush_overlay();
|
||||
virtual void draw_begin();
|
||||
virtual void make_current();
|
||||
virtual void label(const char *name,const char *iname);
|
||||
|
||||
virtual void shape(const Fl_Image* img);
|
||||
virtual void icons(const Fl_RGB_Image *icons[], int count);
|
||||
|
@ -394,6 +394,22 @@ void Fl_WinAPI_Window_Driver::make_current() {
|
||||
fl_graphics_driver->clip_region(0);
|
||||
}
|
||||
|
||||
void Fl_WinAPI_Window_Driver::label(const char *name,const char *iname) {
|
||||
if (pWindow->shown() && !pWindow->parent()) {
|
||||
if (!name) name = "";
|
||||
size_t l = strlen(name);
|
||||
// WCHAR *lab = (WCHAR*) malloc((l + 1) * sizeof(short));
|
||||
// l = fl_utf2unicode((unsigned char*)name, l, (xchar*)lab);
|
||||
unsigned wlen = fl_utf8toUtf16(name, (unsigned) l, NULL, 0); // Pass NULL to query length
|
||||
wlen++;
|
||||
unsigned short * lab = (unsigned short*)malloc(sizeof(unsigned short)*wlen);
|
||||
wlen = fl_utf8toUtf16(name, (unsigned) l, lab, wlen);
|
||||
lab[wlen] = 0;
|
||||
SetWindowTextW(fl_xid(pWindow), (WCHAR *)lab);
|
||||
free(lab);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
virtual void flush_overlay();
|
||||
virtual void draw_begin();
|
||||
virtual void make_current();
|
||||
virtual void label(const char *name, const char *mininame);
|
||||
|
||||
virtual void shape(const Fl_Image* img);
|
||||
virtual void icons(const Fl_RGB_Image *icons[], int count);
|
||||
|
Loading…
Reference in New Issue
Block a user