| @@ -254,11 +254,11 @@ void SourceFileTreeViewItem::showPopupMenu() | |||
| m.addItem (1, "Open in external editor"); | |||
| m.addItem (2, | |||
| #if JUCE_MAC | |||
| #if JUCE_MAC | |||
| "Reveal in Finder"); | |||
| #else | |||
| #else | |||
| "Reveal in Explorer"); | |||
| #endif | |||
| #endif | |||
| m.addItem (4, "Rename File..."); | |||
| m.addSeparator(); | |||
| @@ -225,54 +225,6 @@ namespace CodeHelpers | |||
| return "CharPointer_UTF8 (" + CodeHelpers::addEscapeChars (text).quoted() + ")"; | |||
| } | |||
| String stringLiteralIfNotEmpty (const String& text) | |||
| { | |||
| return text.isNotEmpty() ? stringLiteral (text) : String::empty; | |||
| } | |||
| String boolLiteral (const bool b) | |||
| { | |||
| return b ? "true" : "false"; | |||
| } | |||
| String floatLiteral (float v) | |||
| { | |||
| String s ((double) v, 4); | |||
| if (s.containsChar ('.')) | |||
| { | |||
| s = s.trimCharactersAtEnd ("0"); | |||
| if (s.endsWithChar ('.')) | |||
| s << '0'; | |||
| s << 'f'; | |||
| } | |||
| else | |||
| { | |||
| s << ".0f"; | |||
| } | |||
| return s; | |||
| } | |||
| String doubleLiteral (double v) | |||
| { | |||
| String s (v, 7); | |||
| if (s.containsChar ('.')) | |||
| { | |||
| s = s.trimCharactersAtEnd ("0"); | |||
| if (s.endsWithChar ('.')) | |||
| s << '0'; | |||
| } | |||
| else | |||
| { | |||
| s << ".0"; | |||
| } | |||
| return s; | |||
| } | |||
| String alignFunctionCallParams (const String& call, const StringArray& parameters, const int maxLineLength) | |||
| { | |||
| String result, currentLine (call); | |||
| @@ -321,29 +273,6 @@ namespace CodeHelpers | |||
| return "Colour (0x" + hexString8Digits ((int) col.getARGB()) + ')'; | |||
| } | |||
| String castToFloat (const String& expression) | |||
| { | |||
| if (expression.containsOnly ("0123456789.f")) | |||
| { | |||
| String s (expression.getFloatValue()); | |||
| if (s.containsChar ('.')) | |||
| return s + "f"; | |||
| return s + ".0f"; | |||
| } | |||
| return "(float) (" + expression + ")"; | |||
| } | |||
| String castToInt (const String& expression) | |||
| { | |||
| if (expression.containsOnly ("0123456789.")) | |||
| return String ((int) expression.getFloatValue()); | |||
| return "(int) (" + expression + ")"; | |||
| } | |||
| void writeDataAsCppLiteral (const MemoryBlock& mb, OutputStream& out, | |||
| bool breakAtNewLines, bool allowStringBreaks) | |||
| { | |||
| @@ -382,10 +311,14 @@ namespace CodeHelpers | |||
| out << num << ','; | |||
| charsOnLine += 2; | |||
| if (num >= 10) | |||
| { | |||
| ++charsOnLine; | |||
| if (num >= 100) | |||
| ++charsOnLine; | |||
| if (num >= 100) | |||
| ++charsOnLine; | |||
| } | |||
| if (charsOnLine >= maxCharsOnLine) | |||
| { | |||
| @@ -405,6 +338,7 @@ namespace CodeHelpers | |||
| } | |||
| } | |||
| //============================================================================== | |||
| static int calculateHash (const String& s, const int hashMultiplier) | |||
| { | |||
| const char* t = s.toUTF8(); | |||
| @@ -39,14 +39,8 @@ namespace CodeHelpers | |||
| String makeBinaryDataIdentifierName (const File& file); | |||
| String stringLiteral (const String& text); | |||
| String stringLiteralIfNotEmpty (const String& text); // if the string's empty, this returns an empty string | |||
| String boolLiteral (bool b); | |||
| String floatLiteral (float v); | |||
| String doubleLiteral (double v); | |||
| String colourToCode (const Colour& col); | |||
| String castToFloat (const String& expression); | |||
| String castToInt (const String& expression); | |||
| String alignFunctionCallParams (const String& call, const StringArray& parameters, int maxLineLength); | |||
| void writeDataAsCppLiteral (const MemoryBlock& data, OutputStream& out, | |||
| @@ -54,7 +48,6 @@ namespace CodeHelpers | |||
| void createStringMatcher (OutputStream& out, const String& utf8PointerVariable, | |||
| const StringArray& strings, const StringArray& codeToExecute, const int indentLevel); | |||
| } | |||
| @@ -33,10 +33,6 @@ JucerTreeViewBase::JucerTreeViewBase() | |||
| setLinesDrawnForSubItems (false); | |||
| } | |||
| JucerTreeViewBase::~JucerTreeViewBase() | |||
| { | |||
| } | |||
| Font JucerTreeViewBase::getFont() const | |||
| { | |||
| return Font (getItemHeight() * 0.6f); | |||
| @@ -113,7 +109,8 @@ Component* JucerTreeViewBase::createItemComponent() | |||
| } | |||
| //============================================================================== | |||
| class RenameTreeItemCallback : public ModalComponentManager::Callback | |||
| class RenameTreeItemCallback : public ModalComponentManager::Callback, | |||
| public TextEditorListener | |||
| { | |||
| public: | |||
| RenameTreeItemCallback (JucerTreeViewBase& item_, Component& parent, const Rectangle<int>& bounds) | |||
| @@ -123,7 +120,7 @@ public: | |||
| ed.setPopupMenuEnabled (false); | |||
| ed.setSelectAllWhenFocused (true); | |||
| ed.setFont (item.getFont()); | |||
| ed.addListener (&item); | |||
| ed.addListener (this); | |||
| ed.setText (item.getRenamingName()); | |||
| ed.setBounds (bounds); | |||
| @@ -137,6 +134,11 @@ public: | |||
| item.setName (ed.getText()); | |||
| } | |||
| void textEditorTextChanged (TextEditor&) {} | |||
| void textEditorReturnKeyPressed (TextEditor& editor) { editor.exitModalState (1); } | |||
| void textEditorEscapeKeyPressed (TextEditor& editor) { editor.exitModalState (0); } | |||
| void textEditorFocusLost (TextEditor& editor) { editor.exitModalState (0); } | |||
| private: | |||
| TextEditor ed; | |||
| JucerTreeViewBase& item; | |||
| @@ -30,19 +30,11 @@ | |||
| //============================================================================== | |||
| class JucerTreeViewBase : public TreeViewItem, | |||
| public TextEditorListener | |||
| class JucerTreeViewBase : public TreeViewItem | |||
| { | |||
| protected: | |||
| //============================================================================== | |||
| JucerTreeViewBase(); | |||
| ~JucerTreeViewBase(); | |||
| public: | |||
| //============================================================================== | |||
| int getItemWidth() const { return -1; } | |||
| int getItemHeight() const { return 20; } | |||
| Font getFont() const; | |||
| void paintItem (Graphics& g, int width, int height); | |||
| void paintOpenCloseButton (Graphics& g, int width, int height, bool isMouseOver); | |||
| @@ -50,6 +42,7 @@ public: | |||
| void itemClicked (const MouseEvent& e); | |||
| //============================================================================== | |||
| virtual Font getFont() const; | |||
| virtual String getRenamingName() const = 0; | |||
| virtual String getDisplayName() const = 0; | |||
| virtual void setName (const String& newName) = 0; | |||
| @@ -62,12 +55,6 @@ public: | |||
| virtual void showRenameBox(); | |||
| // Text editor listener for renaming.. | |||
| void textEditorTextChanged (TextEditor&) {} | |||
| void textEditorReturnKeyPressed (TextEditor& editor) { editor.exitModalState (1); } | |||
| void textEditorEscapeKeyPressed (TextEditor& editor) { editor.exitModalState (0); } | |||
| void textEditorFocusLost (TextEditor& editor) { editor.exitModalState (0); } | |||
| //============================================================================== | |||
| // To handle situations where an item gets deleted before openness is | |||
| // restored for it, this OpennessRestorer keeps only a pointer to the | |||
| @@ -85,7 +72,9 @@ public: | |||
| } | |||
| }; | |||
| //============================================================================== | |||
| protected: | |||
| JucerTreeViewBase(); | |||
| private: | |||
| int numLeftHandComps; | |||
| int getTextX() const; | |||
| @@ -516,13 +516,11 @@ public: | |||
| { | |||
| // read the format chunk | |||
| const unsigned short format = (unsigned short) input->readShort(); | |||
| const short numChans = input->readShort(); | |||
| numChannels = (unsigned int) input->readShort(); | |||
| sampleRate = input->readInt(); | |||
| const int bytesPerSec = input->readInt(); | |||
| numChannels = (unsigned int) numChans; | |||
| bytesPerFrame = bytesPerSec / (int)sampleRate; | |||
| bitsPerSample = (unsigned int) (8 * bytesPerFrame / numChans); | |||
| input->skipNextBytes (4); // (skip bytes per second) | |||
| bytesPerFrame = (unsigned int) input->readShort(); | |||
| bitsPerSample = (unsigned int) (8 * bytesPerFrame / numChannels); | |||
| if (format == 3) | |||
| { | |||
| @@ -536,7 +534,7 @@ public: | |||
| } | |||
| else | |||
| { | |||
| input->skipNextBytes (12); // skip over blockAlign, bitsPerSample and speakerPosition mask | |||
| input->skipNextBytes (10); // skip over bitsPerSample and speakerPosition mask | |||
| ExtensibleWavSubFormat subFormat; | |||
| subFormat.data1 = (uint32) input->readInt(); | |||
| subFormat.data2 = (uint16) input->readShort(); | |||