Browse Source

tags/2021-05-28
jules 18 years ago
parent
commit
a353830c81
2 changed files with 82 additions and 42 deletions
  1. +0
    -4
      build/win32/platform_specific_code/juce_win32_Threads.cpp
  2. +82
    -38
      src/juce_appframework/gui/components/windows/juce_AlertWindow.cpp

+ 0
- 4
build/win32/platform_specific_code/juce_win32_Threads.cpp View File

@@ -91,11 +91,7 @@ void CriticalSection::exit() const throw()
//==============================================================================
WaitableEvent::WaitableEvent() throw()
#ifdef JUCE_DEBUG
: internal (CreateEvent (0, FALSE, FALSE, _T("Juce WaitableEvent")))
#else
: internal (CreateEvent (0, FALSE, FALSE, 0))
#endif
{
}


+ 82
- 38
src/juce_appframework/gui/components/windows/juce_AlertWindow.cpp View File

@@ -40,6 +40,7 @@ BEGIN_JUCE_NAMESPACE
#include "../controls/juce_ProgressBar.h"
#include "../juce_Desktop.h"
#include "../../../../juce_core/text/juce_LocalisedStrings.h"
#include "../../../events/juce_MessageManager.h"
static const int titleH = 24;
static const int iconWidth = 80;
@@ -586,20 +587,73 @@ void AlertWindow::lookAndFeelChanged()
}
//==============================================================================
struct AlertWindowInfo
{
String title, message, button1, button2, button3;
AlertWindow::AlertIconType iconType;
int numButtons;
int run() const
{
return (int) (pointer_sized_int)
MessageManager::getInstance()->callFunctionOnMessageThread (showCallback, (void*) this);
}
private:
int show() const
{
AlertWindow aw (title, message, iconType);
if (numButtons == 1)
{
aw.addButton (button1, 0,
KeyPress (KeyPress::escapeKey, 0, 0),
KeyPress (KeyPress::returnKey, 0, 0));
}
else
{
const KeyPress button1ShortCut (CharacterFunctions::toLowerCase (button1[0]), 0, 0);
KeyPress button2ShortCut (CharacterFunctions::toLowerCase (button2[0]), 0, 0);
if (button1ShortCut == button2ShortCut)
button2ShortCut = KeyPress();
if (numButtons == 2)
{
aw.addButton (button1, 1, KeyPress (KeyPress::returnKey, 0, 0), button1ShortCut);
aw.addButton (button2, 0, KeyPress (KeyPress::escapeKey, 0, 0), button2ShortCut);
}
else
{
jassert (numButtons == 3);
aw.addButton (button1, 1, button1ShortCut);
aw.addButton (button2, 2, button2ShortCut);
aw.addButton (button3, 0, KeyPress (KeyPress::escapeKey, 0, 0));
}
}
return aw.runModalLoop();
}
static void* showCallback (void* userData)
{
return (void*) (pointer_sized_int) ((const AlertWindowInfo*) userData)->show();
}
};
void AlertWindow::showMessageBox (AlertIconType iconType,
const String& title,
const String& message,
const String& buttonText)
{
AlertWindow aw (title, message, iconType);
aw.addButton (buttonText.isEmpty() ? TRANS("ok")
: buttonText,
0,
KeyPress (KeyPress::escapeKey, 0, 0),
KeyPress (KeyPress::returnKey, 0, 0));
aw.runModalLoop();
AlertWindowInfo info;
info.title = title;
info.message = message;
info.button1 = buttonText.isEmpty() ? TRANS("ok") : buttonText;
info.iconType = iconType;
info.numButtons = 1;
info.run();
}
bool AlertWindow::showOkCancelBox (AlertIconType iconType,
@@ -608,19 +662,15 @@ bool AlertWindow::showOkCancelBox (AlertIconType iconType,
const String& button1Text,
const String& button2Text)
{
const String bt1 (button1Text.isEmpty() ? TRANS("ok") : button1Text);
const String bt2 (button2Text.isEmpty() ? TRANS("cancel") : button2Text);
const KeyPress okShortCut (CharacterFunctions::toLowerCase (bt1[0]), 0, 0);
KeyPress cancelShortCut (CharacterFunctions::toLowerCase (bt2[0]), 0, 0);
if (okShortCut == cancelShortCut)
cancelShortCut = KeyPress();
AlertWindow aw (title, message, iconType);
aw.addButton (bt1, 1, KeyPress (KeyPress::returnKey, 0, 0), okShortCut);
aw.addButton (bt2, 0, KeyPress (KeyPress::escapeKey, 0, 0), cancelShortCut);
return aw.runModalLoop() != 0;
AlertWindowInfo info;
info.title = title;
info.message = message;
info.button1 = button1Text.isEmpty() ? TRANS("ok") : button1Text;
info.button2 = button2Text.isEmpty() ? TRANS("cancel") : button2Text;
info.iconType = iconType;
info.numButtons = 2;
return info.run() != 0;
}
int AlertWindow::showYesNoCancelBox (AlertIconType iconType,
@@ -630,22 +680,16 @@ int AlertWindow::showYesNoCancelBox (AlertIconType iconType,
const String& button2Text,
const String& button3Text)
{
const String bt1 (button1Text.isEmpty() ? TRANS("yes") : button1Text);
const String bt2 (button2Text.isEmpty() ? TRANS("no") : button2Text);
const String bt3 (button3Text.isEmpty() ? TRANS("cancel") : button3Text);
const KeyPress yesShortCut (CharacterFunctions::toLowerCase (bt1[0]), 0, 0);
KeyPress noShortCut (CharacterFunctions::toLowerCase (bt2[0]), 0, 0);
if (yesShortCut == noShortCut)
noShortCut = KeyPress();
AlertWindow aw (title, message, iconType);
aw.addButton (bt1, 1, yesShortCut);
aw.addButton (bt2, 2, noShortCut);
aw.addButton (bt3, 0, KeyPress (KeyPress::escapeKey, 0, 0));
return aw.runModalLoop();
AlertWindowInfo info;
info.title = title;
info.message = message;
info.button1 = button1Text.isEmpty() ? TRANS("yes") : button1Text;
info.button2 = button2Text.isEmpty() ? TRANS("no") : button2Text;
info.button3 = button3Text.isEmpty() ? TRANS("cancel") : button3Text;
info.iconType = iconType;
info.numButtons = 3;
return info.run();
}
END_JUCE_NAMESPACE

Loading…
Cancel
Save