mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-30 02:50:05 +00:00
Tweaked AlertWindow to allow custom components to be labelled with their name, and to be lined up along their left-hand edge with the other items. Added some mac keyboard handling to stop keys getting stuck.
This commit is contained in:
parent
0282a89908
commit
f3b46c9a2f
9 changed files with 235 additions and 90 deletions
|
|
@ -64262,7 +64262,7 @@ void LookAndFeel::drawButtonText (Graphics& g, TextButton& button,
|
|||
|
||||
void LookAndFeel::drawTickBox (Graphics& g,
|
||||
Component& component,
|
||||
int x, int y, int w, int h,
|
||||
float x, float y, float w, float h,
|
||||
const bool ticked,
|
||||
const bool isEnabled,
|
||||
const bool isMouseOverButton,
|
||||
|
|
@ -64270,7 +64270,7 @@ void LookAndFeel::drawTickBox (Graphics& g,
|
|||
{
|
||||
const float boxSize = w * 0.7f;
|
||||
|
||||
drawGlassSphere (g, (float) x, y + (h - boxSize) * 0.5f, boxSize,
|
||||
drawGlassSphere (g, x, y + (h - boxSize) * 0.5f, boxSize,
|
||||
createBaseColour (component.findColour (TextButton::buttonColourId)
|
||||
.withMultipliedAlpha (isEnabled ? 1.0f : 0.5f),
|
||||
true,
|
||||
|
|
@ -64288,7 +64288,7 @@ void LookAndFeel::drawTickBox (Graphics& g,
|
|||
g.setColour (isEnabled ? Colours::black : Colours::grey);
|
||||
|
||||
const AffineTransform trans (AffineTransform::scale (w / 9.0f, h / 9.0f)
|
||||
.translated ((float) x, (float) y));
|
||||
.translated (x, y));
|
||||
|
||||
g.strokePath (tick, PathStrokeType (2.5f), trans);
|
||||
}
|
||||
|
|
@ -64305,9 +64305,10 @@ void LookAndFeel::drawToggleButton (Graphics& g,
|
|||
g.drawRect (0, 0, button.getWidth(), button.getHeight());
|
||||
}
|
||||
|
||||
const int tickWidth = jmin (20, button.getHeight() - 4);
|
||||
float fontSize = jmin (15.0f, button.getHeight() * 0.75f);
|
||||
const float tickWidth = fontSize * 1.1f;
|
||||
|
||||
drawTickBox (g, button, 4, (button.getHeight() - tickWidth) / 2,
|
||||
drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f,
|
||||
tickWidth, tickWidth,
|
||||
button.getToggleState(),
|
||||
button.isEnabled(),
|
||||
|
|
@ -64315,7 +64316,7 @@ void LookAndFeel::drawToggleButton (Graphics& g,
|
|||
isButtonDown);
|
||||
|
||||
g.setColour (button.findColour (ToggleButton::textColourId));
|
||||
g.setFont (jmin (15.0f, button.getHeight() * 0.6f));
|
||||
g.setFont (fontSize);
|
||||
|
||||
if (! button.isEnabled())
|
||||
g.setOpacity (0.5f);
|
||||
|
|
@ -64323,8 +64324,8 @@ void LookAndFeel::drawToggleButton (Graphics& g,
|
|||
const int textX = tickWidth + 5;
|
||||
|
||||
g.drawFittedText (button.getButtonText(),
|
||||
textX, 4,
|
||||
button.getWidth() - textX - 2, button.getHeight() - 8,
|
||||
textX, 0,
|
||||
button.getWidth() - textX - 2, button.getHeight(),
|
||||
Justification::centredLeft, 10);
|
||||
}
|
||||
|
||||
|
|
@ -75760,28 +75761,32 @@ void AlertWindow::paint (Graphics& g)
|
|||
int i;
|
||||
for (i = textBoxes.size(); --i >= 0;)
|
||||
{
|
||||
if (textboxNames[i].isNotEmpty())
|
||||
{
|
||||
const TextEditor* const te = (TextEditor*) textBoxes[i];
|
||||
const TextEditor* const te = (TextEditor*) textBoxes[i];
|
||||
|
||||
g.drawFittedText (textboxNames[i],
|
||||
te->getX(), te->getY() - 14,
|
||||
te->getWidth(), 14,
|
||||
Justification::centredLeft, 1);
|
||||
}
|
||||
g.drawFittedText (textboxNames[i],
|
||||
te->getX(), te->getY() - 14,
|
||||
te->getWidth(), 14,
|
||||
Justification::centredLeft, 1);
|
||||
}
|
||||
|
||||
for (i = comboBoxNames.size(); --i >= 0;)
|
||||
{
|
||||
if (comboBoxNames[i].isNotEmpty())
|
||||
{
|
||||
const ComboBox* const cb = (ComboBox*) comboBoxes[i];
|
||||
const ComboBox* const cb = (ComboBox*) comboBoxes[i];
|
||||
|
||||
g.drawFittedText (comboBoxNames[i],
|
||||
cb->getX(), cb->getY() - 14,
|
||||
cb->getWidth(), 14,
|
||||
Justification::centredLeft, 1);
|
||||
}
|
||||
g.drawFittedText (comboBoxNames[i],
|
||||
cb->getX(), cb->getY() - 14,
|
||||
cb->getWidth(), 14,
|
||||
Justification::centredLeft, 1);
|
||||
}
|
||||
|
||||
for (i = customComps.size(); --i >= 0;)
|
||||
{
|
||||
const Component* const c = (Component*) customComps[i];
|
||||
|
||||
g.drawFittedText (c->getName(),
|
||||
c->getX(), c->getY() - 14,
|
||||
c->getWidth(), 14,
|
||||
Justification::centredLeft, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75793,6 +75798,7 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
|
|||
const int sw = (int) sqrt (font.getHeight() * wid);
|
||||
int w = jmin (300 + sw * 2, (int) (getParentWidth() * 0.7f));
|
||||
const int edgeGap = 10;
|
||||
const int labelHeight = 18;
|
||||
int iconSpace;
|
||||
|
||||
if (alertIconType == NoIcon)
|
||||
|
|
@ -75827,8 +75833,12 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
|
|||
|
||||
for (i = customComps.size(); --i >= 0;)
|
||||
{
|
||||
w = jmax (w, ((Component*) customComps[i])->getWidth() + 40);
|
||||
h += 10 + ((Component*) customComps[i])->getHeight();
|
||||
Component* c = (Component*) customComps[i];
|
||||
w = jmax (w, (c->getWidth() * 100) / 80);
|
||||
h += 10 + c->getHeight();
|
||||
|
||||
if (c->getName().isNotEmpty())
|
||||
h += labelHeight;
|
||||
}
|
||||
|
||||
for (i = textBlocks.size(); --i >= 0;)
|
||||
|
|
@ -75897,27 +75907,35 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
|
|||
for (i = 0; i < allComps.size(); ++i)
|
||||
{
|
||||
Component* const c = (Component*) allComps[i];
|
||||
|
||||
const int h = 22;
|
||||
int h = 22;
|
||||
|
||||
const int comboIndex = comboBoxes.indexOf (c);
|
||||
if (comboIndex >= 0 && comboBoxNames [comboIndex].isNotEmpty())
|
||||
y += 18;
|
||||
y += labelHeight;
|
||||
|
||||
const int tbIndex = textBoxes.indexOf (c);
|
||||
if (tbIndex >= 0 && textboxNames[tbIndex].isNotEmpty())
|
||||
y += 18;
|
||||
y += labelHeight;
|
||||
|
||||
if (customComps.contains (c) || textBlocks.contains (c))
|
||||
if (customComps.contains (c))
|
||||
{
|
||||
if (c->getName().isNotEmpty())
|
||||
y += labelHeight;
|
||||
|
||||
c->setTopLeftPosition (proportionOfWidth (0.1f), y);
|
||||
h = c->getHeight();
|
||||
}
|
||||
else if (textBlocks.contains (c))
|
||||
{
|
||||
c->setTopLeftPosition ((getWidth() - c->getWidth()) / 2, y);
|
||||
y += c->getHeight() + 10;
|
||||
h = c->getHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
c->setBounds (proportionOfWidth (0.1f), y, proportionOfWidth (0.8f), h);
|
||||
y += h + 10;
|
||||
}
|
||||
|
||||
y += h + 10;
|
||||
}
|
||||
|
||||
setWantsKeyboardFocus (getNumChildComponents() == 0);
|
||||
|
|
@ -213632,6 +213650,48 @@ struct ConnectionAndRequestStruct
|
|||
|
||||
static HINTERNET sessionHandle = 0;
|
||||
|
||||
#ifndef WORKAROUND_TIMEOUT_BUG
|
||||
//#define WORKAROUND_TIMEOUT_BUG 1
|
||||
#endif
|
||||
|
||||
#if WORKAROUND_TIMEOUT_BUG
|
||||
// Required because of a Microsoft bug in setting a timeout
|
||||
class InternetConnectThread : public Thread
|
||||
{
|
||||
public:
|
||||
InternetConnectThread (URL_COMPONENTS& uc_, HINTERNET& connection_, const bool isFtp_)
|
||||
: Thread ("Internet"), uc (uc_), connection (connection_), isFtp (isFtp_)
|
||||
{
|
||||
startThread();
|
||||
}
|
||||
|
||||
~InternetConnectThread()
|
||||
{
|
||||
stopThread (60000);
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
connection = InternetConnect (sessionHandle, uc.lpszHostName,
|
||||
uc.nPort, _T(""), _T(""),
|
||||
isFtp ? INTERNET_SERVICE_FTP
|
||||
: INTERNET_SERVICE_HTTP,
|
||||
0, 0);
|
||||
notify();
|
||||
}
|
||||
|
||||
juce_UseDebuggingNewOperator
|
||||
|
||||
private:
|
||||
URL_COMPONENTS& uc;
|
||||
HINTERNET& connection;
|
||||
const bool isFtp;
|
||||
|
||||
InternetConnectThread (const InternetConnectThread&);
|
||||
InternetConnectThread& operator= (const InternetConnectThread&);
|
||||
};
|
||||
#endif
|
||||
|
||||
void* juce_openInternetFile (const String& url,
|
||||
const String& headers,
|
||||
const MemoryBlock& postData,
|
||||
|
|
@ -213661,6 +213721,9 @@ void* juce_openInternetFile (const String& url,
|
|||
|
||||
if (InternetCrackUrl (url, 0, 0, &uc))
|
||||
{
|
||||
int disable = 1;
|
||||
InternetSetOption (sessionHandle, INTERNET_OPTION_DISABLE_AUTODIAL, &disable, sizeof (disable));
|
||||
|
||||
if (timeOutMs == 0)
|
||||
timeOutMs = 30000;
|
||||
else if (timeOutMs < 0)
|
||||
|
|
@ -213670,6 +213733,20 @@ void* juce_openInternetFile (const String& url,
|
|||
|
||||
const bool isFtp = url.startsWithIgnoreCase (T("ftp:"));
|
||||
|
||||
#if WORKAROUND_TIMEOUT_BUG
|
||||
HINTERNET connection = 0;
|
||||
|
||||
{
|
||||
InternetConnectThread connectThread (uc, connection, isFtp);
|
||||
connectThread.wait (timeOutMs);
|
||||
|
||||
if (connection == 0)
|
||||
{
|
||||
InternetCloseHandle (sessionHandle);
|
||||
sessionHandle = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
HINTERNET connection = InternetConnect (sessionHandle,
|
||||
uc.lpszHostName,
|
||||
uc.nPort,
|
||||
|
|
@ -213677,6 +213754,7 @@ void* juce_openInternetFile (const String& url,
|
|||
isFtp ? INTERNET_SERVICE_FTP
|
||||
: INTERNET_SERVICE_HTTP,
|
||||
0, 0);
|
||||
#endif
|
||||
|
||||
if (connection != 0)
|
||||
{
|
||||
|
|
@ -246393,6 +246471,9 @@ bool NSViewComponentPeer::redirectKeyUp (NSEvent* ev)
|
|||
|
||||
void NSViewComponentPeer::redirectModKeyChange (NSEvent* ev)
|
||||
{
|
||||
keysCurrentlyDown.clear();
|
||||
handleKeyUpOrDown (true);
|
||||
|
||||
updateModifiers (ev);
|
||||
handleModifierKeysChange();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18413,6 +18413,8 @@ public:
|
|||
|
||||
int getPreferredHeight() const throw() { return preferredHeight; }
|
||||
|
||||
void setPreferredHeight (int newHeight) throw() { preferredHeight = newHeight; }
|
||||
|
||||
virtual void refresh() = 0;
|
||||
|
||||
void paint (Graphics& g);
|
||||
|
|
@ -24096,7 +24098,7 @@ public:
|
|||
|
||||
virtual void drawTickBox (Graphics& g,
|
||||
Component& component,
|
||||
int x, int y, int w, int h,
|
||||
float x, float y, float w, float h,
|
||||
const bool ticked,
|
||||
const bool isEnabled,
|
||||
const bool isMouseOverButton,
|
||||
|
|
@ -24477,16 +24479,6 @@ public:
|
|||
|
||||
juce_UseDebuggingNewOperator
|
||||
|
||||
protected:
|
||||
// xxx the following methods are only here to cause a compiler error, because they've been
|
||||
// deprecated or their parameters have changed. Hopefully these definitions should cause an
|
||||
// error if you try to build a subclass with the old versions.
|
||||
virtual int drawTickBox (Graphics&, int, int, int, int, bool, const bool, const bool, const bool) { return 0; }
|
||||
virtual int drawProgressBar (Graphics&, int, int, int, int, float) { return 0; }
|
||||
virtual int drawProgressBar (Graphics&, ProgressBar&, int, int, int, int, float) { return 0; }
|
||||
virtual void getTabButtonBestWidth (int, const String&, int) {}
|
||||
virtual int drawTreeviewPlusMinusBox (Graphics&, int, int, int, int, bool) { return 0; }
|
||||
|
||||
private:
|
||||
friend void JUCE_PUBLIC_FUNCTION shutdownJuce_GUI();
|
||||
static void clearDefaultLookAndFeel() throw(); // called at shutdown
|
||||
|
|
|
|||
|
|
@ -34,12 +34,12 @@ class Component;
|
|||
/**
|
||||
Represents a type of audio driver, such as DirectSound, ASIO, CoreAudio, etc.
|
||||
|
||||
To get a list of available audio driver types, use the createDeviceTypes()
|
||||
To get a list of available audio driver types, use the AudioDeviceManager::createAudioDeviceTypes()
|
||||
method. Each of the objects returned can then be used to list the available
|
||||
devices of that type. E.g.
|
||||
@code
|
||||
OwnedArray <AudioIODeviceType> types;
|
||||
AudioIODeviceType::createDeviceTypes (types);
|
||||
myAudioDeviceManager.createAudioDeviceTypes (types);
|
||||
|
||||
for (int i = 0; i < types.size(); ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ void LookAndFeel::drawButtonText (Graphics& g, TextButton& button,
|
|||
|
||||
void LookAndFeel::drawTickBox (Graphics& g,
|
||||
Component& component,
|
||||
int x, int y, int w, int h,
|
||||
float x, float y, float w, float h,
|
||||
const bool ticked,
|
||||
const bool isEnabled,
|
||||
const bool isMouseOverButton,
|
||||
|
|
@ -419,7 +419,7 @@ void LookAndFeel::drawTickBox (Graphics& g,
|
|||
{
|
||||
const float boxSize = w * 0.7f;
|
||||
|
||||
drawGlassSphere (g, (float) x, y + (h - boxSize) * 0.5f, boxSize,
|
||||
drawGlassSphere (g, x, y + (h - boxSize) * 0.5f, boxSize,
|
||||
createBaseColour (component.findColour (TextButton::buttonColourId)
|
||||
.withMultipliedAlpha (isEnabled ? 1.0f : 0.5f),
|
||||
true,
|
||||
|
|
@ -437,7 +437,7 @@ void LookAndFeel::drawTickBox (Graphics& g,
|
|||
g.setColour (isEnabled ? Colours::black : Colours::grey);
|
||||
|
||||
const AffineTransform trans (AffineTransform::scale (w / 9.0f, h / 9.0f)
|
||||
.translated ((float) x, (float) y));
|
||||
.translated (x, y));
|
||||
|
||||
g.strokePath (tick, PathStrokeType (2.5f), trans);
|
||||
}
|
||||
|
|
@ -454,9 +454,10 @@ void LookAndFeel::drawToggleButton (Graphics& g,
|
|||
g.drawRect (0, 0, button.getWidth(), button.getHeight());
|
||||
}
|
||||
|
||||
const int tickWidth = jmin (20, button.getHeight() - 4);
|
||||
float fontSize = jmin (15.0f, button.getHeight() * 0.75f);
|
||||
const float tickWidth = fontSize * 1.1f;
|
||||
|
||||
drawTickBox (g, button, 4, (button.getHeight() - tickWidth) / 2,
|
||||
drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f,
|
||||
tickWidth, tickWidth,
|
||||
button.getToggleState(),
|
||||
button.isEnabled(),
|
||||
|
|
@ -464,7 +465,7 @@ void LookAndFeel::drawToggleButton (Graphics& g,
|
|||
isButtonDown);
|
||||
|
||||
g.setColour (button.findColour (ToggleButton::textColourId));
|
||||
g.setFont (jmin (15.0f, button.getHeight() * 0.6f));
|
||||
g.setFont (fontSize);
|
||||
|
||||
if (! button.isEnabled())
|
||||
g.setOpacity (0.5f);
|
||||
|
|
@ -472,8 +473,8 @@ void LookAndFeel::drawToggleButton (Graphics& g,
|
|||
const int textX = tickWidth + 5;
|
||||
|
||||
g.drawFittedText (button.getButtonText(),
|
||||
textX, 4,
|
||||
button.getWidth() - textX - 2, button.getHeight() - 8,
|
||||
textX, 0,
|
||||
button.getWidth() - textX - 2, button.getHeight(),
|
||||
Justification::centredLeft, 10);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ public:
|
|||
|
||||
virtual void drawTickBox (Graphics& g,
|
||||
Component& component,
|
||||
int x, int y, int w, int h,
|
||||
float x, float y, float w, float h,
|
||||
const bool ticked,
|
||||
const bool isEnabled,
|
||||
const bool isMouseOverButton,
|
||||
|
|
@ -635,16 +635,6 @@ public:
|
|||
juce_UseDebuggingNewOperator
|
||||
|
||||
|
||||
protected:
|
||||
// xxx the following methods are only here to cause a compiler error, because they've been
|
||||
// deprecated or their parameters have changed. Hopefully these definitions should cause an
|
||||
// error if you try to build a subclass with the old versions.
|
||||
virtual int drawTickBox (Graphics&, int, int, int, int, bool, const bool, const bool, const bool) { return 0; }
|
||||
virtual int drawProgressBar (Graphics&, int, int, int, int, float) { return 0; }
|
||||
virtual int drawProgressBar (Graphics&, ProgressBar&, int, int, int, int, float) { return 0; }
|
||||
virtual void getTabButtonBestWidth (int, const String&, int) {}
|
||||
virtual int drawTreeviewPlusMinusBox (Graphics&, int, int, int, int, bool) { return 0; }
|
||||
|
||||
private:
|
||||
friend void JUCE_PUBLIC_FUNCTION shutdownJuce_GUI();
|
||||
static void clearDefaultLookAndFeel() throw(); // called at shutdown
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ public:
|
|||
*/
|
||||
int getPreferredHeight() const throw() { return preferredHeight; }
|
||||
|
||||
void setPreferredHeight (int newHeight) throw() { preferredHeight = newHeight; }
|
||||
|
||||
//==============================================================================
|
||||
/** Updates the property component if the item it refers to has changed.
|
||||
|
|
|
|||
|
|
@ -369,28 +369,32 @@ void AlertWindow::paint (Graphics& g)
|
|||
int i;
|
||||
for (i = textBoxes.size(); --i >= 0;)
|
||||
{
|
||||
if (textboxNames[i].isNotEmpty())
|
||||
{
|
||||
const TextEditor* const te = (TextEditor*) textBoxes[i];
|
||||
const TextEditor* const te = (TextEditor*) textBoxes[i];
|
||||
|
||||
g.drawFittedText (textboxNames[i],
|
||||
te->getX(), te->getY() - 14,
|
||||
te->getWidth(), 14,
|
||||
Justification::centredLeft, 1);
|
||||
}
|
||||
g.drawFittedText (textboxNames[i],
|
||||
te->getX(), te->getY() - 14,
|
||||
te->getWidth(), 14,
|
||||
Justification::centredLeft, 1);
|
||||
}
|
||||
|
||||
for (i = comboBoxNames.size(); --i >= 0;)
|
||||
{
|
||||
if (comboBoxNames[i].isNotEmpty())
|
||||
{
|
||||
const ComboBox* const cb = (ComboBox*) comboBoxes[i];
|
||||
const ComboBox* const cb = (ComboBox*) comboBoxes[i];
|
||||
|
||||
g.drawFittedText (comboBoxNames[i],
|
||||
cb->getX(), cb->getY() - 14,
|
||||
cb->getWidth(), 14,
|
||||
Justification::centredLeft, 1);
|
||||
}
|
||||
g.drawFittedText (comboBoxNames[i],
|
||||
cb->getX(), cb->getY() - 14,
|
||||
cb->getWidth(), 14,
|
||||
Justification::centredLeft, 1);
|
||||
}
|
||||
|
||||
for (i = customComps.size(); --i >= 0;)
|
||||
{
|
||||
const Component* const c = (Component*) customComps[i];
|
||||
|
||||
g.drawFittedText (c->getName(),
|
||||
c->getX(), c->getY() - 14,
|
||||
c->getWidth(), 14,
|
||||
Justification::centredLeft, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -402,6 +406,7 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
|
|||
const int sw = (int) sqrt (font.getHeight() * wid);
|
||||
int w = jmin (300 + sw * 2, (int) (getParentWidth() * 0.7f));
|
||||
const int edgeGap = 10;
|
||||
const int labelHeight = 18;
|
||||
int iconSpace;
|
||||
|
||||
if (alertIconType == NoIcon)
|
||||
|
|
@ -436,8 +441,12 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
|
|||
|
||||
for (i = customComps.size(); --i >= 0;)
|
||||
{
|
||||
w = jmax (w, ((Component*) customComps[i])->getWidth() + 40);
|
||||
h += 10 + ((Component*) customComps[i])->getHeight();
|
||||
Component* c = (Component*) customComps[i];
|
||||
w = jmax (w, (c->getWidth() * 100) / 80);
|
||||
h += 10 + c->getHeight();
|
||||
|
||||
if (c->getName().isNotEmpty())
|
||||
h += labelHeight;
|
||||
}
|
||||
|
||||
for (i = textBlocks.size(); --i >= 0;)
|
||||
|
|
@ -506,27 +515,35 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
|
|||
for (i = 0; i < allComps.size(); ++i)
|
||||
{
|
||||
Component* const c = (Component*) allComps[i];
|
||||
|
||||
const int h = 22;
|
||||
int h = 22;
|
||||
|
||||
const int comboIndex = comboBoxes.indexOf (c);
|
||||
if (comboIndex >= 0 && comboBoxNames [comboIndex].isNotEmpty())
|
||||
y += 18;
|
||||
y += labelHeight;
|
||||
|
||||
const int tbIndex = textBoxes.indexOf (c);
|
||||
if (tbIndex >= 0 && textboxNames[tbIndex].isNotEmpty())
|
||||
y += 18;
|
||||
y += labelHeight;
|
||||
|
||||
if (customComps.contains (c) || textBlocks.contains (c))
|
||||
if (customComps.contains (c))
|
||||
{
|
||||
if (c->getName().isNotEmpty())
|
||||
y += labelHeight;
|
||||
|
||||
c->setTopLeftPosition (proportionOfWidth (0.1f), y);
|
||||
h = c->getHeight();
|
||||
}
|
||||
else if (textBlocks.contains (c))
|
||||
{
|
||||
c->setTopLeftPosition ((getWidth() - c->getWidth()) / 2, y);
|
||||
y += c->getHeight() + 10;
|
||||
h = c->getHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
c->setBounds (proportionOfWidth (0.1f), y, proportionOfWidth (0.8f), h);
|
||||
y += h + 10;
|
||||
}
|
||||
|
||||
y += h + 10;
|
||||
}
|
||||
|
||||
setWantsKeyboardFocus (getNumChildComponents() == 0);
|
||||
|
|
|
|||
|
|
@ -1200,6 +1200,9 @@ bool NSViewComponentPeer::redirectKeyUp (NSEvent* ev)
|
|||
|
||||
void NSViewComponentPeer::redirectModKeyChange (NSEvent* ev)
|
||||
{
|
||||
keysCurrentlyDown.clear();
|
||||
handleKeyUpOrDown (true);
|
||||
|
||||
updateModifiers (ev);
|
||||
handleModifierKeysChange();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,48 @@ struct ConnectionAndRequestStruct
|
|||
|
||||
static HINTERNET sessionHandle = 0;
|
||||
|
||||
#ifndef WORKAROUND_TIMEOUT_BUG
|
||||
//#define WORKAROUND_TIMEOUT_BUG 1
|
||||
#endif
|
||||
|
||||
#if WORKAROUND_TIMEOUT_BUG
|
||||
// Required because of a Microsoft bug in setting a timeout
|
||||
class InternetConnectThread : public Thread
|
||||
{
|
||||
public:
|
||||
InternetConnectThread (URL_COMPONENTS& uc_, HINTERNET& connection_, const bool isFtp_)
|
||||
: Thread ("Internet"), uc (uc_), connection (connection_), isFtp (isFtp_)
|
||||
{
|
||||
startThread();
|
||||
}
|
||||
|
||||
~InternetConnectThread()
|
||||
{
|
||||
stopThread (60000);
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
connection = InternetConnect (sessionHandle, uc.lpszHostName,
|
||||
uc.nPort, _T(""), _T(""),
|
||||
isFtp ? INTERNET_SERVICE_FTP
|
||||
: INTERNET_SERVICE_HTTP,
|
||||
0, 0);
|
||||
notify();
|
||||
}
|
||||
|
||||
juce_UseDebuggingNewOperator
|
||||
|
||||
private:
|
||||
URL_COMPONENTS& uc;
|
||||
HINTERNET& connection;
|
||||
const bool isFtp;
|
||||
|
||||
InternetConnectThread (const InternetConnectThread&);
|
||||
InternetConnectThread& operator= (const InternetConnectThread&);
|
||||
};
|
||||
#endif
|
||||
|
||||
void* juce_openInternetFile (const String& url,
|
||||
const String& headers,
|
||||
const MemoryBlock& postData,
|
||||
|
|
@ -77,6 +119,9 @@ void* juce_openInternetFile (const String& url,
|
|||
|
||||
if (InternetCrackUrl (url, 0, 0, &uc))
|
||||
{
|
||||
int disable = 1;
|
||||
InternetSetOption (sessionHandle, INTERNET_OPTION_DISABLE_AUTODIAL, &disable, sizeof (disable));
|
||||
|
||||
if (timeOutMs == 0)
|
||||
timeOutMs = 30000;
|
||||
else if (timeOutMs < 0)
|
||||
|
|
@ -86,6 +131,20 @@ void* juce_openInternetFile (const String& url,
|
|||
|
||||
const bool isFtp = url.startsWithIgnoreCase (T("ftp:"));
|
||||
|
||||
#if WORKAROUND_TIMEOUT_BUG
|
||||
HINTERNET connection = 0;
|
||||
|
||||
{
|
||||
InternetConnectThread connectThread (uc, connection, isFtp);
|
||||
connectThread.wait (timeOutMs);
|
||||
|
||||
if (connection == 0)
|
||||
{
|
||||
InternetCloseHandle (sessionHandle);
|
||||
sessionHandle = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
HINTERNET connection = InternetConnect (sessionHandle,
|
||||
uc.lpszHostName,
|
||||
uc.nPort,
|
||||
|
|
@ -93,6 +152,7 @@ void* juce_openInternetFile (const String& url,
|
|||
isFtp ? INTERNET_SERVICE_FTP
|
||||
: INTERNET_SERVICE_HTTP,
|
||||
0, 0);
|
||||
#endif
|
||||
|
||||
if (connection != 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue