@@ -308,14 +308,11 @@ bool File::moveToTrash() const | |||
#else | |||
JUCE_AUTORELEASEPOOL | |||
{ | |||
NSString* p = juceStringToNS (getFullPathName()); | |||
return [[NSWorkspace sharedWorkspace] | |||
performFileOperation: NSWorkspaceRecycleOperation | |||
source: [p stringByDeletingLastPathComponent] | |||
destination: nsEmptyString() | |||
files: [NSArray arrayWithObject: [p lastPathComponent]] | |||
tag: nil ]; | |||
NSURL* url = [NSURL fileURLWithPath: juceStringToNS (getFullPathName())]; | |||
[[NSWorkspace sharedWorkspace] recycleURLs: [NSArray arrayWithObject: url] | |||
completionHandler: nil]; | |||
return true; | |||
} | |||
#endif | |||
} | |||
@@ -272,16 +272,27 @@ namespace CoreTextTypeLayout | |||
} | |||
// Paragraph Attributes | |||
#if defined (MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8 | |||
CTTextAlignment ctTextAlignment = kCTTextAlignmentLeft; | |||
#else | |||
CTTextAlignment ctTextAlignment = kCTLeftTextAlignment; | |||
#endif | |||
CTLineBreakMode ctLineBreakMode = kCTLineBreakByWordWrapping; | |||
const CGFloat ctLineSpacing = text.getLineSpacing(); | |||
switch (text.getJustification().getOnlyHorizontalFlags()) | |||
{ | |||
case Justification::left: break; | |||
#if defined (MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8 | |||
case Justification::right: ctTextAlignment = kCTTextAlignmentRight; break; | |||
case Justification::horizontallyCentred: ctTextAlignment = kCTTextAlignmentCenter; break; | |||
case Justification::horizontallyJustified: ctTextAlignment = kCTTextAlignmentJustified; break; | |||
#else | |||
case Justification::right: ctTextAlignment = kCTRightTextAlignment; break; | |||
case Justification::horizontallyCentred: ctTextAlignment = kCTCenterTextAlignment; break; | |||
case Justification::horizontallyJustified: ctTextAlignment = kCTJustifiedTextAlignment; break; | |||
#endif | |||
default: jassertfalse; break; // Illegal justification flags | |||
} | |||
@@ -2965,9 +2965,13 @@ private: | |||
CWBorderPixel | CWColormap | CWBackPixmap | CWEventMask | CWOverrideRedirect, | |||
&swa); | |||
unsigned int buttonMask = EnterWindowMask | LeaveWindowMask | PointerMotionMask; | |||
if ((styleFlags & windowIgnoresMouseClicks) == 0) | |||
buttonMask |= ButtonPressMask | ButtonReleaseMask; | |||
XGrabButton (display, AnyButton, AnyModifier, windowH, False, | |||
ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, | |||
GrabModeAsync, GrabModeAsync, None, None); | |||
buttonMask, GrabModeAsync, GrabModeAsync, None, None); | |||
// Set the window context to identify the window handle object | |||
if (XSaveContext (display, (XID) windowH, windowHandleXContext, (XPointer) this)) | |||
@@ -3037,11 +3041,12 @@ private: | |||
{} | |||
} | |||
static int getAllEventsMask() noexcept | |||
int getAllEventsMask() const noexcept | |||
{ | |||
return NoEventMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |||
return NoEventMask | KeyPressMask | KeyReleaseMask | |||
| EnterWindowMask | LeaveWindowMask | PointerMotionMask | KeymapStateMask | |||
| ExposureMask | StructureNotifyMask | FocusChangeMask; | |||
| ExposureMask | StructureNotifyMask | FocusChangeMask | |||
| ((styleFlags & windowIgnoresMouseClicks) != 0 ? (ButtonPressMask | ButtonReleaseMask) : 0); | |||
} | |||
template <typename EventType> | |||
@@ -49,7 +49,7 @@ struct TextAtom | |||
return atomText.substring (0, numChars); | |||
if (isNewLine()) | |||
return String::empty; | |||
return String(); | |||
return String::repeatedString (String::charToString (passwordCharacter), numChars); | |||
} | |||
@@ -111,7 +111,7 @@ public: | |||
UniformTextSection* split (const int indexToBreakAt, const juce_wchar passwordChar) | |||
{ | |||
UniformTextSection* const section2 = new UniformTextSection (String::empty, font, colour, passwordChar); | |||
UniformTextSection* const section2 = new UniformTextSection (String(), font, colour, passwordChar); | |||
int index = 0; | |||
for (int i = 0; i < atoms.size(); ++i) | |||
@@ -902,6 +902,7 @@ TextEditor::TextEditor (const String& name, | |||
: Component (name), | |||
borderSize (1, 1, 1, 3), | |||
readOnly (false), | |||
caretVisible (true), | |||
multiline (false), | |||
wordWrap (false), | |||
returnKeyStartsNewLine (false), | |||
@@ -933,7 +934,7 @@ TextEditor::TextEditor (const String& name, | |||
viewport->setScrollBarsShown (false, false); | |||
setWantsKeyboardFocus (true); | |||
setCaretVisible (true); | |||
recreateCaret(); | |||
} | |||
TextEditor::~TextEditor() | |||
@@ -1020,7 +1021,7 @@ void TextEditor::setReadOnly (const bool shouldBeReadOnly) | |||
} | |||
} | |||
bool TextEditor::isReadOnly() const | |||
bool TextEditor::isReadOnly() const noexcept | |||
{ | |||
return readOnly || ! isEnabled(); | |||
} | |||
@@ -1084,20 +1085,27 @@ void TextEditor::colourChanged() | |||
void TextEditor::lookAndFeelChanged() | |||
{ | |||
recreateCaret(); | |||
repaint(); | |||
} | |||
void TextEditor::recreateCaret() | |||
void TextEditor::enablementChanged() | |||
{ | |||
if (isCaretVisible()) | |||
recreateCaret(); | |||
repaint(); | |||
} | |||
void TextEditor::setCaretVisible (const bool shouldCaretBeVisible) | |||
{ | |||
if (caretVisible != shouldCaretBeVisible) | |||
{ | |||
setCaretVisible (false); | |||
setCaretVisible (true); | |||
caretVisible = shouldCaretBeVisible; | |||
recreateCaret(); | |||
} | |||
} | |||
void TextEditor::setCaretVisible (const bool shouldCaretBeVisible) | |||
void TextEditor::recreateCaret() | |||
{ | |||
if (shouldCaretBeVisible && ! isReadOnly()) | |||
if (isCaretVisible()) | |||
{ | |||
if (caret == nullptr) | |||
{ | |||
@@ -1139,8 +1147,7 @@ void TextEditor::setInputFilter (InputFilter* newFilter, bool takeOwnership) | |||
inputFilter.set (newFilter, takeOwnership); | |||
} | |||
void TextEditor::setInputRestrictions (const int maxLen, | |||
const String& chars) | |||
void TextEditor::setInputRestrictions (const int maxLen, const String& chars) | |||
{ | |||
setInputFilter (new LengthAndCharacterRestriction (maxLen, chars), true); | |||
} | |||
@@ -1570,7 +1577,7 @@ void TextEditor::cut() | |||
if (! isReadOnly()) | |||
{ | |||
moveCaret (selection.getEnd()); | |||
insertTextAtCaret (String::empty); | |||
insertTextAtCaret (String()); | |||
} | |||
} | |||
@@ -2131,12 +2138,6 @@ void TextEditor::handleCommandMessage (const int commandId) | |||
} | |||
} | |||
void TextEditor::enablementChanged() | |||
{ | |||
recreateCaret(); | |||
repaint(); | |||
} | |||
void TextEditor::setTemporaryUnderlining (const Array<Range<int> >& newUnderlinedSections) | |||
{ | |||
underlinedSections = newUnderlinedSections; | |||
@@ -2361,7 +2362,7 @@ String TextEditor::getText() const | |||
String TextEditor::getTextInRange (const Range<int>& range) const | |||
{ | |||
if (range.isEmpty()) | |||
return String::empty; | |||
return String(); | |||
MemoryOutputStream mo; | |||
mo.preallocate ((size_t) jmin (getTotalNumChars(), range.getLength())); | |||
@@ -51,7 +51,7 @@ public: | |||
for a black splodge (not all fonts include this, though), or 0x2022, | |||
which is a bullet (probably the best choice for linux). | |||
*/ | |||
explicit TextEditor (const String& componentName = String::empty, | |||
explicit TextEditor (const String& componentName = String(), | |||
juce_wchar passwordCharacter = 0); | |||
/** Destructor. */ | |||
@@ -123,7 +123,7 @@ public: | |||
void setReadOnly (bool shouldBeReadOnly); | |||
/** Returns true if the editor is in read-only mode. */ | |||
bool isReadOnly() const; | |||
bool isReadOnly() const noexcept; | |||
//============================================================================== | |||
/** Makes the caret visible or invisible. | |||
@@ -135,7 +135,7 @@ public: | |||
/** Returns true if the caret is enabled. | |||
@see setCaretVisible | |||
*/ | |||
bool isCaretVisible() const noexcept { return caret != nullptr; } | |||
bool isCaretVisible() const noexcept { return caretVisible && ! isReadOnly(); } | |||
//============================================================================== | |||
/** Enables/disables a vertical scrollbar. | |||
@@ -347,7 +347,7 @@ public: | |||
this string, otherwise it will be inserted. | |||
To delete a section of text, you can use setHighlightedRegion() to | |||
highlight it, and call insertTextAtCursor (String::empty). | |||
highlight it, and call insertTextAtCaret (String()). | |||
@see setCaretPosition, getCaretPosition, setHighlightedRegion | |||
*/ | |||
@@ -583,7 +583,7 @@ public: | |||
this string are allowed to be entered into the editor. | |||
*/ | |||
void setInputRestrictions (int maxTextLength, | |||
const String& allowedCharacters = String::empty); | |||
const String& allowedCharacters = String()); | |||
void setKeyboardType (VirtualKeyboardType type) noexcept { keyboardType = type; } | |||
@@ -670,19 +670,20 @@ private: | |||
TextHolderComponent* textHolder; | |||
BorderSize<int> borderSize; | |||
bool readOnly : 1; | |||
bool multiline : 1; | |||
bool wordWrap : 1; | |||
bool returnKeyStartsNewLine : 1; | |||
bool popupMenuEnabled : 1; | |||
bool selectAllTextWhenFocused : 1; | |||
bool scrollbarVisible : 1; | |||
bool wasFocused : 1; | |||
bool keepCaretOnScreen : 1; | |||
bool tabKeyUsed : 1; | |||
bool menuActive : 1; | |||
bool valueTextNeedsUpdating : 1; | |||
bool consumeEscAndReturnKeys : 1; | |||
bool readOnly; | |||
bool caretVisible; | |||
bool multiline; | |||
bool wordWrap; | |||
bool returnKeyStartsNewLine; | |||
bool popupMenuEnabled; | |||
bool selectAllTextWhenFocused; | |||
bool scrollbarVisible; | |||
bool wasFocused; | |||
bool keepCaretOnScreen; | |||
bool tabKeyUsed; | |||
bool menuActive; | |||
bool valueTextNeedsUpdating; | |||
bool consumeEscAndReturnKeys; | |||
UndoManager undoManager; | |||
ScopedPointer<CaretComponent> caret; | |||