diff --git a/build/linux/platform_specific_code/juce_linux_Windowing.cpp b/build/linux/platform_specific_code/juce_linux_Windowing.cpp index 7c779b9504..0788f04705 100644 --- a/build/linux/platform_specific_code/juce_linux_Windowing.cpp +++ b/build/linux/platform_specific_code/juce_linux_Windowing.cpp @@ -1087,6 +1087,18 @@ public: repainter->performAnyPendingRepaintsNow(); } + void setIcon (const Image& newIcon) + { + /*XWMHints* wmHints = XAllocWMHints(); + wmHints->flags = IconPixmapHint | IconMaskHint; + wmHints->icon_pixmap = + wmHints->icon_mask = + + XSetWMHints (display, windowH, wmHints); + XFree (wmHints); + */ + } + //============================================================================== void handleWindowMessage (XEvent* event) { @@ -2557,8 +2569,8 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot } const int stride = (cursorW + 7) >> 3; - unsigned char* const maskPlane = (unsigned char*) juce_calloc (stride * cursorH); - unsigned char* const sourcePlane = (unsigned char*) juce_calloc (stride * cursorH); + uint8* const maskPlane = (uint8*) juce_calloc (stride * cursorH); + uint8* const sourcePlane = (uint8*) juce_calloc (stride * cursorH); bool msbfirst = (BitmapBitOrder (display) == MSBFirst); @@ -2566,7 +2578,7 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot { for (int x = cursorW; --x >= 0;) { - const unsigned char mask = (unsigned char) (1 << (msbfirst ? (7 - (x & 7)) : (x & 7))); + const uint8 mask = (uint8) (1 << (msbfirst ? (7 - (x & 7)) : (x & 7))); const int offset = y * stride + (x >> 3); const Colour c (im.getPixelAt (x, y)); @@ -2903,7 +2915,7 @@ void SystemClipboard::copyTextToClipboard (const String& clipText) XRotateWindowProperties (display, root, cutBuffers, 8, 1); XChangeProperty (display, root, cutBuffers[0], - XA_STRING, 8, PropModeReplace, (const unsigned char*)((const char*)clipText), + XA_STRING, 8, PropModeReplace, (const unsigned char*) (const char*) clipText, clipText.length()); } diff --git a/build/macosx/platform_specific_code/juce_mac_Windowing.cpp b/build/macosx/platform_specific_code/juce_mac_Windowing.cpp index 16dfe896dc..85dfe26e7a 100644 --- a/build/macosx/platform_specific_code/juce_mac_Windowing.cpp +++ b/build/macosx/platform_specific_code/juce_mac_Windowing.cpp @@ -684,6 +684,11 @@ public: } } + void setIcon (const Image& /*newIcon*/) + { + // to do.. + } + //============================================================================== void viewFocusGain() { diff --git a/build/win32/platform_specific_code/juce_win32_Windowing.cpp b/build/win32/platform_specific_code/juce_win32_Windowing.cpp index 8db3ab78c5..a000da51a9 100644 --- a/build/win32/platform_specific_code/juce_win32_Windowing.cpp +++ b/build/win32/platform_specific_code/juce_win32_Windowing.cpp @@ -517,7 +517,8 @@ public: fullScreen (false), isDragging (false), isMouseOver (false), - taskBarIcon (0) + taskBarIcon (0), + currentWindowIcon (0) { juce_initialiseUnicodeWindowFunctions(); @@ -551,6 +552,9 @@ public: MessageManager::getInstance() ->callFunctionOnMessageThread (&destroyWindowCallback, (void*) hwnd); + + if (currentWindowIcon != 0) + DestroyIcon (currentWindowIcon); } //============================================================================== @@ -928,6 +932,7 @@ private: DropShadower* shadower; bool fullScreen, isDragging, isMouseOver; BorderSize windowBorder; + HICON currentWindowIcon; NOTIFYICONDATA* taskBarIcon; friend class WindowClassHolder; @@ -1179,6 +1184,23 @@ private: inline bool hasTitleBar() const throw() { return (styleFlags & windowHasTitleBar) != 0; } + + void setIcon (const Image& newIcon) + { + HICON hicon = createHICONFromImage (newIcon, TRUE, 0, 0); + + if (hicon != 0) + { + SendMessage (hwnd, WM_SETICON, ICON_BIG, (LPARAM) hicon); + SendMessage (hwnd, WM_SETICON, ICON_SMALL, (LPARAM) hicon); + + if (currentWindowIcon != 0) + DestroyIcon (currentWindowIcon); + + currentWindowIcon = hicon; + } + } + //============================================================================== void handlePaintMessage() { diff --git a/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp b/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp index 3099c0d116..0e4aa8e32e 100644 --- a/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp +++ b/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp @@ -68,6 +68,7 @@ public: bool setAlwaysOnTop (bool) { return true; } void toFront (bool) {} void toBehind (ComponentPeer*) {} + void setIcon (const Image&) {} bool isFocused() const { diff --git a/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h b/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h index 4fbc428731..5651c1e356 100644 --- a/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h +++ b/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h @@ -174,6 +174,10 @@ public: /** True if the window is currently full-screen. */ virtual bool isFullScreen() const = 0; + /** Attempts to change the icon associated with this window. + */ + virtual void setIcon (const Image& newIcon) = 0; + /** Sets a constrainer to use if the peer can resize itself. The constrainer won't be deleted by this object, so the caller must manage its lifetime.