mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
New class: CaretComponent, which is created by the LookAndFeel. Fix for VST build on VC2005.
This commit is contained in:
parent
7485498ee7
commit
e1e5018a91
25 changed files with 586 additions and 522 deletions
|
|
@ -163,6 +163,7 @@ OBJECTS := \
|
|||
$(OBJDIR)/juce_FileTreeComponent_8cb2d3a3.o \
|
||||
$(OBJDIR)/juce_ImagePreviewComponent_a108ea50.o \
|
||||
$(OBJDIR)/juce_WildcardFileFilter_9337b18.o \
|
||||
$(OBJDIR)/juce_CaretComponent_26bf4433.o \
|
||||
$(OBJDIR)/juce_KeyboardFocusTraverser_6325fc08.o \
|
||||
$(OBJDIR)/juce_KeyListener_631ada24.o \
|
||||
$(OBJDIR)/juce_KeyMappingEditorComponent_a0183a92.o \
|
||||
|
|
@ -1002,6 +1003,11 @@ $(OBJDIR)/juce_WildcardFileFilter_9337b18.o: ../../src/gui/components/filebrowse
|
|||
@echo "Compiling juce_WildcardFileFilter.cpp"
|
||||
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"
|
||||
|
||||
$(OBJDIR)/juce_CaretComponent_26bf4433.o: ../../src/gui/components/keyboard/juce_CaretComponent.cpp
|
||||
-@mkdir -p $(OBJDIR)
|
||||
@echo "Compiling juce_CaretComponent.cpp"
|
||||
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"
|
||||
|
||||
$(OBJDIR)/juce_KeyboardFocusTraverser_6325fc08.o: ../../src/gui/components/keyboard/juce_KeyboardFocusTraverser.cpp
|
||||
-@mkdir -p $(OBJDIR)
|
||||
@echo "Compiling juce_KeyboardFocusTraverser.cpp"
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@
|
|||
0D91D36C2195315FE534F304 = { isa = PBXBuildFile; fileRef = A418FC3BDDBF1CE9F2903490; };
|
||||
A1E82F70796B8611D7323247 = { isa = PBXBuildFile; fileRef = 949854EDE6B5B16CEFB6108F; };
|
||||
BC1856E0B20406DDCE5EBF94 = { isa = PBXBuildFile; fileRef = 8A67B45A2BA1D19D1AC43315; };
|
||||
FF3A28F88174E10CB478931E = { isa = PBXBuildFile; fileRef = 912C419859C9C56BC96AA6FB; };
|
||||
C39AE37828718E9A45589A24 = { isa = PBXBuildFile; fileRef = 5ABC6616473BA4791AA8101E; };
|
||||
4400B0595B35F919291C1A01 = { isa = PBXBuildFile; fileRef = 29A79478AE8567250972ED43; };
|
||||
BB1DAC0CA8D7B3DEEDEE76C6 = { isa = PBXBuildFile; fileRef = 7F5A271EAB78C7CF8B2341DE; };
|
||||
|
|
@ -664,6 +665,8 @@
|
|||
F39059E72B927A700010851B = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ImagePreviewComponent.h; path = ../../src/gui/components/filebrowser/juce_ImagePreviewComponent.h; sourceTree = SOURCE_ROOT; };
|
||||
8A67B45A2BA1D19D1AC43315 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_WildcardFileFilter.cpp; path = ../../src/gui/components/filebrowser/juce_WildcardFileFilter.cpp; sourceTree = SOURCE_ROOT; };
|
||||
ECDD0F8397F3EE4E7FA7ACCC = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_WildcardFileFilter.h; path = ../../src/gui/components/filebrowser/juce_WildcardFileFilter.h; sourceTree = SOURCE_ROOT; };
|
||||
912C419859C9C56BC96AA6FB = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_CaretComponent.cpp; path = ../../src/gui/components/keyboard/juce_CaretComponent.cpp; sourceTree = SOURCE_ROOT; };
|
||||
717295136FD426125079F78C = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_CaretComponent.h; path = ../../src/gui/components/keyboard/juce_CaretComponent.h; sourceTree = SOURCE_ROOT; };
|
||||
5ABC6616473BA4791AA8101E = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_KeyboardFocusTraverser.cpp; path = ../../src/gui/components/keyboard/juce_KeyboardFocusTraverser.cpp; sourceTree = SOURCE_ROOT; };
|
||||
F61C34EE417006881D0869F4 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_KeyboardFocusTraverser.h; path = ../../src/gui/components/keyboard/juce_KeyboardFocusTraverser.h; sourceTree = SOURCE_ROOT; };
|
||||
29A79478AE8567250972ED43 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_KeyListener.cpp; path = ../../src/gui/components/keyboard/juce_KeyListener.cpp; sourceTree = SOURCE_ROOT; };
|
||||
|
|
@ -1424,6 +1427,8 @@
|
|||
8A67B45A2BA1D19D1AC43315,
|
||||
ECDD0F8397F3EE4E7FA7ACCC ); name = filebrowser; sourceTree = "<group>"; };
|
||||
558A664D5D1ECEC607F4775D = { isa = PBXGroup; children = (
|
||||
912C419859C9C56BC96AA6FB,
|
||||
717295136FD426125079F78C,
|
||||
5ABC6616473BA4791AA8101E,
|
||||
F61C34EE417006881D0869F4,
|
||||
29A79478AE8567250972ED43,
|
||||
|
|
@ -2149,6 +2154,7 @@
|
|||
0D91D36C2195315FE534F304,
|
||||
A1E82F70796B8611D7323247,
|
||||
BC1856E0B20406DDCE5EBF94,
|
||||
FF3A28F88174E10CB478931E,
|
||||
C39AE37828718E9A45589A24,
|
||||
4400B0595B35F919291C1A01,
|
||||
BB1DAC0CA8D7B3DEEDEE76C6,
|
||||
|
|
|
|||
|
|
@ -525,6 +525,8 @@
|
|||
<File RelativePath="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h"/>
|
||||
</Filter>
|
||||
<Filter Name="keyboard">
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_CaretComponent.cpp"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_CaretComponent.h"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.cpp"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/>
|
||||
|
|
|
|||
|
|
@ -525,6 +525,8 @@
|
|||
<File RelativePath="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h"/>
|
||||
</Filter>
|
||||
<Filter Name="keyboard">
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_CaretComponent.cpp"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_CaretComponent.h"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.cpp"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/>
|
||||
|
|
|
|||
|
|
@ -527,6 +527,8 @@
|
|||
<File RelativePath="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h"/>
|
||||
</Filter>
|
||||
<Filter Name="keyboard">
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_CaretComponent.cpp"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_CaretComponent.h"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.cpp"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h"/>
|
||||
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/>
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@
|
|||
<ClCompile Include="..\..\src\gui\components\filebrowser\juce_FileTreeComponent.cpp"/>
|
||||
<ClCompile Include="..\..\src\gui\components\filebrowser\juce_ImagePreviewComponent.cpp"/>
|
||||
<ClCompile Include="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.cpp"/>
|
||||
<ClCompile Include="..\..\src\gui\components\keyboard\juce_CaretComponent.cpp"/>
|
||||
<ClCompile Include="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.cpp"/>
|
||||
<ClCompile Include="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/>
|
||||
<ClCompile Include="..\..\src\gui\components\keyboard\juce_KeyMappingEditorComponent.cpp"/>
|
||||
|
|
@ -616,6 +617,7 @@
|
|||
<ClInclude Include="..\..\src\gui\components\filebrowser\juce_FileTreeComponent.h"/>
|
||||
<ClInclude Include="..\..\src\gui\components\filebrowser\juce_ImagePreviewComponent.h"/>
|
||||
<ClInclude Include="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h"/>
|
||||
<ClInclude Include="..\..\src\gui\components\keyboard\juce_CaretComponent.h"/>
|
||||
<ClInclude Include="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h"/>
|
||||
<ClInclude Include="..\..\src\gui\components\keyboard\juce_KeyListener.h"/>
|
||||
<ClInclude Include="..\..\src\gui\components\keyboard\juce_KeyMappingEditorComponent.h"/>
|
||||
|
|
|
|||
|
|
@ -598,6 +598,9 @@
|
|||
<ClCompile Include="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.cpp">
|
||||
<Filter>Juce\Source\gui\components\filebrowser</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\gui\components\keyboard\juce_CaretComponent.cpp">
|
||||
<Filter>Juce\Source\gui\components\keyboard</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.cpp">
|
||||
<Filter>Juce\Source\gui\components\keyboard</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -1782,6 +1785,9 @@
|
|||
<ClInclude Include="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h">
|
||||
<Filter>Juce\Source\gui\components\filebrowser</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\gui\components\keyboard\juce_CaretComponent.h">
|
||||
<Filter>Juce\Source\gui\components\keyboard</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h">
|
||||
<Filter>Juce\Source\gui\components\keyboard</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@
|
|||
0D91D36C2195315FE534F304 = { isa = PBXBuildFile; fileRef = A418FC3BDDBF1CE9F2903490; };
|
||||
A1E82F70796B8611D7323247 = { isa = PBXBuildFile; fileRef = 949854EDE6B5B16CEFB6108F; };
|
||||
BC1856E0B20406DDCE5EBF94 = { isa = PBXBuildFile; fileRef = 8A67B45A2BA1D19D1AC43315; };
|
||||
FF3A28F88174E10CB478931E = { isa = PBXBuildFile; fileRef = 912C419859C9C56BC96AA6FB; };
|
||||
C39AE37828718E9A45589A24 = { isa = PBXBuildFile; fileRef = 5ABC6616473BA4791AA8101E; };
|
||||
4400B0595B35F919291C1A01 = { isa = PBXBuildFile; fileRef = 29A79478AE8567250972ED43; };
|
||||
BB1DAC0CA8D7B3DEEDEE76C6 = { isa = PBXBuildFile; fileRef = 7F5A271EAB78C7CF8B2341DE; };
|
||||
|
|
@ -664,6 +665,8 @@
|
|||
F39059E72B927A700010851B = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ImagePreviewComponent.h; path = ../../src/gui/components/filebrowser/juce_ImagePreviewComponent.h; sourceTree = SOURCE_ROOT; };
|
||||
8A67B45A2BA1D19D1AC43315 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_WildcardFileFilter.cpp; path = ../../src/gui/components/filebrowser/juce_WildcardFileFilter.cpp; sourceTree = SOURCE_ROOT; };
|
||||
ECDD0F8397F3EE4E7FA7ACCC = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_WildcardFileFilter.h; path = ../../src/gui/components/filebrowser/juce_WildcardFileFilter.h; sourceTree = SOURCE_ROOT; };
|
||||
912C419859C9C56BC96AA6FB = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_CaretComponent.cpp; path = ../../src/gui/components/keyboard/juce_CaretComponent.cpp; sourceTree = SOURCE_ROOT; };
|
||||
717295136FD426125079F78C = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_CaretComponent.h; path = ../../src/gui/components/keyboard/juce_CaretComponent.h; sourceTree = SOURCE_ROOT; };
|
||||
5ABC6616473BA4791AA8101E = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_KeyboardFocusTraverser.cpp; path = ../../src/gui/components/keyboard/juce_KeyboardFocusTraverser.cpp; sourceTree = SOURCE_ROOT; };
|
||||
F61C34EE417006881D0869F4 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_KeyboardFocusTraverser.h; path = ../../src/gui/components/keyboard/juce_KeyboardFocusTraverser.h; sourceTree = SOURCE_ROOT; };
|
||||
29A79478AE8567250972ED43 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_KeyListener.cpp; path = ../../src/gui/components/keyboard/juce_KeyListener.cpp; sourceTree = SOURCE_ROOT; };
|
||||
|
|
@ -1424,6 +1427,8 @@
|
|||
8A67B45A2BA1D19D1AC43315,
|
||||
ECDD0F8397F3EE4E7FA7ACCC ); name = filebrowser; sourceTree = "<group>"; };
|
||||
558A664D5D1ECEC607F4775D = { isa = PBXGroup; children = (
|
||||
912C419859C9C56BC96AA6FB,
|
||||
717295136FD426125079F78C,
|
||||
5ABC6616473BA4791AA8101E,
|
||||
F61C34EE417006881D0869F4,
|
||||
29A79478AE8567250972ED43,
|
||||
|
|
@ -2153,6 +2158,7 @@
|
|||
0D91D36C2195315FE534F304,
|
||||
A1E82F70796B8611D7323247,
|
||||
BC1856E0B20406DDCE5EBF94,
|
||||
FF3A28F88174E10CB478931E,
|
||||
C39AE37828718E9A45589A24,
|
||||
4400B0595B35F919291C1A01,
|
||||
BB1DAC0CA8D7B3DEEDEE76C6,
|
||||
|
|
|
|||
|
|
@ -683,6 +683,10 @@
|
|||
file="src/gui/components/filebrowser/juce_WildcardFileFilter.h"/>
|
||||
</GROUP>
|
||||
<GROUP id="PAM9sn3Rp" name="keyboard">
|
||||
<FILE id="KAEiwD" name="juce_CaretComponent.cpp" compile="1" resource="0"
|
||||
file="src/gui/components/keyboard/juce_CaretComponent.cpp"/>
|
||||
<FILE id="UpJwqg" name="juce_CaretComponent.h" compile="0" resource="0"
|
||||
file="src/gui/components/keyboard/juce_CaretComponent.h"/>
|
||||
<FILE id="mUtddLtZX" name="juce_KeyboardFocusTraverser.cpp" compile="1"
|
||||
resource="0" file="src/gui/components/keyboard/juce_KeyboardFocusTraverser.cpp"/>
|
||||
<FILE id="edrEUIDT" name="juce_KeyboardFocusTraverser.h" compile="0"
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@
|
|||
#include "../src/gui/components/keyboard/juce_KeyPress.cpp"
|
||||
#include "../src/gui/components/keyboard/juce_KeyPressMappingSet.cpp"
|
||||
#include "../src/gui/components/keyboard/juce_ModifierKeys.cpp"
|
||||
#include "../src/gui/components/keyboard/juce_CaretComponent.cpp"
|
||||
#include "../src/gui/components/layout/juce_ComponentAnimator.cpp"
|
||||
#include "../src/gui/components/layout/juce_ComponentBuilder.cpp"
|
||||
#include "../src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp"
|
||||
|
|
|
|||
|
|
@ -210,6 +210,19 @@ namespace
|
|||
|
||||
LRESULT CALLBACK mouseWheelHookCallback (int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
#ifndef WM_MOUSEWHEEL
|
||||
#define WM_MOUSEWHEEL 0x20a
|
||||
|
||||
struct MSLLHOOKSTRUCT
|
||||
{
|
||||
POINT pt;
|
||||
DWORD mouseData;
|
||||
DWORD flags;
|
||||
DWORD time;
|
||||
ULONG_PTR dwExtraInfo;
|
||||
};
|
||||
#endif
|
||||
|
||||
if (nCode >= 0 && wParam == WM_MOUSEWHEEL)
|
||||
{
|
||||
const MSLLHOOKSTRUCT& hs = *(MSLLHOOKSTRUCT*) lParam;
|
||||
|
|
@ -226,6 +239,10 @@ namespace
|
|||
|
||||
void registerMouseWheelHook()
|
||||
{
|
||||
#ifndef WH_MOUSE_LL
|
||||
#define WH_MOUSE_LL 14
|
||||
#endif
|
||||
|
||||
if (mouseHookUsers++ == 0)
|
||||
mouseWheelHook = SetWindowsHookEx (WH_MOUSE_LL, mouseWheelHookCallback,
|
||||
(HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(), 0);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public:
|
|||
registerColour (TextEditor::highlightColourId, "highlight", "hilitecol");
|
||||
registerColour (TextEditor::outlineColourId, "outline", "outlinecol");
|
||||
registerColour (TextEditor::shadowColourId, "shadow", "shadowcol");
|
||||
registerColour (TextEditor::caretColourId, "caret", "caretcol");
|
||||
registerColour (CaretComponent::caretColourId, "caret", "caretcol");
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -73,7 +73,7 @@ namespace JuceDummyNamespace {}
|
|||
*/
|
||||
#define JUCE_MAJOR_VERSION 1
|
||||
#define JUCE_MINOR_VERSION 53
|
||||
#define JUCE_BUILDNUMBER 55
|
||||
#define JUCE_BUILDNUMBER 56
|
||||
|
||||
/** Current Juce version number.
|
||||
|
||||
|
|
@ -41819,6 +41819,61 @@ public:
|
|||
#endif // __JUCE_TEXTINPUTTARGET_JUCEHEADER__
|
||||
/*** End of inlined file: juce_TextInputTarget.h ***/
|
||||
|
||||
|
||||
/*** Start of inlined file: juce_CaretComponent.h ***/
|
||||
#ifndef __JUCE_CARETCOMPONENT_JUCEHEADER__
|
||||
#define __JUCE_CARETCOMPONENT_JUCEHEADER__
|
||||
|
||||
/**
|
||||
*/
|
||||
class JUCE_API CaretComponent : public Component,
|
||||
public Timer
|
||||
{
|
||||
public:
|
||||
|
||||
/** Creates the caret component.
|
||||
The keyFocusOwner is an optional component which the caret will check, making
|
||||
itself visible only when the keyFocusOwner has keyboard focus.
|
||||
*/
|
||||
CaretComponent (Component* keyFocusOwner);
|
||||
|
||||
/** Destructor. */
|
||||
~CaretComponent();
|
||||
|
||||
/** Sets the caret's position to place it next to the given character.
|
||||
The area is the rectangle containing the entire character that the caret is
|
||||
positioned on, so by default a vertical-line caret may choose to just show itself
|
||||
at the left of this area. You can override this method to customise its size.
|
||||
This method will also force the caret to reset its timer and become visible (if
|
||||
appropriate), so that as it moves, you can see where it is.
|
||||
*/
|
||||
virtual void setCaretPosition (const Rectangle<int>& characterArea);
|
||||
|
||||
/** A set of colour IDs to use to change the colour of various aspects of the caret.
|
||||
These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
|
||||
methods.
|
||||
@see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
|
||||
*/
|
||||
enum ColourIds
|
||||
{
|
||||
caretColourId = 0x1000204, /**< The colour with which to draw the caret. */
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
void paint (Graphics& g);
|
||||
/** @internal */
|
||||
void timerCallback();
|
||||
|
||||
private:
|
||||
Component* owner;
|
||||
bool shouldBeShown() const;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (CaretComponent);
|
||||
};
|
||||
|
||||
#endif // __JUCE_CARETCOMPONENT_JUCEHEADER__
|
||||
/*** End of inlined file: juce_CaretComponent.h ***/
|
||||
|
||||
/**
|
||||
A component containing text that can be edited.
|
||||
|
||||
|
|
@ -41910,9 +41965,7 @@ public:
|
|||
bool isReadOnly() const;
|
||||
|
||||
/** Makes the caret visible or invisible.
|
||||
|
||||
By default the caret is visible.
|
||||
|
||||
@see setCaretColour, setCaretPosition
|
||||
*/
|
||||
void setCaretVisible (bool shouldBeVisible);
|
||||
|
|
@ -41920,7 +41973,7 @@ public:
|
|||
/** Returns true if the caret is enabled.
|
||||
@see setCaretVisible
|
||||
*/
|
||||
bool isCaretVisible() const { return caretVisible; }
|
||||
bool isCaretVisible() const { return caret != 0; }
|
||||
|
||||
/** Enables/disables a vertical scrollbar.
|
||||
|
||||
|
|
@ -41994,8 +42047,6 @@ public:
|
|||
|
||||
highlightedTextColourId = 0x1000203, /**< The colour with which to draw the text in highlighted sections. */
|
||||
|
||||
caretColourId = 0x1000204, /**< The colour with which to draw the caret. */
|
||||
|
||||
outlineColourId = 0x1000205, /**< If this is non-transparent, it will be used to draw a box around
|
||||
the edge of the component. */
|
||||
|
||||
|
|
@ -42385,19 +42436,17 @@ private:
|
|||
bool multiline : 1;
|
||||
bool wordWrap : 1;
|
||||
bool returnKeyStartsNewLine : 1;
|
||||
bool caretVisible : 1;
|
||||
bool popupMenuEnabled : 1;
|
||||
bool selectAllTextWhenFocused : 1;
|
||||
bool scrollbarVisible : 1;
|
||||
bool wasFocused : 1;
|
||||
bool caretFlashState : 1;
|
||||
bool keepCursorOnScreen : 1;
|
||||
bool tabKeyUsed : 1;
|
||||
bool menuActive : 1;
|
||||
bool valueTextNeedsUpdating : 1;
|
||||
|
||||
UndoManager undoManager;
|
||||
float cursorX, cursorY, cursorHeight;
|
||||
ScopedPointer<CaretComponent> caret;
|
||||
int maxTextLength;
|
||||
Range<int> selection;
|
||||
int leftIndent, topIndent;
|
||||
|
|
@ -42441,7 +42490,6 @@ private:
|
|||
void updateTextHolderSize();
|
||||
float getWordWrapWidth() const;
|
||||
void timerCallbackInt();
|
||||
void repaintCaret();
|
||||
void repaintText (const Range<int>& range);
|
||||
UndoManager* getUndoManager() throw();
|
||||
|
||||
|
|
@ -51637,7 +51685,6 @@ public:
|
|||
enum ColourIds
|
||||
{
|
||||
backgroundColourId = 0x1004500, /**< A colour to use to fill the editor's background. */
|
||||
caretColourId = 0x1004501, /**< The colour to draw the caret. */
|
||||
highlightColourId = 0x1004502, /**< The colour to use for the highlighted background under
|
||||
selected text. */
|
||||
defaultTextColourId = 0x1004503 /**< The colour to use for text when no syntax colouring is
|
||||
|
|
@ -51697,8 +51744,6 @@ private:
|
|||
CodeDocument::Position caretPos;
|
||||
CodeDocument::Position selectionStart, selectionEnd;
|
||||
|
||||
class CaretComponent;
|
||||
friend class ScopedPointer <CaretComponent>;
|
||||
ScopedPointer<CaretComponent> caret;
|
||||
ScrollBar verticalScrollBar, horizontalScrollBar;
|
||||
|
||||
|
|
@ -51724,6 +51769,7 @@ private:
|
|||
void getIteratorForPosition (int position, CodeDocument::Iterator& result);
|
||||
void moveLineDelta (int delta, bool selecting);
|
||||
|
||||
void updateCaretPosition();
|
||||
void updateScrollBars();
|
||||
void scrollToLineInternal (int line);
|
||||
void scrollToColumnInternal (double column);
|
||||
|
|
@ -57710,6 +57756,9 @@ private:
|
|||
#endif
|
||||
#ifndef __JUCE_MODALCOMPONENTMANAGER_JUCEHEADER__
|
||||
|
||||
#endif
|
||||
#ifndef __JUCE_CARETCOMPONENT_JUCEHEADER__
|
||||
|
||||
#endif
|
||||
#ifndef __JUCE_KEYBOARDFOCUSTRAVERSER_JUCEHEADER__
|
||||
|
||||
|
|
@ -59878,6 +59927,7 @@ class FilePreviewComponent;
|
|||
class ImageButton;
|
||||
class CallOutBox;
|
||||
class Drawable;
|
||||
class CaretComponent;
|
||||
|
||||
/**
|
||||
LookAndFeel objects define the appearance of all the JUCE widgets, and subclasses
|
||||
|
|
@ -60099,6 +60149,8 @@ public:
|
|||
virtual void fillTextEditorBackground (Graphics& g, int width, int height, TextEditor& textEditor);
|
||||
virtual void drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor);
|
||||
|
||||
virtual CaretComponent* createCaretComponent (Component* keyFocusOwner);
|
||||
|
||||
// These return a pointer to an internally cached drawable - make sure you don't keep
|
||||
// a copy of this pointer anywhere, as it may become invalid in the future.
|
||||
virtual const Drawable* getDefaultFolderImage();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
*/
|
||||
#define JUCE_MAJOR_VERSION 1
|
||||
#define JUCE_MINOR_VERSION 53
|
||||
#define JUCE_BUILDNUMBER 55
|
||||
#define JUCE_BUILDNUMBER 56
|
||||
|
||||
/** Current Juce version number.
|
||||
|
||||
|
|
|
|||
|
|
@ -32,44 +32,6 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "../../../utilities/juce_SystemClipboard.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class CodeEditorComponent::CaretComponent : public Component,
|
||||
public Timer
|
||||
{
|
||||
public:
|
||||
CaretComponent (CodeEditorComponent& owner_)
|
||||
: owner (owner_)
|
||||
{
|
||||
setAlwaysOnTop (true);
|
||||
setInterceptsMouseClicks (false, false);
|
||||
}
|
||||
|
||||
void paint (Graphics& g)
|
||||
{
|
||||
g.fillAll (findColour (CodeEditorComponent::caretColourId));
|
||||
}
|
||||
|
||||
void timerCallback()
|
||||
{
|
||||
setVisible (shouldBeShown() && ! isVisible());
|
||||
}
|
||||
|
||||
void updatePosition()
|
||||
{
|
||||
startTimer (400);
|
||||
setVisible (shouldBeShown());
|
||||
|
||||
setBounds (owner.getCharacterBounds (owner.getCaretPos()).withWidth (2));
|
||||
}
|
||||
|
||||
private:
|
||||
CodeEditorComponent& owner;
|
||||
|
||||
bool shouldBeShown() const { return owner.hasKeyboardFocus (true); }
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (CaretComponent);
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class CodeEditorComponent::CodeEditorLine
|
||||
{
|
||||
|
|
@ -311,7 +273,7 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& document_,
|
|||
addAndMakeVisible (&horizontalScrollBar);
|
||||
horizontalScrollBar.setSingleStepSize (1.0);
|
||||
|
||||
addAndMakeVisible (caret = new CaretComponent (*this));
|
||||
addAndMakeVisible (caret = getLookAndFeel().createCaretComponent (this));
|
||||
|
||||
Font f (12.0f);
|
||||
f.setTypefaceName (Font::getDefaultMonospacedFontName());
|
||||
|
|
@ -354,7 +316,7 @@ void CodeEditorComponent::codeDocumentChanged (const CodeDocument::Position& aff
|
|||
|
||||
triggerAsyncUpdate();
|
||||
|
||||
caret->updatePosition();
|
||||
updateCaretPosition();
|
||||
columnToTryToMaintain = -1;
|
||||
|
||||
if (affectedTextEnd.getPosition() >= selectionStart.getPosition()
|
||||
|
|
@ -374,7 +336,7 @@ void CodeEditorComponent::resized()
|
|||
columnsOnScreen = (int) ((getWidth() - scrollbarThickness) / charWidth);
|
||||
lines.clear();
|
||||
rebuildLineTokens();
|
||||
caret->updatePosition();
|
||||
updateCaretPosition();
|
||||
|
||||
verticalScrollBar.setBounds (getWidth() - scrollbarThickness, 0, scrollbarThickness, getHeight() - scrollbarThickness);
|
||||
horizontalScrollBar.setBounds (gutter, getHeight() - scrollbarThickness, getWidth() - scrollbarThickness - gutter, scrollbarThickness);
|
||||
|
|
@ -467,6 +429,11 @@ void CodeEditorComponent::rebuildLineTokens()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void CodeEditorComponent::updateCaretPosition()
|
||||
{
|
||||
caret->setCaretPosition (getCharacterBounds (getCaretPos()));
|
||||
}
|
||||
|
||||
void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, const bool highlighting)
|
||||
{
|
||||
caretPos = newPos;
|
||||
|
|
@ -517,7 +484,7 @@ void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, con
|
|||
deselectAll();
|
||||
}
|
||||
|
||||
caret->updatePosition();
|
||||
updateCaretPosition();
|
||||
scrollToKeepCaretOnScreen();
|
||||
updateScrollBars();
|
||||
}
|
||||
|
|
@ -548,7 +515,7 @@ void CodeEditorComponent::scrollToLineInternal (int newFirstLineOnScreen)
|
|||
if (newFirstLineOnScreen != firstLineOnScreen)
|
||||
{
|
||||
firstLineOnScreen = newFirstLineOnScreen;
|
||||
caret->updatePosition();
|
||||
updateCaretPosition();
|
||||
|
||||
updateCachedIterators (firstLineOnScreen);
|
||||
triggerAsyncUpdate();
|
||||
|
|
@ -562,7 +529,7 @@ void CodeEditorComponent::scrollToColumnInternal (double column)
|
|||
if (xOffset != newOffset)
|
||||
{
|
||||
xOffset = newOffset;
|
||||
caret->updatePosition();
|
||||
updateCaretPosition();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
|
@ -1104,12 +1071,12 @@ void CodeEditorComponent::scrollBarMoved (ScrollBar* scrollBarThatHasMoved, doub
|
|||
//==============================================================================
|
||||
void CodeEditorComponent::focusGained (FocusChangeType)
|
||||
{
|
||||
caret->updatePosition();
|
||||
updateCaretPosition();
|
||||
}
|
||||
|
||||
void CodeEditorComponent::focusLost (FocusChangeType)
|
||||
{
|
||||
caret->updatePosition();
|
||||
updateCaretPosition();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "../juce_Component.h"
|
||||
#include "../layout/juce_ScrollBar.h"
|
||||
#include "../keyboard/juce_TextInputTarget.h"
|
||||
#include "../keyboard/juce_CaretComponent.h"
|
||||
#include "juce_CodeDocument.h"
|
||||
#include "juce_CodeTokeniser.h"
|
||||
|
||||
|
|
@ -208,7 +209,6 @@ public:
|
|||
enum ColourIds
|
||||
{
|
||||
backgroundColourId = 0x1004500, /**< A colour to use to fill the editor's background. */
|
||||
caretColourId = 0x1004501, /**< The colour to draw the caret. */
|
||||
highlightColourId = 0x1004502, /**< The colour to use for the highlighted background under
|
||||
selected text. */
|
||||
defaultTextColourId = 0x1004503 /**< The colour to use for text when no syntax colouring is
|
||||
|
|
@ -270,8 +270,6 @@ private:
|
|||
CodeDocument::Position caretPos;
|
||||
CodeDocument::Position selectionStart, selectionEnd;
|
||||
|
||||
class CaretComponent;
|
||||
friend class ScopedPointer <CaretComponent>;
|
||||
ScopedPointer<CaretComponent> caret;
|
||||
ScrollBar verticalScrollBar, horizontalScrollBar;
|
||||
|
||||
|
|
@ -299,6 +297,7 @@ private:
|
|||
void moveLineDelta (int delta, bool selecting);
|
||||
|
||||
//==============================================================================
|
||||
void updateCaretPosition();
|
||||
void updateScrollBars();
|
||||
void scrollToLineInternal (int line);
|
||||
void scrollToColumnInternal (double column);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "juce_Label.h"
|
||||
#include "../lookandfeel/juce_LookAndFeel.h"
|
||||
#include "../windows/juce_ComponentPeer.h"
|
||||
#include "../keyboard/juce_CaretComponent.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -311,10 +312,10 @@ TextEditor* Label::createEditorComponent()
|
|||
TextEditor::textColourId,
|
||||
TextEditor::highlightColourId,
|
||||
TextEditor::highlightedTextColourId,
|
||||
TextEditor::caretColourId,
|
||||
TextEditor::outlineColourId,
|
||||
TextEditor::focusedOutlineColourId,
|
||||
TextEditor::shadowColourId };
|
||||
TextEditor::shadowColourId,
|
||||
CaretComponent::caretColourId };
|
||||
|
||||
for (int i = 0; i < numElementsInArray (cols); ++i)
|
||||
ed->setColour (cols[i], findColour (cols[i]));
|
||||
|
|
|
|||
|
|
@ -884,6 +884,11 @@ public:
|
|||
owner.drawContent (g);
|
||||
}
|
||||
|
||||
void restartTimer()
|
||||
{
|
||||
startTimer (350);
|
||||
}
|
||||
|
||||
void timerCallback()
|
||||
{
|
||||
owner.timerCallbackInt();
|
||||
|
|
@ -943,8 +948,6 @@ private:
|
|||
//==============================================================================
|
||||
namespace TextEditorDefs
|
||||
{
|
||||
const int flashSpeedIntervalMs = 380;
|
||||
|
||||
const int textChangeMessageId = 0x10003001;
|
||||
const int returnKeyMessageId = 0x10003002;
|
||||
const int escapeKeyMessageId = 0x10003003;
|
||||
|
|
@ -968,19 +971,14 @@ TextEditor::TextEditor (const String& name,
|
|||
multiline (false),
|
||||
wordWrap (false),
|
||||
returnKeyStartsNewLine (false),
|
||||
caretVisible (true),
|
||||
popupMenuEnabled (true),
|
||||
selectAllTextWhenFocused (false),
|
||||
scrollbarVisible (true),
|
||||
wasFocused (false),
|
||||
caretFlashState (true),
|
||||
keepCursorOnScreen (true),
|
||||
tabKeyUsed (false),
|
||||
menuActive (false),
|
||||
valueTextNeedsUpdating (false),
|
||||
cursorX (0),
|
||||
cursorY (0),
|
||||
cursorHeight (0),
|
||||
maxTextLength (0),
|
||||
leftIndent (4),
|
||||
topIndent (4),
|
||||
|
|
@ -998,8 +996,8 @@ TextEditor::TextEditor (const String& name,
|
|||
viewport->setWantsKeyboardFocus (false);
|
||||
viewport->setScrollBarsShown (false, false);
|
||||
|
||||
setMouseCursor (MouseCursor::IBeamCursor);
|
||||
setWantsKeyboardFocus (true);
|
||||
setCaretVisible (true);
|
||||
}
|
||||
|
||||
TextEditor::~TextEditor()
|
||||
|
|
@ -1142,15 +1140,26 @@ void TextEditor::colourChanged()
|
|||
|
||||
void TextEditor::setCaretVisible (const bool shouldCaretBeVisible)
|
||||
{
|
||||
caretVisible = shouldCaretBeVisible;
|
||||
|
||||
if (shouldCaretBeVisible)
|
||||
textHolder->startTimer (TextEditorDefs::flashSpeedIntervalMs);
|
||||
if (shouldCaretBeVisible && ! isReadOnly())
|
||||
{
|
||||
if (caret == 0)
|
||||
textHolder->addChildComponent (caret = getLookAndFeel().createCaretComponent (this));
|
||||
}
|
||||
else
|
||||
{
|
||||
caret = 0;
|
||||
}
|
||||
|
||||
setMouseCursor (shouldCaretBeVisible ? MouseCursor::IBeamCursor
|
||||
: MouseCursor::NormalCursor);
|
||||
}
|
||||
|
||||
void TextEditor::updateCaretPosition()
|
||||
{
|
||||
if (caret != 0)
|
||||
caret->setCaretPosition (getCaretRectangle().translated (leftIndent, topIndent));
|
||||
}
|
||||
|
||||
void TextEditor::setInputRestrictions (const int maxLen,
|
||||
const String& chars)
|
||||
{
|
||||
|
|
@ -1279,22 +1288,8 @@ void TextEditor::removeListener (TextEditorListener* const listenerToRemove)
|
|||
//==============================================================================
|
||||
void TextEditor::timerCallbackInt()
|
||||
{
|
||||
const bool newState = (! caretFlashState) && ! isCurrentlyBlockedByAnotherModalComponent();
|
||||
|
||||
if (caretFlashState != newState)
|
||||
{
|
||||
caretFlashState = newState;
|
||||
|
||||
if (caretFlashState)
|
||||
wasFocused = true;
|
||||
|
||||
if (caretVisible
|
||||
&& hasKeyboardFocus (false)
|
||||
&& ! isReadOnly())
|
||||
{
|
||||
repaintCaret();
|
||||
}
|
||||
}
|
||||
if (hasKeyboardFocus (false) && ! isCurrentlyBlockedByAnotherModalComponent())
|
||||
wasFocused = true;
|
||||
|
||||
const unsigned int now = Time::getApproximateMillisecondCounter();
|
||||
|
||||
|
|
@ -1302,15 +1297,6 @@ void TextEditor::timerCallbackInt()
|
|||
newTransaction();
|
||||
}
|
||||
|
||||
void TextEditor::repaintCaret()
|
||||
{
|
||||
if (! findColour (caretColourId).isTransparent())
|
||||
repaint (borderSize.getLeft() + textHolder->getX() + leftIndent + roundToInt (cursorX) - 1,
|
||||
borderSize.getTop() + textHolder->getY() + topIndent + roundToInt (cursorY) - 1,
|
||||
4,
|
||||
roundToInt (cursorHeight) + 2);
|
||||
}
|
||||
|
||||
void TextEditor::repaintText (const Range<int>& range)
|
||||
{
|
||||
if (! range.isEmpty())
|
||||
|
|
@ -1353,12 +1339,10 @@ void TextEditor::moveCaret (int newCaretPos)
|
|||
|
||||
if (newCaretPos != getCaretPosition())
|
||||
{
|
||||
repaintCaret();
|
||||
caretFlashState = true;
|
||||
caretPosition = newCaretPos;
|
||||
textHolder->startTimer (TextEditorDefs::flashSpeedIntervalMs);
|
||||
textHolder->restartTimer();
|
||||
scrollToMakeSureCursorIsVisible();
|
||||
repaintCaret();
|
||||
updateCaretPosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1378,17 +1362,15 @@ void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX,
|
|||
{
|
||||
updateCaretPosition();
|
||||
|
||||
int vx = roundToInt (cursorX) - desiredCaretX;
|
||||
int vy = roundToInt (cursorY) - desiredCaretY;
|
||||
const Rectangle<int> caretPos (getCaretRectangle());
|
||||
|
||||
int vx = caretPos.getX() - desiredCaretX;
|
||||
int vy = caretPos.getY() - desiredCaretY;
|
||||
|
||||
if (desiredCaretX < jmax (1, proportionOfWidth (0.05f)))
|
||||
{
|
||||
vx += desiredCaretX - proportionOfWidth (0.2f);
|
||||
}
|
||||
else if (desiredCaretX > jmax (0, viewport->getMaximumVisibleWidth() - (wordWrap ? 2 : 10)))
|
||||
{
|
||||
vx += desiredCaretX + (isMultiLine() ? proportionOfWidth (0.2f) : 10) - viewport->getMaximumVisibleWidth();
|
||||
}
|
||||
|
||||
vx = jlimit (0, jmax (0, textHolder->getWidth() + 8 - viewport->getMaximumVisibleWidth()), vx);
|
||||
|
||||
|
|
@ -1400,16 +1382,10 @@ void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX,
|
|||
{
|
||||
vy = jlimit (0, jmax (0, textHolder->getHeight() - viewport->getMaximumVisibleHeight()), vy);
|
||||
|
||||
const int curH = roundToInt (cursorHeight);
|
||||
|
||||
if (desiredCaretY < 0)
|
||||
{
|
||||
vy = jmax (0, desiredCaretY + vy);
|
||||
}
|
||||
else if (desiredCaretY > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - curH))
|
||||
{
|
||||
vy += desiredCaretY + 2 + curH + topIndent - viewport->getMaximumVisibleHeight();
|
||||
}
|
||||
else if (desiredCaretY > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - caretPos.getHeight()))
|
||||
vy += desiredCaretY + 2 + caretPos.getHeight() + topIndent - viewport->getMaximumVisibleHeight();
|
||||
}
|
||||
|
||||
viewport->setViewPosition (vx, vy);
|
||||
|
|
@ -1417,18 +1393,18 @@ void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX,
|
|||
|
||||
const Rectangle<int> TextEditor::getCaretRectangle()
|
||||
{
|
||||
updateCaretPosition();
|
||||
float cursorX, cursorY;
|
||||
float cursorHeight = currentFont.getHeight(); // (in case the text is empty and the call below doesn't set this value)
|
||||
getCharPosition (caretPosition, cursorX, cursorY, cursorHeight);
|
||||
|
||||
return Rectangle<int> (roundToInt (cursorX) - viewport->getX(),
|
||||
roundToInt (cursorY) - viewport->getY(),
|
||||
1, roundToInt (cursorHeight));
|
||||
return Rectangle<int> (roundToInt (cursorX), roundToInt (cursorY), 2, roundToInt (cursorHeight));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
float TextEditor::getWordWrapWidth() const
|
||||
{
|
||||
return (wordWrap) ? (float) (viewport->getMaximumVisibleWidth() - leftIndent - leftIndent / 2)
|
||||
: 1.0e10f;
|
||||
return wordWrap ? (float) (viewport->getMaximumVisibleWidth() - leftIndent - leftIndent / 2)
|
||||
: std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
void TextEditor::updateTextHolderSize()
|
||||
|
|
@ -1448,7 +1424,7 @@ void TextEditor::updateTextHolderSize()
|
|||
const int h = topIndent + roundToInt (jmax (i.lineY + i.lineHeight,
|
||||
currentFont.getHeight()));
|
||||
|
||||
textHolder->setSize (w + 1, h + 1);
|
||||
textHolder->setSize (w + 2, h + 1); // (the +2 allows a bit of space for the cursor to be at the right-hand-edge)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1485,12 +1461,6 @@ void TextEditor::setScrollToShowCursor (const bool shouldScrollToShowCursor)
|
|||
keepCursorOnScreen = shouldScrollToShowCursor;
|
||||
}
|
||||
|
||||
void TextEditor::updateCaretPosition()
|
||||
{
|
||||
cursorHeight = currentFont.getHeight(); // (in case the text is empty and the call below doesn't set this value)
|
||||
getCharPosition (caretPosition, cursorX, cursorY, cursorHeight);
|
||||
}
|
||||
|
||||
void TextEditor::scrollToMakeSureCursorIsVisible()
|
||||
{
|
||||
updateCaretPosition();
|
||||
|
|
@ -1500,8 +1470,10 @@ void TextEditor::scrollToMakeSureCursorIsVisible()
|
|||
int x = viewport->getViewPositionX();
|
||||
int y = viewport->getViewPositionY();
|
||||
|
||||
const int relativeCursorX = roundToInt (cursorX) - x;
|
||||
const int relativeCursorY = roundToInt (cursorY) - y;
|
||||
const Rectangle<int> caretPos (getCaretRectangle());
|
||||
|
||||
const int relativeCursorX = caretPos.getX() - x;
|
||||
const int relativeCursorY = caretPos.getY() - y;
|
||||
|
||||
if (relativeCursorX < jmax (1, proportionOfWidth (0.05f)))
|
||||
{
|
||||
|
|
@ -1520,15 +1492,13 @@ void TextEditor::scrollToMakeSureCursorIsVisible()
|
|||
}
|
||||
else
|
||||
{
|
||||
const int curH = roundToInt (cursorHeight);
|
||||
|
||||
if (relativeCursorY < 0)
|
||||
{
|
||||
y = jmax (0, relativeCursorY + y);
|
||||
}
|
||||
else if (relativeCursorY > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - curH))
|
||||
else if (relativeCursorY > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - caretPos.getHeight()))
|
||||
{
|
||||
y += relativeCursorY + 2 + curH + topIndent - viewport->getMaximumVisibleHeight();
|
||||
y += relativeCursorY + 2 + caretPos.getHeight() + topIndent - viewport->getMaximumVisibleHeight();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1720,18 +1690,6 @@ void TextEditor::paint (Graphics& g)
|
|||
|
||||
void TextEditor::paintOverChildren (Graphics& g)
|
||||
{
|
||||
if (caretFlashState
|
||||
&& hasKeyboardFocus (false)
|
||||
&& caretVisible
|
||||
&& ! isReadOnly())
|
||||
{
|
||||
g.setColour (findColour (caretColourId));
|
||||
|
||||
g.fillRect (borderSize.getLeft() + textHolder->getX() + leftIndent + cursorX,
|
||||
borderSize.getTop() + textHolder->getY() + topIndent + cursorY,
|
||||
2.0f, cursorHeight);
|
||||
}
|
||||
|
||||
if (textToShowWhenEmpty.isNotEmpty()
|
||||
&& (! hasKeyboardFocus (false))
|
||||
&& getTotalNumChars() == 0)
|
||||
|
|
@ -1803,7 +1761,7 @@ void TextEditor::mouseDrag (const MouseEvent& e)
|
|||
void TextEditor::mouseUp (const MouseEvent& e)
|
||||
{
|
||||
newTransaction();
|
||||
textHolder->startTimer (TextEditorDefs::flashSpeedIntervalMs);
|
||||
textHolder->restartTimer();
|
||||
|
||||
if (wasFocused || ! selectAllTextWhenFocused)
|
||||
{
|
||||
|
|
@ -1892,6 +1850,7 @@ bool TextEditor::keyPressed (const KeyPress& key)
|
|||
return false;
|
||||
|
||||
const bool moveInWholeWordSteps = key.getModifiers().isCtrlDown() || key.getModifiers().isAltDown();
|
||||
const Rectangle<float> caretPos (getCaretRectangle().toFloat());
|
||||
|
||||
if (key.isKeyCode (KeyPress::leftKey)
|
||||
|| key.isKeyCode (KeyPress::upKey))
|
||||
|
|
@ -1901,7 +1860,7 @@ bool TextEditor::keyPressed (const KeyPress& key)
|
|||
int newPos;
|
||||
|
||||
if (isMultiLine() && key.isKeyCode (KeyPress::upKey))
|
||||
newPos = indexAtPosition (cursorX, cursorY - 1);
|
||||
newPos = indexAtPosition (caretPos.getX(), caretPos.getY() - 1.0f);
|
||||
else if (moveInWholeWordSteps)
|
||||
newPos = findWordBreakBefore (getCaretPosition());
|
||||
else
|
||||
|
|
@ -1917,7 +1876,7 @@ bool TextEditor::keyPressed (const KeyPress& key)
|
|||
int newPos;
|
||||
|
||||
if (isMultiLine() && key.isKeyCode (KeyPress::downKey))
|
||||
newPos = indexAtPosition (cursorX, cursorY + cursorHeight + 1);
|
||||
newPos = indexAtPosition (caretPos.getX(), caretPos.getBottom() + 1.0f);
|
||||
else if (moveInWholeWordSteps)
|
||||
newPos = findWordBreakAfter (getCaretPosition());
|
||||
else
|
||||
|
|
@ -1929,14 +1888,14 @@ bool TextEditor::keyPressed (const KeyPress& key)
|
|||
{
|
||||
newTransaction();
|
||||
|
||||
moveCursorTo (indexAtPosition (cursorX, cursorY + cursorHeight + viewport->getViewHeight()),
|
||||
moveCursorTo (indexAtPosition (caretPos.getX(), caretPos.getBottom() + viewport->getViewHeight()),
|
||||
key.getModifiers().isShiftDown());
|
||||
}
|
||||
else if (key.isKeyCode (KeyPress::pageUpKey) && isMultiLine())
|
||||
{
|
||||
newTransaction();
|
||||
|
||||
moveCursorTo (indexAtPosition (cursorX, cursorY - viewport->getViewHeight()),
|
||||
moveCursorTo (indexAtPosition (caretPos.getX(), caretPos.getY() - viewport->getViewHeight()),
|
||||
key.getModifiers().isShiftDown());
|
||||
}
|
||||
else if (key.isKeyCode (KeyPress::homeKey))
|
||||
|
|
@ -1944,7 +1903,7 @@ bool TextEditor::keyPressed (const KeyPress& key)
|
|||
newTransaction();
|
||||
|
||||
if (isMultiLine() && ! moveInWholeWordSteps)
|
||||
moveCursorTo (indexAtPosition (0.0f, cursorY),
|
||||
moveCursorTo (indexAtPosition (0.0f, caretPos.getY()),
|
||||
key.getModifiers().isShiftDown());
|
||||
else
|
||||
moveCursorTo (0, key.getModifiers().isShiftDown());
|
||||
|
|
@ -1954,7 +1913,7 @@ bool TextEditor::keyPressed (const KeyPress& key)
|
|||
newTransaction();
|
||||
|
||||
if (isMultiLine() && ! moveInWholeWordSteps)
|
||||
moveCursorTo (indexAtPosition ((float) textHolder->getWidth(), cursorY),
|
||||
moveCursorTo (indexAtPosition ((float) textHolder->getWidth(), caretPos.getY()),
|
||||
key.getModifiers().isShiftDown());
|
||||
else
|
||||
moveCursorTo (getTotalNumChars(), key.getModifiers().isShiftDown());
|
||||
|
|
@ -2131,8 +2090,6 @@ void TextEditor::focusGained (FocusChangeType)
|
|||
{
|
||||
newTransaction();
|
||||
|
||||
caretFlashState = true;
|
||||
|
||||
if (selectAllTextWhenFocused)
|
||||
{
|
||||
moveCursorTo (0, false);
|
||||
|
|
@ -2140,9 +2097,7 @@ void TextEditor::focusGained (FocusChangeType)
|
|||
}
|
||||
|
||||
repaint();
|
||||
|
||||
if (caretVisible)
|
||||
textHolder->startTimer (TextEditorDefs::flashSpeedIntervalMs);
|
||||
updateCaretPosition();
|
||||
|
||||
ComponentPeer* const peer = getPeer();
|
||||
if (peer != 0 && ! isReadOnly())
|
||||
|
|
@ -2155,7 +2110,7 @@ void TextEditor::focusLost (FocusChangeType)
|
|||
|
||||
wasFocused = false;
|
||||
textHolder->stopTimer();
|
||||
caretFlashState = false;
|
||||
updateCaretPosition();
|
||||
|
||||
postCommandMessage (TextEditorDefs::focusLossMessageId);
|
||||
repaint();
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include "../menus/juce_PopupMenu.h"
|
||||
#include "../../../containers/juce_Value.h"
|
||||
#include "../keyboard/juce_TextInputTarget.h"
|
||||
#include "../keyboard/juce_CaretComponent.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -133,9 +134,7 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Makes the caret visible or invisible.
|
||||
|
||||
By default the caret is visible.
|
||||
|
||||
@see setCaretColour, setCaretPosition
|
||||
*/
|
||||
void setCaretVisible (bool shouldBeVisible);
|
||||
|
|
@ -143,7 +142,7 @@ public:
|
|||
/** Returns true if the caret is enabled.
|
||||
@see setCaretVisible
|
||||
*/
|
||||
bool isCaretVisible() const { return caretVisible; }
|
||||
bool isCaretVisible() const { return caret != 0; }
|
||||
|
||||
//==============================================================================
|
||||
/** Enables/disables a vertical scrollbar.
|
||||
|
|
@ -222,8 +221,6 @@ public:
|
|||
|
||||
highlightedTextColourId = 0x1000203, /**< The colour with which to draw the text in highlighted sections. */
|
||||
|
||||
caretColourId = 0x1000204, /**< The colour with which to draw the caret. */
|
||||
|
||||
outlineColourId = 0x1000205, /**< If this is non-transparent, it will be used to draw a box around
|
||||
the edge of the component. */
|
||||
|
||||
|
|
@ -622,19 +619,17 @@ private:
|
|||
bool multiline : 1;
|
||||
bool wordWrap : 1;
|
||||
bool returnKeyStartsNewLine : 1;
|
||||
bool caretVisible : 1;
|
||||
bool popupMenuEnabled : 1;
|
||||
bool selectAllTextWhenFocused : 1;
|
||||
bool scrollbarVisible : 1;
|
||||
bool wasFocused : 1;
|
||||
bool caretFlashState : 1;
|
||||
bool keepCursorOnScreen : 1;
|
||||
bool tabKeyUsed : 1;
|
||||
bool menuActive : 1;
|
||||
bool valueTextNeedsUpdating : 1;
|
||||
|
||||
UndoManager undoManager;
|
||||
float cursorX, cursorY, cursorHeight;
|
||||
ScopedPointer<CaretComponent> caret;
|
||||
int maxTextLength;
|
||||
Range<int> selection;
|
||||
int leftIndent, topIndent;
|
||||
|
|
@ -678,7 +673,6 @@ private:
|
|||
void updateTextHolderSize();
|
||||
float getWordWrapWidth() const;
|
||||
void timerCallbackInt();
|
||||
void repaintCaret();
|
||||
void repaintText (const Range<int>& range);
|
||||
UndoManager* getUndoManager() throw();
|
||||
|
||||
|
|
|
|||
69
src/gui/components/keyboard/juce_CaretComponent.cpp
Normal file
69
src/gui/components/keyboard/juce_CaretComponent.cpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library - "Jules' Utility Class Extensions"
|
||||
Copyright 2004-11 by Raw Material Software Ltd.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
JUCE can be redistributed and/or modified under the terms of the GNU General
|
||||
Public License (Version 2), as published by the Free Software Foundation.
|
||||
A copy of the license is included in the JUCE distribution, or can be found
|
||||
online at www.gnu.org/licenses.
|
||||
|
||||
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses JUCE, commercial licenses are
|
||||
available: visit www.rawmaterialsoftware.com/juce for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#include "../../../core/juce_StandardHeader.h"
|
||||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
#include "juce_CaretComponent.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
CaretComponent::CaretComponent (Component* const keyFocusOwner)
|
||||
: owner (keyFocusOwner)
|
||||
{
|
||||
setAlwaysOnTop (true);
|
||||
setInterceptsMouseClicks (false, false);
|
||||
}
|
||||
|
||||
CaretComponent::~CaretComponent()
|
||||
{
|
||||
}
|
||||
|
||||
void CaretComponent::paint (Graphics& g)
|
||||
{
|
||||
g.fillAll (findColour (caretColourId));
|
||||
}
|
||||
|
||||
void CaretComponent::timerCallback()
|
||||
{
|
||||
setVisible (shouldBeShown() && ! isVisible());
|
||||
}
|
||||
|
||||
void CaretComponent::setCaretPosition (const Rectangle<int>& characterArea)
|
||||
{
|
||||
startTimer (380);
|
||||
setVisible (shouldBeShown());
|
||||
setBounds (characterArea.withWidth (2));
|
||||
}
|
||||
|
||||
bool CaretComponent::shouldBeShown() const
|
||||
{
|
||||
return owner == 0 || (owner->hasKeyboardFocus (true)
|
||||
&& ! owner->isCurrentlyBlockedByAnotherModalComponent());
|
||||
}
|
||||
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
84
src/gui/components/keyboard/juce_CaretComponent.h
Normal file
84
src/gui/components/keyboard/juce_CaretComponent.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library - "Jules' Utility Class Extensions"
|
||||
Copyright 2004-11 by Raw Material Software Ltd.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
JUCE can be redistributed and/or modified under the terms of the GNU General
|
||||
Public License (Version 2), as published by the Free Software Foundation.
|
||||
A copy of the license is included in the JUCE distribution, or can be found
|
||||
online at www.gnu.org/licenses.
|
||||
|
||||
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses JUCE, commercial licenses are
|
||||
available: visit www.rawmaterialsoftware.com/juce for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef __JUCE_CARETCOMPONENT_JUCEHEADER__
|
||||
#define __JUCE_CARETCOMPONENT_JUCEHEADER__
|
||||
|
||||
#include "../juce_Component.h"
|
||||
#include "../../../events/juce_Timer.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
*/
|
||||
class JUCE_API CaretComponent : public Component,
|
||||
public Timer
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Creates the caret component.
|
||||
The keyFocusOwner is an optional component which the caret will check, making
|
||||
itself visible only when the keyFocusOwner has keyboard focus.
|
||||
*/
|
||||
CaretComponent (Component* keyFocusOwner);
|
||||
|
||||
/** Destructor. */
|
||||
~CaretComponent();
|
||||
|
||||
//==============================================================================
|
||||
/** Sets the caret's position to place it next to the given character.
|
||||
The area is the rectangle containing the entire character that the caret is
|
||||
positioned on, so by default a vertical-line caret may choose to just show itself
|
||||
at the left of this area. You can override this method to customise its size.
|
||||
This method will also force the caret to reset its timer and become visible (if
|
||||
appropriate), so that as it moves, you can see where it is.
|
||||
*/
|
||||
virtual void setCaretPosition (const Rectangle<int>& characterArea);
|
||||
|
||||
/** A set of colour IDs to use to change the colour of various aspects of the caret.
|
||||
These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
|
||||
methods.
|
||||
@see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
|
||||
*/
|
||||
enum ColourIds
|
||||
{
|
||||
caretColourId = 0x1000204, /**< The colour with which to draw the caret. */
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paint (Graphics& g);
|
||||
/** @internal */
|
||||
void timerCallback();
|
||||
|
||||
private:
|
||||
Component* owner;
|
||||
bool shouldBeShown() const;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (CaretComponent);
|
||||
};
|
||||
|
||||
|
||||
#endif // __JUCE_CARETCOMPONENT_JUCEHEADER__
|
||||
|
|
@ -52,6 +52,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "../controls/juce_ProgressBar.h"
|
||||
#include "../controls/juce_TreeView.h"
|
||||
#include "../keyboard/juce_KeyMappingEditorComponent.h"
|
||||
#include "../keyboard/juce_CaretComponent.h"
|
||||
#include "../code_editor/juce_CodeEditorComponent.h"
|
||||
#include "../filebrowser/juce_FilenameComponent.h"
|
||||
#include "../filebrowser/juce_DirectoryContentsDisplayComponent.h"
|
||||
|
|
@ -191,11 +192,12 @@ LookAndFeel::LookAndFeel()
|
|||
TextEditor::textColourId, 0xff000000,
|
||||
TextEditor::highlightColourId, textHighlightColour,
|
||||
TextEditor::highlightedTextColourId, 0xff000000,
|
||||
TextEditor::caretColourId, 0xff000000,
|
||||
TextEditor::outlineColourId, 0x00000000,
|
||||
TextEditor::focusedOutlineColourId, textButtonColour,
|
||||
TextEditor::shadowColourId, 0x38000000,
|
||||
|
||||
CaretComponent::caretColourId, 0xff000000,
|
||||
|
||||
Label::backgroundColourId, 0x00000000,
|
||||
Label::textColourId, 0xff000000,
|
||||
Label::outlineColourId, 0x00000000,
|
||||
|
|
@ -278,7 +280,6 @@ LookAndFeel::LookAndFeel()
|
|||
MidiKeyboardComponent::upDownButtonArrowColourId, 0xff000000,
|
||||
|
||||
CodeEditorComponent::backgroundColourId, 0xffffffff,
|
||||
CodeEditorComponent::caretColourId, 0xff000000,
|
||||
CodeEditorComponent::highlightColourId, textHighlightColour,
|
||||
CodeEditorComponent::defaultTextColourId, 0xff000000,
|
||||
|
||||
|
|
@ -1325,6 +1326,11 @@ void LookAndFeel::drawTextEditorOutline (Graphics& g, int width, int height, Tex
|
|||
}
|
||||
}
|
||||
|
||||
CaretComponent* LookAndFeel::createCaretComponent (Component* keyFocusOwner)
|
||||
{
|
||||
return new CaretComponent (keyFocusOwner);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void LookAndFeel::drawComboBox (Graphics& g, int width, int height,
|
||||
const bool isButtonDown,
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ class FilePreviewComponent;
|
|||
class ImageButton;
|
||||
class CallOutBox;
|
||||
class Drawable;
|
||||
class CaretComponent;
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
|
|
@ -294,6 +295,8 @@ public:
|
|||
virtual void fillTextEditorBackground (Graphics& g, int width, int height, TextEditor& textEditor);
|
||||
virtual void drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor);
|
||||
|
||||
virtual CaretComponent* createCaretComponent (Component* keyFocusOwner);
|
||||
|
||||
//==============================================================================
|
||||
// These return a pointer to an internally cached drawable - make sure you don't keep
|
||||
// a copy of this pointer anywhere, as it may become invalid in the future.
|
||||
|
|
|
|||
|
|
@ -401,6 +401,9 @@
|
|||
#ifndef __JUCE_MODALCOMPONENTMANAGER_JUCEHEADER__
|
||||
#include "gui/components/juce_ModalComponentManager.h"
|
||||
#endif
|
||||
#ifndef __JUCE_CARETCOMPONENT_JUCEHEADER__
|
||||
#include "gui/components/keyboard/juce_CaretComponent.h"
|
||||
#endif
|
||||
#ifndef __JUCE_KEYBOARDFOCUSTRAVERSER_JUCEHEADER__
|
||||
#include "gui/components/keyboard/juce_KeyboardFocusTraverser.h"
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue