- Library code update

- project update (added Eigen)

git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@94 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-12-20 20:59:48 +00:00
parent 1b4d8e9f54
commit dc5560392f
312 changed files with 6349 additions and 4195 deletions
@@ -535,6 +535,106 @@ struct CppTokeniserFunctions
String::CharPointerType t;
int numChars;
};
//==============================================================================
/** Takes a UTF8 string and writes it to a stream using standard C++ escape sequences for any
non-ascii bytes.
Although not strictly a tokenising function, this is still a function that often comes in
handy when working with C++ code!
Note that addEscapeChars() is easier to use than this function if you're working with Strings.
@see addEscapeChars
*/
static void writeEscapeChars (OutputStream& out, const char* utf8, const int numBytesToRead,
const int maxCharsOnLine, const bool breakAtNewLines,
const bool replaceSingleQuotes, const bool allowStringBreaks)
{
int charsOnLine = 0;
bool lastWasHexEscapeCode = false;
for (int i = 0; i < numBytesToRead || numBytesToRead < 0; ++i)
{
const unsigned char c = (unsigned char) utf8[i];
bool startNewLine = false;
switch (c)
{
case '\t': out << "\\t"; lastWasHexEscapeCode = false; charsOnLine += 2; break;
case '\r': out << "\\r"; lastWasHexEscapeCode = false; charsOnLine += 2; break;
case '\n': out << "\\n"; lastWasHexEscapeCode = false; charsOnLine += 2; startNewLine = breakAtNewLines; break;
case '\\': out << "\\\\"; lastWasHexEscapeCode = false; charsOnLine += 2; break;
case '\"': out << "\\\""; lastWasHexEscapeCode = false; charsOnLine += 2; break;
case 0:
if (numBytesToRead < 0)
return;
out << "\\0";
lastWasHexEscapeCode = true;
charsOnLine += 2;
break;
case '\'':
if (replaceSingleQuotes)
{
out << "\\\'";
lastWasHexEscapeCode = false;
charsOnLine += 2;
break;
}
// deliberate fall-through...
default:
if (c >= 32 && c < 127 && ! (lastWasHexEscapeCode // (have to avoid following a hex escape sequence with a valid hex digit)
&& CharacterFunctions::getHexDigitValue (c) >= 0))
{
out << (char) c;
lastWasHexEscapeCode = false;
++charsOnLine;
}
else if (allowStringBreaks && lastWasHexEscapeCode && c >= 32 && c < 127)
{
out << "\"\"" << (char) c;
lastWasHexEscapeCode = false;
charsOnLine += 3;
}
else
{
out << (c < 16 ? "\\x0" : "\\x") << String::toHexString ((int) c);
lastWasHexEscapeCode = true;
charsOnLine += 4;
}
break;
}
if ((startNewLine || (maxCharsOnLine > 0 && charsOnLine >= maxCharsOnLine))
&& (numBytesToRead < 0 || i < numBytesToRead - 1))
{
charsOnLine = 0;
out << "\"" << newLine << "\"";
lastWasHexEscapeCode = false;
}
}
}
/** Takes a string and returns a version of it where standard C++ escape sequences have been
used to replace any non-ascii bytes.
Although not strictly a tokenising function, this is still a function that often comes in
handy when working with C++ code!
@see writeEscapeChars
*/
static String addEscapeChars (const String& s)
{
MemoryOutputStream mo;
writeEscapeChars (mo, s.toRawUTF8(), -1, -1, false, true, true);
return mo.toString();
}
};
@@ -102,9 +102,7 @@ public:
lineLength = 0;
lineLengthWithoutNewLines = 0;
String::CharPointerType t (line.getCharPointer());
for (;;)
for (String::CharPointerType t (line.getCharPointer());;)
{
const juce_wchar c = t.getAndAdvance();
@@ -242,16 +240,16 @@ CodeDocument::Position::Position() noexcept
}
CodeDocument::Position::Position (const CodeDocument& ownerDocument,
const int line_, const int indexInLine_) noexcept
: owner (const_cast <CodeDocument*> (&ownerDocument)),
characterPos (0), line (line_),
indexInLine (indexInLine_), positionMaintained (false)
const int lineNum, const int index) noexcept
: owner (const_cast<CodeDocument*> (&ownerDocument)),
characterPos (0), line (lineNum),
indexInLine (index), positionMaintained (false)
{
setLineAndIndex (line_, indexInLine_);
setLineAndIndex (lineNum, index);
}
CodeDocument::Position::Position (const CodeDocument& ownerDocument, const int characterPos_) noexcept
: owner (const_cast <CodeDocument*> (&ownerDocument)),
: owner (const_cast<CodeDocument*> (&ownerDocument)),
positionMaintained (false)
{
setPosition (characterPos_);
@@ -858,7 +856,7 @@ void CodeDocument::insert (const String& text, const int insertPos, const bool u
}
maximumLineLength = -1;
Array <CodeDocumentLine*> newLines;
Array<CodeDocumentLine*> newLines;
CodeDocumentLine::createLines (newLines, textInsideOriginalLine);
jassert (newLines.size() > 0);
@@ -35,7 +35,7 @@ public:
const CodeDocument::Position& selStart,
const CodeDocument::Position& selEnd)
{
Array <SyntaxToken> newTokens;
Array<SyntaxToken> newTokens;
newTokens.ensureStorageAllocated (8);
if (tokeniser == nullptr)
@@ -129,13 +129,13 @@ private:
int tokenType;
};
Array <SyntaxToken> tokens;
Array<SyntaxToken> tokens;
int highlightColumnStart, highlightColumnEnd;
static void createTokens (int startPosition, const String& lineText,
CodeDocument::Iterator& source,
CodeTokeniser& tokeniser,
Array <SyntaxToken>& newTokens)
Array<SyntaxToken>& newTokens)
{
CodeDocument::Iterator lastIterator (source);
const int lineLength = lineText.length();
@@ -168,7 +168,7 @@ private:
source = lastIterator;
}
static void replaceTabsWithSpaces (Array <SyntaxToken>& tokens, const int spacesPerTab)
static void replaceTabsWithSpaces (Array<SyntaxToken>& tokens, const int spacesPerTab)
{
int x = 0;
for (int i = 0; i < tokens.size(); ++i)
@@ -287,8 +287,8 @@ public:
void paint (Graphics& g) override
{
jassert (dynamic_cast <CodeEditorComponent*> (getParentComponent()) != nullptr);
const CodeEditorComponent& editor = *static_cast <CodeEditorComponent*> (getParentComponent());
jassert (dynamic_cast<CodeEditorComponent*> (getParentComponent()) != nullptr);
const CodeEditorComponent& editor = *static_cast<CodeEditorComponent*> (getParentComponent());
g.fillAll (editor.findColour (CodeEditorComponent::backgroundColourId)
.overlaidWith (editor.findColour (lineNumberBackgroundId)));
@@ -412,7 +412,7 @@ bool CodeEditorComponent::isTextInputActive() const
return true;
}
void CodeEditorComponent::setTemporaryUnderlining (const Array <Range<int> >&)
void CodeEditorComponent::setTemporaryUnderlining (const Array<Range<int> >&)
{
jassertfalse; // TODO Windows IME not yet supported for this comp..
}
@@ -1235,7 +1235,7 @@ ApplicationCommandTarget* CodeEditorComponent::getNextCommandTarget()
return findFirstTargetParentComponent();
}
void CodeEditorComponent::getAllCommands (Array <CommandID>& commands)
void CodeEditorComponent::getAllCommands (Array<CommandID>& commands)
{
const CommandID ids[] = { StandardApplicationCommandIDs::cut,
StandardApplicationCommandIDs::copy,
@@ -1569,7 +1569,7 @@ void CodeEditorComponent::updateCachedIterators (int maxLineNum)
CodeDocument::Iterator* t = new CodeDocument::Iterator (last);
cachedIterators.add (t);
const int targetLine = last.getLine() + linesBetweenCachedSources;
const int targetLine = jmin (maxLineNum, last.getLine() + linesBetweenCachedSources);
for (;;)
{
@@ -1645,7 +1645,7 @@ void CodeEditorComponent::State::restoreState (CodeEditorComponent& editor) cons
CodeEditorComponent::State::State (const String& s)
{
StringArray tokens;
tokens.addTokens (s, ":", String::empty);
tokens.addTokens (s, ":", StringRef());
lastTopLine = tokens[0].getIntValue();
lastCaretPos = tokens[1].getIntValue();
@@ -119,7 +119,7 @@ static bool askToOverwriteFile (const File& newFile)
{
return AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
TRANS("File already exists"),
TRANS("There's already a file called: FLMN")
TRANS("There's already a file called: FLNM")
.replace ("FLNM", newFile.getFullPathName())
+ "\n\n"
+ TRANS("Are you sure you want to overwrite it?"),
@@ -40,17 +40,12 @@
//==============================================================================
#if JUCE_MAC
#define Point CarbonDummyPointName
#define Component CarbonDummyCompName
#import <WebKit/WebKit.h>
#import <IOKit/IOKitLib.h>
#import <IOKit/IOCFPlugIn.h>
#import <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDKeys.h>
#import <IOKit/pwr_mgt/IOPMLib.h>
#import <Carbon/Carbon.h> // still needed for SetSystemUIMode()
#undef Point
#undef Component
#elif JUCE_IOS
@@ -1,7 +1,7 @@
{
"id": "juce_gui_extra",
"name": "JUCE extended GUI classes",
"version": "3.0.5",
"version": "3.0.8",
"description": "Miscellaneous GUI classes for specialised tasks.",
"website": "http://www.juce.com/juce",
"license": "GPL/Commercial",
@@ -145,7 +145,7 @@ private:
ScopedPointer<Slider> sliders[4];
ScopedPointer<ColourSpaceView> colourSpace;
ScopedPointer<HueSelectorComp> hueSelector;
OwnedArray <SwatchComponent> swatchComponents;
OwnedArray<SwatchComponent> swatchComponents;
const int flags;
int edgeGap;
Rectangle<int> previewArea;
@@ -117,6 +117,8 @@ LivePropertyEditorBase::LivePropertyEditorBase (LiveValueBase& v, CodeDocument&
name.setFont (13.0f);
name.setText (v.name, dontSendNotification);
valueEditor.setMultiLine (v.isString());
valueEditor.setReturnKeyStartsNewLine (v.isString());
valueEditor.setText (v.getStringValue (wasHex), dontSendNotification);
valueEditor.addListener (this);
sourceEditor.setReadOnly (true);
@@ -138,11 +140,17 @@ void LivePropertyEditorBase::resized()
Rectangle<int> top (left.removeFromTop (25));
resetButton.setBounds (top.removeFromRight (35).reduced (0, 3));
name.setBounds (top);
valueEditor.setBounds (left.removeFromTop (25));
left.removeFromTop (2);
if (customComp != nullptr)
{
valueEditor.setBounds (left.removeFromTop (25));
left.removeFromTop (2);
customComp->setBounds (left);
}
else
{
valueEditor.setBounds (left);
}
r.removeFromLeft (4);
sourceEditor.setBounds (r);
@@ -373,7 +381,7 @@ struct ColourEditorComp : public Component,
Colour getColour() const
{
return Colour ((int) parseInt (editor.value.getStringValue (false)));
return Colour ((uint32) parseInt (editor.value.getStringValue (false)));
}
void paint (Graphics& g) override
@@ -53,7 +53,7 @@ namespace LiveConstantEditor
inline void setFromString (double& v, const String& s) { v = parseDouble (s); }
inline void setFromString (float& v, const String& s) { v = (float) parseDouble (s); }
inline void setFromString (String& v, const String& s) { v = s; }
inline void setFromString (Colour& v, const String& s) { v = Colour ((int) parseInt (s)); }
inline void setFromString (Colour& v, const String& s) { v = Colour ((uint32) parseInt (s)); }
template <typename Type>
inline String getAsString (const Type& v, bool) { return String (v); }
@@ -67,10 +67,13 @@ namespace LiveConstantEditor
inline String getAsString (uint64 v, bool preferHex) { return intToString ((int64) v, preferHex); }
inline String getAsString (Colour v, bool) { return intToString ((int) v.getARGB(), true); }
template <typename Type> struct isStringType { enum { value = 0 }; };
template <> struct isStringType<String> { enum { value = 1 }; };
template <typename Type>
inline String getAsCode (Type& v, bool preferHex) { return getAsString (v, preferHex); }
inline String getAsCode (Colour v, bool) { return "Colour (0x" + String::toHexString ((int) v.getARGB()).paddedLeft ('0', 8) + ")"; }
inline String getAsCode (const String& v, bool) { return "\"" + v + "\""; }
inline String getAsCode (const String& v, bool) { return CppTokeniserFunctions::addEscapeChars(v).quoted(); }
inline String getAsCode (const char* v, bool) { return getAsCode (String (v), false); }
template <typename Type>
@@ -90,6 +93,7 @@ namespace LiveConstantEditor
virtual String getCodeValue (bool preferHex) const = 0;
virtual void setStringValue (const String&) = 0;
virtual String getOriginalStringValue (bool preferHex) const = 0;
virtual bool isString() const = 0;
String name, sourceFile;
int sourceLine;
@@ -175,6 +179,7 @@ namespace LiveConstantEditor
String getCodeValue (bool preferHex) const override { return getAsCode (value, preferHex); }
String getOriginalStringValue (bool preferHex) const override { return getAsString (originalValue, preferHex); }
void setStringValue (const String& s) override { setFromString (value, s); }
bool isString() const override { return isStringType<Type>::value; }
Type value, originalValue;
@@ -288,7 +293,7 @@ namespace LiveConstantEditor
@endcode
*/
#define JUCE_LIVE_CONSTANT(initialValue) \
(LiveConstantEditor::getValue (__FILE__, __LINE__ - 1, initialValue))
(juce::LiveConstantEditor::getValue (__FILE__, __LINE__ - 1, initialValue))
#else
#define JUCE_LIVE_CONSTANT(initialValue) \
(initialValue)
@@ -142,7 +142,6 @@ public:
if (currentPeer != peer)
{
removeFromParent();
currentPeer = peer;
if (peer != nullptr)
@@ -151,6 +150,10 @@ public:
[peerView addSubview: view];
componentMovedOrResized (false, false);
}
else
{
removeFromParent();
}
}
[view setHidden: ! owner.isShowing()];
@@ -53,7 +53,10 @@ public:
~Pimpl()
{
[[NSNotificationCenter defaultCenter] removeObserver: view];
[[NSStatusBar systemStatusBar] removeStatusItem: statusItem];
SystemTrayViewClass::setOwner (view, nullptr);
SystemTrayViewClass::setImage (view, nil);
[statusItem release];
[view release];
[statusIcon release];
@@ -99,21 +102,21 @@ public:
if (isLeft || isRight) // Only mouse up is sent by the OS, so simulate a down/up
{
owner.mouseDown (MouseEvent (mouseSource, Point<int>(),
owner.mouseDown (MouseEvent (mouseSource, Point<float>(),
eventMods.withFlags (isLeft ? ModifierKeys::leftButtonModifier
: ModifierKeys::rightButtonModifier),
&owner, &owner, now,
Point<int>(), now, 1, false));
Point<float>(), now, 1, false));
owner.mouseUp (MouseEvent (mouseSource, Point<int>(), eventMods.withoutMouseButtons(),
owner.mouseUp (MouseEvent (mouseSource, Point<float>(), eventMods.withoutMouseButtons(),
&owner, &owner, now,
Point<int>(), now, 1, false));
Point<float>(), now, 1, false));
}
else if (type == NSMouseMoved)
{
owner.mouseMove (MouseEvent (mouseSource, Point<int>(), eventMods,
owner.mouseMove (MouseEvent (mouseSource, Point<float>(), eventMods,
&owner, &owner, now,
Point<int>(), now, 1, false));
Point<float>(), now, 1, false));
}
}
}
@@ -70,6 +70,7 @@ private:
static void runOpenPanel (id, SEL, WebView*, id<WebOpenPanelResultListener> resultListener, BOOL allowMultipleFiles)
{
#if JUCE_MODAL_LOOPS_PERMITTED
FileChooser chooser (TRANS("Select the file you want to upload..."),
File::getSpecialLocation (File::userHomeDirectory), "*");
@@ -81,6 +82,10 @@ private:
for (int i = 0; i < files.size(); ++i)
[resultListener chooseFilename: juceStringToNS (files.getReference(i).getFullPathName())];
}
#else
(void) resultListener; (void) allowMultipleFiles;
jassertfalse; // Can't use this without modal loops being enabled!
#endif
}
};
@@ -187,7 +187,7 @@ namespace ActiveXHelpers
case WM_MBUTTONUP:
case WM_RBUTTONUP:
peer->handleMouseEvent (0, Point<int> (GET_X_LPARAM (lParam) + activeXRect.left - peerRect.left,
GET_Y_LPARAM (lParam) + activeXRect.top - peerRect.top),
GET_Y_LPARAM (lParam) + activeXRect.top - peerRect.top).toFloat(),
ModifierKeys::getCurrentModifiersRealtime(),
getMouseEventTime());
break;
@@ -111,8 +111,8 @@ public:
const Time eventTime (getMouseEventTime());
const MouseEvent e (Desktop::getInstance().getMainMouseSource(),
Point<int>(), eventMods, &owner, &owner, eventTime,
Point<int>(), eventTime, 1, false);
Point<float>(), eventMods, &owner, &owner, eventTime,
Point<float>(), eventTime, 1, false);
if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN)
{
@@ -226,6 +226,9 @@ void WebBrowserComponent::goToURL (const String& url,
blankPageShown = false;
if (browser->browser == nullptr)
checkWindowAssociation();
browser->goToURL (url, headers, postData);
}
@@ -262,7 +265,10 @@ void WebBrowserComponent::refresh()
void WebBrowserComponent::paint (Graphics& g)
{
if (browser->browser == nullptr)
{
g.fillAll (Colours::white);
checkWindowAssociation();
}
}
void WebBrowserComponent::checkWindowAssociation()