mirror of
https://github.com/fltk/fltk.git
synced 2026-05-27 02:46:34 +08:00
Allow use of Fl_Window::default_icon() with a scaled image - Part 2.
Default icons are handled according to their scaled size, if there scaled.
This commit is contained in:
+21
-5
@@ -2397,11 +2397,11 @@ static const Fl_RGB_Image *find_best_icon(int ideal_width, const Fl_RGB_Image *i
|
|||||||
if (best == NULL)
|
if (best == NULL)
|
||||||
best = icons[i];
|
best = icons[i];
|
||||||
else {
|
else {
|
||||||
if (best->data_w() < ideal_width) {
|
if (best->w() < ideal_width) {
|
||||||
if (icons[i]->data_w() > best->data_w())
|
if (icons[i]->w() > best->w())
|
||||||
best = icons[i];
|
best = icons[i];
|
||||||
} else {
|
} else {
|
||||||
if ((icons[i]->data_w() >= ideal_width) && (icons[i]->data_w() < best->data_w()))
|
if ((icons[i]->w() >= ideal_width) && (icons[i]->w() < best->w()))
|
||||||
best = icons[i];
|
best = icons[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2424,11 +2424,27 @@ void Fl_WinAPI_Screen_Driver::default_icons(const Fl_RGB_Image *icons[], int cou
|
|||||||
best_big = find_best_icon(GetSystemMetrics(SM_CXICON), icons, count);
|
best_big = find_best_icon(GetSystemMetrics(SM_CXICON), icons, count);
|
||||||
best_small = find_best_icon(GetSystemMetrics(SM_CXSMICON), icons, count);
|
best_small = find_best_icon(GetSystemMetrics(SM_CXSMICON), icons, count);
|
||||||
|
|
||||||
if (best_big != NULL)
|
bool need_delete;
|
||||||
|
if (best_big != NULL) {
|
||||||
|
need_delete = false;
|
||||||
|
if (best_big->w() != best_big->data_w() || best_big->h() != best_big->data_h()) {
|
||||||
|
best_big = (Fl_RGB_Image *)best_big->copy();
|
||||||
|
need_delete = true;
|
||||||
|
}
|
||||||
default_big_icon = image_to_icon(best_big, true, 0, 0);
|
default_big_icon = image_to_icon(best_big, true, 0, 0);
|
||||||
|
if (need_delete) delete best_big;
|
||||||
|
}
|
||||||
|
|
||||||
if (best_small != NULL)
|
if (best_small != NULL) {
|
||||||
|
need_delete = false;
|
||||||
|
if (best_small->w() != best_small->data_w() ||
|
||||||
|
best_small->h() != best_small->data_h()) {
|
||||||
|
best_small = (Fl_RGB_Image *)best_small->copy();
|
||||||
|
need_delete = true;
|
||||||
|
}
|
||||||
default_small_icon = image_to_icon(best_small, true, 0, 0);
|
default_small_icon = image_to_icon(best_small, true, 0, 0);
|
||||||
|
if (need_delete) delete best_small;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets the window icons using Windows' native HICON icon handles.
|
/** Sets the window icons using Windows' native HICON icon handles.
|
||||||
|
|||||||
@@ -2707,6 +2707,11 @@ static void icons_to_property(const Fl_RGB_Image *icons[], int count,
|
|||||||
const Fl_RGB_Image *image;
|
const Fl_RGB_Image *image;
|
||||||
|
|
||||||
image = icons[i];
|
image = icons[i];
|
||||||
|
bool need_delete = false;
|
||||||
|
if (image->w() != image->data_w() || image->h() != image->data_h()) {
|
||||||
|
image = (Fl_RGB_Image*)image->copy();
|
||||||
|
need_delete = true;
|
||||||
|
}
|
||||||
|
|
||||||
data[0] = image->data_w();
|
data[0] = image->data_w();
|
||||||
data[1] = image->data_h();
|
data[1] = image->data_h();
|
||||||
@@ -2736,6 +2741,7 @@ static void icons_to_property(const Fl_RGB_Image *icons[], int count,
|
|||||||
}
|
}
|
||||||
in += extra_data;
|
in += extra_data;
|
||||||
}
|
}
|
||||||
|
if (need_delete) delete image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user