Browse Source

AlertWindow text colour fix. URL::getPort() method. Image::createCopy() method.

tags/2021-05-28
jules 14 years ago
parent
commit
dcfa73204b
5 changed files with 47 additions and 20 deletions
  1. +26
    -16
      modules/juce_core/network/juce_URL.cpp
  2. +5
    -0
      modules/juce_core/network/juce_URL.h
  3. +6
    -4
      modules/juce_graphics/images/juce_Image.cpp
  4. +7
    -0
      modules/juce_graphics/images/juce_Image.h
  5. +3
    -0
      modules/juce_gui_basics/windows/juce_AlertWindow.cpp

+ 26
- 16
modules/juce_core/network/juce_URL.cpp View File

@@ -121,7 +121,7 @@ namespace URLHelpers
return p;
}
int findStartOfDomain (const String& url)
int findEndOfScheme (const String& url)
{
int i = 0;
@@ -132,6 +132,20 @@ namespace URLHelpers
return url[i] == ':' ? i + 1 : 0;
}
int findStartOfNetLocation (const String& url)
{
int start = findEndOfScheme (url);
while (url[start] == '/')
++start;
return start;
}
int findStartOfPath (const String& url)
{
return url.indexOfChar (findStartOfNetLocation (url), '/') + 1;
}
void createHeadersAndPostData (const URL& url, String& headers, MemoryBlock& postData)
{
MemoryOutputStream data (postData, false);
@@ -214,10 +228,7 @@ bool URL::isWellFormed() const
String URL::getDomain() const
{
int start = URLHelpers::findStartOfDomain (url);
while (url[start] == '/')
++start;
const int start = URLHelpers::findStartOfNetLocation (url);
const int end1 = url.indexOfChar (start, '/');
const int end2 = url.indexOfChar (start, ':');
@@ -229,11 +240,7 @@ String URL::getDomain() const
String URL::getSubPath() const
{
int start = URLHelpers::findStartOfDomain (url);
while (url[start] == '/')
++start;
const int startOfPath = url.indexOfChar (start, '/') + 1;
const int startOfPath = URLHelpers::findStartOfPath (url);
return startOfPath <= 0 ? String::empty
: url.substring (startOfPath);
@@ -241,16 +248,19 @@ String URL::getSubPath() const
String URL::getScheme() const
{
return url.substring (0, URLHelpers::findStartOfDomain (url) - 1);
return url.substring (0, URLHelpers::findEndOfScheme (url) - 1);
}
URL URL::withNewSubPath (const String& newPath) const
int URL::getPort() const
{
int start = URLHelpers::findStartOfDomain (url);
while (url[start] == '/')
++start;
const int colonPos = url.indexOfChar (URLHelpers::findStartOfNetLocation (url), ':');
const int startOfPath = url.indexOfChar (start, '/') + 1;
return colonPos > 0 ? url.substring (colonPos + 1).getIntValue() : 0;
}
URL URL::withNewSubPath (const String& newPath) const
{
const int startOfPath = URLHelpers::findStartOfPath (url);
URL u (*this);


+ 5
- 0
modules/juce_core/network/juce_URL.h View File

@@ -96,6 +96,11 @@ public:
*/
String getScheme() const;
/** Attempts to read a port number from the URL.
@returns the port number, or 0 if none is explicitly specified.
*/
int getPort() const;
/** Returns a new version of this URL that uses a different sub-path.
E.g. if the URL is "http://www.xyz.com/foo?x=1" and you call this with


+ 6
- 4
modules/juce_graphics/images/juce_Image.cpp View File

@@ -176,10 +176,7 @@ Image Image::getClippedImage (const Rectangle<int>& area) const
return *this;
const Rectangle<int> validArea (area.getIntersection (getBounds()));
if (validArea.isEmpty())
return Image::null;
return Image (new SubsectionPixelData (image, validArea));
return Image (validArea.isEmpty() ? nullptr : new SubsectionPixelData (image, validArea));
}
@@ -254,6 +251,11 @@ void Image::duplicateIfShared()
image = image->clone();
}
Image Image::createCopy() const
{
return Image (image != nullptr ? image->clone() : nullptr);
}
Image Image::rescaled (const int newWidth, const int newHeight, const Graphics::ResamplingQuality quality) const
{
if (image == nullptr || (image->width == newWidth && image->height == newHeight))


+ 7
- 0
modules/juce_graphics/images/juce_Image.h View File

@@ -200,6 +200,13 @@ public:
Image rescaled (int newWidth, int newHeight,
Graphics::ResamplingQuality quality = Graphics::mediumResamplingQuality) const;
/** Creates a copy of this image.
Note that it's usually more efficient to use duplicateIfShared(), because it may not be necessary
to copy an image if nothing else is using it.
@see getReferenceCount
*/
Image createCopy() const;
/** Returns a version of this image with a different image format.
A new image is returned which has been converted to the specified format.


+ 3
- 0
modules/juce_gui_basics/windows/juce_AlertWindow.cpp View File

@@ -400,6 +400,8 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
const int labelHeight = 18;
int iconSpace = 0;
attributedText.setColour (findColour (textColourId));
if (alertIconType == NoIcon)
{
attributedText.setJustification (Justification::centredTop);
@@ -590,6 +592,7 @@ void AlertWindow::lookAndFeelChanged()
setUsingNativeTitleBar ((newFlags & ComponentPeer::windowHasTitleBar) != 0);
setDropShadowEnabled (isOpaque() && (newFlags & ComponentPeer::windowHasDropShadow) != 0);
updateLayout (false);
}
int AlertWindow::getDesktopWindowStyleFlags() const


Loading…
Cancel
Save