Browse Source

New class: CaretComponent, which is created by the LookAndFeel. Fix for VST build on VC2005.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
e1e5018a91
25 changed files with 586 additions and 522 deletions
  1. +6
    -0
      Builds/Linux/Makefile
  2. +6
    -0
      Builds/MacOSX/Juce.xcodeproj/project.pbxproj
  3. +2
    -0
      Builds/VisualStudio2005/Juce.vcproj
  4. +2
    -0
      Builds/VisualStudio2008/Juce.vcproj
  5. +2
    -0
      Builds/VisualStudio2008_DLL/Juce.vcproj
  6. +2
    -0
      Builds/VisualStudio2010/Juce.vcxproj
  7. +6
    -0
      Builds/VisualStudio2010/Juce.vcxproj.filters
  8. +6
    -0
      Builds/iOS/Juce.xcodeproj/project.pbxproj
  9. +4
    -0
      Juce.jucer
  10. +1
    -0
      amalgamation/juce_amalgamated_template.cpp
  11. +17
    -0
      extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp
  12. +1
    -1
      extras/the jucer/src/model/components/jucer_TextEditorHandler.h
  13. +223
    -346
      juce_amalgamated.cpp
  14. +65
    -13
      juce_amalgamated.h
  15. +1
    -1
      src/core/juce_StandardHeader.h
  16. +13
    -46
      src/gui/components/code_editor/juce_CodeEditorComponent.cpp
  17. +2
    -3
      src/gui/components/code_editor/juce_CodeEditorComponent.h
  18. +3
    -2
      src/gui/components/controls/juce_Label.cpp
  19. +54
    -99
      src/gui/components/controls/juce_TextEditor.cpp
  20. +3
    -9
      src/gui/components/controls/juce_TextEditor.h
  21. +69
    -0
      src/gui/components/keyboard/juce_CaretComponent.cpp
  22. +84
    -0
      src/gui/components/keyboard/juce_CaretComponent.h
  23. +8
    -2
      src/gui/components/lookandfeel/juce_LookAndFeel.cpp
  24. +3
    -0
      src/gui/components/lookandfeel/juce_LookAndFeel.h
  25. +3
    -0
      src/juce_app_includes.h

+ 6
- 0
Builds/Linux/Makefile View File

@@ -163,6 +163,7 @@ OBJECTS := \
$(OBJDIR)/juce_FileTreeComponent_8cb2d3a3.o \ $(OBJDIR)/juce_FileTreeComponent_8cb2d3a3.o \
$(OBJDIR)/juce_ImagePreviewComponent_a108ea50.o \ $(OBJDIR)/juce_ImagePreviewComponent_a108ea50.o \
$(OBJDIR)/juce_WildcardFileFilter_9337b18.o \ $(OBJDIR)/juce_WildcardFileFilter_9337b18.o \
$(OBJDIR)/juce_CaretComponent_26bf4433.o \
$(OBJDIR)/juce_KeyboardFocusTraverser_6325fc08.o \ $(OBJDIR)/juce_KeyboardFocusTraverser_6325fc08.o \
$(OBJDIR)/juce_KeyListener_631ada24.o \ $(OBJDIR)/juce_KeyListener_631ada24.o \
$(OBJDIR)/juce_KeyMappingEditorComponent_a0183a92.o \ $(OBJDIR)/juce_KeyMappingEditorComponent_a0183a92.o \
@@ -1002,6 +1003,11 @@ $(OBJDIR)/juce_WildcardFileFilter_9337b18.o: ../../src/gui/components/filebrowse
@echo "Compiling juce_WildcardFileFilter.cpp" @echo "Compiling juce_WildcardFileFilter.cpp"
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<" @$(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 $(OBJDIR)/juce_KeyboardFocusTraverser_6325fc08.o: ../../src/gui/components/keyboard/juce_KeyboardFocusTraverser.cpp
-@mkdir -p $(OBJDIR) -@mkdir -p $(OBJDIR)
@echo "Compiling juce_KeyboardFocusTraverser.cpp" @echo "Compiling juce_KeyboardFocusTraverser.cpp"


+ 6
- 0
Builds/MacOSX/Juce.xcodeproj/project.pbxproj View File

@@ -132,6 +132,7 @@
0D91D36C2195315FE534F304 = { isa = PBXBuildFile; fileRef = A418FC3BDDBF1CE9F2903490; }; 0D91D36C2195315FE534F304 = { isa = PBXBuildFile; fileRef = A418FC3BDDBF1CE9F2903490; };
A1E82F70796B8611D7323247 = { isa = PBXBuildFile; fileRef = 949854EDE6B5B16CEFB6108F; }; A1E82F70796B8611D7323247 = { isa = PBXBuildFile; fileRef = 949854EDE6B5B16CEFB6108F; };
BC1856E0B20406DDCE5EBF94 = { isa = PBXBuildFile; fileRef = 8A67B45A2BA1D19D1AC43315; }; BC1856E0B20406DDCE5EBF94 = { isa = PBXBuildFile; fileRef = 8A67B45A2BA1D19D1AC43315; };
FF3A28F88174E10CB478931E = { isa = PBXBuildFile; fileRef = 912C419859C9C56BC96AA6FB; };
C39AE37828718E9A45589A24 = { isa = PBXBuildFile; fileRef = 5ABC6616473BA4791AA8101E; }; C39AE37828718E9A45589A24 = { isa = PBXBuildFile; fileRef = 5ABC6616473BA4791AA8101E; };
4400B0595B35F919291C1A01 = { isa = PBXBuildFile; fileRef = 29A79478AE8567250972ED43; }; 4400B0595B35F919291C1A01 = { isa = PBXBuildFile; fileRef = 29A79478AE8567250972ED43; };
BB1DAC0CA8D7B3DEEDEE76C6 = { isa = PBXBuildFile; fileRef = 7F5A271EAB78C7CF8B2341DE; }; 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; }; 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; }; 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; }; 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; }; 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; }; 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; }; 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, 8A67B45A2BA1D19D1AC43315,
ECDD0F8397F3EE4E7FA7ACCC ); name = filebrowser; sourceTree = "<group>"; }; ECDD0F8397F3EE4E7FA7ACCC ); name = filebrowser; sourceTree = "<group>"; };
558A664D5D1ECEC607F4775D = { isa = PBXGroup; children = ( 558A664D5D1ECEC607F4775D = { isa = PBXGroup; children = (
912C419859C9C56BC96AA6FB,
717295136FD426125079F78C,
5ABC6616473BA4791AA8101E, 5ABC6616473BA4791AA8101E,
F61C34EE417006881D0869F4, F61C34EE417006881D0869F4,
29A79478AE8567250972ED43, 29A79478AE8567250972ED43,
@@ -2149,6 +2154,7 @@
0D91D36C2195315FE534F304, 0D91D36C2195315FE534F304,
A1E82F70796B8611D7323247, A1E82F70796B8611D7323247,
BC1856E0B20406DDCE5EBF94, BC1856E0B20406DDCE5EBF94,
FF3A28F88174E10CB478931E,
C39AE37828718E9A45589A24, C39AE37828718E9A45589A24,
4400B0595B35F919291C1A01, 4400B0595B35F919291C1A01,
BB1DAC0CA8D7B3DEEDEE76C6, BB1DAC0CA8D7B3DEEDEE76C6,


+ 2
- 0
Builds/VisualStudio2005/Juce.vcproj View File

@@ -525,6 +525,8 @@
<File RelativePath="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h"/> <File RelativePath="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h"/>
</Filter> </Filter>
<Filter Name="keyboard"> <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.cpp"/>
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h"/> <File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h"/>
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/> <File RelativePath="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/>


+ 2
- 0
Builds/VisualStudio2008/Juce.vcproj View File

@@ -525,6 +525,8 @@
<File RelativePath="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h"/> <File RelativePath="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h"/>
</Filter> </Filter>
<Filter Name="keyboard"> <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.cpp"/>
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h"/> <File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h"/>
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/> <File RelativePath="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/>


+ 2
- 0
Builds/VisualStudio2008_DLL/Juce.vcproj View File

@@ -527,6 +527,8 @@
<File RelativePath="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h"/> <File RelativePath="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h"/>
</Filter> </Filter>
<Filter Name="keyboard"> <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.cpp"/>
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h"/> <File RelativePath="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h"/>
<File RelativePath="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/> <File RelativePath="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/>


+ 2
- 0
Builds/VisualStudio2010/Juce.vcxproj View File

@@ -246,6 +246,7 @@
<ClCompile Include="..\..\src\gui\components\filebrowser\juce_FileTreeComponent.cpp"/> <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_ImagePreviewComponent.cpp"/>
<ClCompile Include="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.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_KeyboardFocusTraverser.cpp"/>
<ClCompile Include="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/> <ClCompile Include="..\..\src\gui\components\keyboard\juce_KeyListener.cpp"/>
<ClCompile Include="..\..\src\gui\components\keyboard\juce_KeyMappingEditorComponent.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_FileTreeComponent.h"/>
<ClInclude Include="..\..\src\gui\components\filebrowser\juce_ImagePreviewComponent.h"/> <ClInclude Include="..\..\src\gui\components\filebrowser\juce_ImagePreviewComponent.h"/>
<ClInclude Include="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.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_KeyboardFocusTraverser.h"/>
<ClInclude Include="..\..\src\gui\components\keyboard\juce_KeyListener.h"/> <ClInclude Include="..\..\src\gui\components\keyboard\juce_KeyListener.h"/>
<ClInclude Include="..\..\src\gui\components\keyboard\juce_KeyMappingEditorComponent.h"/> <ClInclude Include="..\..\src\gui\components\keyboard\juce_KeyMappingEditorComponent.h"/>


+ 6
- 0
Builds/VisualStudio2010/Juce.vcxproj.filters View File

@@ -598,6 +598,9 @@
<ClCompile Include="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.cpp"> <ClCompile Include="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.cpp">
<Filter>Juce\Source\gui\components\filebrowser</Filter> <Filter>Juce\Source\gui\components\filebrowser</Filter>
</ClCompile> </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"> <ClCompile Include="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.cpp">
<Filter>Juce\Source\gui\components\keyboard</Filter> <Filter>Juce\Source\gui\components\keyboard</Filter>
</ClCompile> </ClCompile>
@@ -1782,6 +1785,9 @@
<ClInclude Include="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h"> <ClInclude Include="..\..\src\gui\components\filebrowser\juce_WildcardFileFilter.h">
<Filter>Juce\Source\gui\components\filebrowser</Filter> <Filter>Juce\Source\gui\components\filebrowser</Filter>
</ClInclude> </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"> <ClInclude Include="..\..\src\gui\components\keyboard\juce_KeyboardFocusTraverser.h">
<Filter>Juce\Source\gui\components\keyboard</Filter> <Filter>Juce\Source\gui\components\keyboard</Filter>
</ClInclude> </ClInclude>


+ 6
- 0
Builds/iOS/Juce.xcodeproj/project.pbxproj View File

@@ -132,6 +132,7 @@
0D91D36C2195315FE534F304 = { isa = PBXBuildFile; fileRef = A418FC3BDDBF1CE9F2903490; }; 0D91D36C2195315FE534F304 = { isa = PBXBuildFile; fileRef = A418FC3BDDBF1CE9F2903490; };
A1E82F70796B8611D7323247 = { isa = PBXBuildFile; fileRef = 949854EDE6B5B16CEFB6108F; }; A1E82F70796B8611D7323247 = { isa = PBXBuildFile; fileRef = 949854EDE6B5B16CEFB6108F; };
BC1856E0B20406DDCE5EBF94 = { isa = PBXBuildFile; fileRef = 8A67B45A2BA1D19D1AC43315; }; BC1856E0B20406DDCE5EBF94 = { isa = PBXBuildFile; fileRef = 8A67B45A2BA1D19D1AC43315; };
FF3A28F88174E10CB478931E = { isa = PBXBuildFile; fileRef = 912C419859C9C56BC96AA6FB; };
C39AE37828718E9A45589A24 = { isa = PBXBuildFile; fileRef = 5ABC6616473BA4791AA8101E; }; C39AE37828718E9A45589A24 = { isa = PBXBuildFile; fileRef = 5ABC6616473BA4791AA8101E; };
4400B0595B35F919291C1A01 = { isa = PBXBuildFile; fileRef = 29A79478AE8567250972ED43; }; 4400B0595B35F919291C1A01 = { isa = PBXBuildFile; fileRef = 29A79478AE8567250972ED43; };
BB1DAC0CA8D7B3DEEDEE76C6 = { isa = PBXBuildFile; fileRef = 7F5A271EAB78C7CF8B2341DE; }; 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; }; 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; }; 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; }; 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; }; 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; }; 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; }; 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, 8A67B45A2BA1D19D1AC43315,
ECDD0F8397F3EE4E7FA7ACCC ); name = filebrowser; sourceTree = "<group>"; }; ECDD0F8397F3EE4E7FA7ACCC ); name = filebrowser; sourceTree = "<group>"; };
558A664D5D1ECEC607F4775D = { isa = PBXGroup; children = ( 558A664D5D1ECEC607F4775D = { isa = PBXGroup; children = (
912C419859C9C56BC96AA6FB,
717295136FD426125079F78C,
5ABC6616473BA4791AA8101E, 5ABC6616473BA4791AA8101E,
F61C34EE417006881D0869F4, F61C34EE417006881D0869F4,
29A79478AE8567250972ED43, 29A79478AE8567250972ED43,
@@ -2153,6 +2158,7 @@
0D91D36C2195315FE534F304, 0D91D36C2195315FE534F304,
A1E82F70796B8611D7323247, A1E82F70796B8611D7323247,
BC1856E0B20406DDCE5EBF94, BC1856E0B20406DDCE5EBF94,
FF3A28F88174E10CB478931E,
C39AE37828718E9A45589A24, C39AE37828718E9A45589A24,
4400B0595B35F919291C1A01, 4400B0595B35F919291C1A01,
BB1DAC0CA8D7B3DEEDEE76C6, BB1DAC0CA8D7B3DEEDEE76C6,


+ 4
- 0
Juce.jucer View File

@@ -683,6 +683,10 @@
file="src/gui/components/filebrowser/juce_WildcardFileFilter.h"/> file="src/gui/components/filebrowser/juce_WildcardFileFilter.h"/>
</GROUP> </GROUP>
<GROUP id="PAM9sn3Rp" name="keyboard"> <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" <FILE id="mUtddLtZX" name="juce_KeyboardFocusTraverser.cpp" compile="1"
resource="0" file="src/gui/components/keyboard/juce_KeyboardFocusTraverser.cpp"/> resource="0" file="src/gui/components/keyboard/juce_KeyboardFocusTraverser.cpp"/>
<FILE id="edrEUIDT" name="juce_KeyboardFocusTraverser.h" compile="0" <FILE id="edrEUIDT" name="juce_KeyboardFocusTraverser.h" compile="0"


+ 1
- 0
amalgamation/juce_amalgamated_template.cpp View File

@@ -274,6 +274,7 @@
#include "../src/gui/components/keyboard/juce_KeyPress.cpp" #include "../src/gui/components/keyboard/juce_KeyPress.cpp"
#include "../src/gui/components/keyboard/juce_KeyPressMappingSet.cpp" #include "../src/gui/components/keyboard/juce_KeyPressMappingSet.cpp"
#include "../src/gui/components/keyboard/juce_ModifierKeys.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_ComponentAnimator.cpp"
#include "../src/gui/components/layout/juce_ComponentBuilder.cpp" #include "../src/gui/components/layout/juce_ComponentBuilder.cpp"
#include "../src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp" #include "../src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp"


+ 17
- 0
extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp View File

@@ -210,6 +210,19 @@ namespace
LRESULT CALLBACK mouseWheelHookCallback (int nCode, WPARAM wParam, LPARAM lParam) 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) if (nCode >= 0 && wParam == WM_MOUSEWHEEL)
{ {
const MSLLHOOKSTRUCT& hs = *(MSLLHOOKSTRUCT*) lParam; const MSLLHOOKSTRUCT& hs = *(MSLLHOOKSTRUCT*) lParam;
@@ -226,6 +239,10 @@ namespace
void registerMouseWheelHook() void registerMouseWheelHook()
{ {
#ifndef WH_MOUSE_LL
#define WH_MOUSE_LL 14
#endif
if (mouseHookUsers++ == 0) if (mouseHookUsers++ == 0)
mouseWheelHook = SetWindowsHookEx (WH_MOUSE_LL, mouseWheelHookCallback, mouseWheelHook = SetWindowsHookEx (WH_MOUSE_LL, mouseWheelHookCallback,
(HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(), 0); (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(), 0);


+ 1
- 1
extras/the jucer/src/model/components/jucer_TextEditorHandler.h View File

@@ -42,7 +42,7 @@ public:
registerColour (TextEditor::highlightColourId, "highlight", "hilitecol"); registerColour (TextEditor::highlightColourId, "highlight", "hilitecol");
registerColour (TextEditor::outlineColourId, "outline", "outlinecol"); registerColour (TextEditor::outlineColourId, "outline", "outlinecol");
registerColour (TextEditor::shadowColourId, "shadow", "shadowcol"); registerColour (TextEditor::shadowColourId, "shadow", "shadowcol");
registerColour (TextEditor::caretColourId, "caret", "caretcol");
registerColour (CaretComponent::caretColourId, "caret", "caretcol");
} }
//============================================================================== //==============================================================================


+ 223
- 346
juce_amalgamated.cpp
File diff suppressed because it is too large
View File


+ 65
- 13
juce_amalgamated.h View File

@@ -73,7 +73,7 @@ namespace JuceDummyNamespace {}
*/ */
#define JUCE_MAJOR_VERSION 1 #define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53 #define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 55
#define JUCE_BUILDNUMBER 56


/** Current Juce version number. /** Current Juce version number.


@@ -41819,6 +41819,61 @@ public:
#endif // __JUCE_TEXTINPUTTARGET_JUCEHEADER__ #endif // __JUCE_TEXTINPUTTARGET_JUCEHEADER__
/*** End of inlined file: juce_TextInputTarget.h ***/ /*** 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. A component containing text that can be edited.


@@ -41910,9 +41965,7 @@ public:
bool isReadOnly() const; bool isReadOnly() const;


/** Makes the caret visible or invisible. /** Makes the caret visible or invisible.

By default the caret is visible. By default the caret is visible.

@see setCaretColour, setCaretPosition @see setCaretColour, setCaretPosition
*/ */
void setCaretVisible (bool shouldBeVisible); void setCaretVisible (bool shouldBeVisible);
@@ -41920,7 +41973,7 @@ public:
/** Returns true if the caret is enabled. /** Returns true if the caret is enabled.
@see setCaretVisible @see setCaretVisible
*/ */
bool isCaretVisible() const { return caretVisible; }
bool isCaretVisible() const { return caret != 0; }


/** Enables/disables a vertical scrollbar. /** Enables/disables a vertical scrollbar.


@@ -41994,8 +42047,6 @@ public:


highlightedTextColourId = 0x1000203, /**< The colour with which to draw the text in highlighted sections. */ 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 outlineColourId = 0x1000205, /**< If this is non-transparent, it will be used to draw a box around
the edge of the component. */ the edge of the component. */


@@ -42385,19 +42436,17 @@ private:
bool multiline : 1; bool multiline : 1;
bool wordWrap : 1; bool wordWrap : 1;
bool returnKeyStartsNewLine : 1; bool returnKeyStartsNewLine : 1;
bool caretVisible : 1;
bool popupMenuEnabled : 1; bool popupMenuEnabled : 1;
bool selectAllTextWhenFocused : 1; bool selectAllTextWhenFocused : 1;
bool scrollbarVisible : 1; bool scrollbarVisible : 1;
bool wasFocused : 1; bool wasFocused : 1;
bool caretFlashState : 1;
bool keepCursorOnScreen : 1; bool keepCursorOnScreen : 1;
bool tabKeyUsed : 1; bool tabKeyUsed : 1;
bool menuActive : 1; bool menuActive : 1;
bool valueTextNeedsUpdating : 1; bool valueTextNeedsUpdating : 1;


UndoManager undoManager; UndoManager undoManager;
float cursorX, cursorY, cursorHeight;
ScopedPointer<CaretComponent> caret;
int maxTextLength; int maxTextLength;
Range<int> selection; Range<int> selection;
int leftIndent, topIndent; int leftIndent, topIndent;
@@ -42441,7 +42490,6 @@ private:
void updateTextHolderSize(); void updateTextHolderSize();
float getWordWrapWidth() const; float getWordWrapWidth() const;
void timerCallbackInt(); void timerCallbackInt();
void repaintCaret();
void repaintText (const Range<int>& range); void repaintText (const Range<int>& range);
UndoManager* getUndoManager() throw(); UndoManager* getUndoManager() throw();


@@ -51637,7 +51685,6 @@ public:
enum ColourIds enum ColourIds
{ {
backgroundColourId = 0x1004500, /**< A colour to use to fill the editor's background. */ 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 highlightColourId = 0x1004502, /**< The colour to use for the highlighted background under
selected text. */ selected text. */
defaultTextColourId = 0x1004503 /**< The colour to use for text when no syntax colouring is defaultTextColourId = 0x1004503 /**< The colour to use for text when no syntax colouring is
@@ -51697,8 +51744,6 @@ private:
CodeDocument::Position caretPos; CodeDocument::Position caretPos;
CodeDocument::Position selectionStart, selectionEnd; CodeDocument::Position selectionStart, selectionEnd;


class CaretComponent;
friend class ScopedPointer <CaretComponent>;
ScopedPointer<CaretComponent> caret; ScopedPointer<CaretComponent> caret;
ScrollBar verticalScrollBar, horizontalScrollBar; ScrollBar verticalScrollBar, horizontalScrollBar;


@@ -51724,6 +51769,7 @@ private:
void getIteratorForPosition (int position, CodeDocument::Iterator& result); void getIteratorForPosition (int position, CodeDocument::Iterator& result);
void moveLineDelta (int delta, bool selecting); void moveLineDelta (int delta, bool selecting);


void updateCaretPosition();
void updateScrollBars(); void updateScrollBars();
void scrollToLineInternal (int line); void scrollToLineInternal (int line);
void scrollToColumnInternal (double column); void scrollToColumnInternal (double column);
@@ -57710,6 +57756,9 @@ private:
#endif #endif
#ifndef __JUCE_MODALCOMPONENTMANAGER_JUCEHEADER__ #ifndef __JUCE_MODALCOMPONENTMANAGER_JUCEHEADER__


#endif
#ifndef __JUCE_CARETCOMPONENT_JUCEHEADER__

#endif #endif
#ifndef __JUCE_KEYBOARDFOCUSTRAVERSER_JUCEHEADER__ #ifndef __JUCE_KEYBOARDFOCUSTRAVERSER_JUCEHEADER__


@@ -59878,6 +59927,7 @@ class FilePreviewComponent;
class ImageButton; class ImageButton;
class CallOutBox; class CallOutBox;
class Drawable; class Drawable;
class CaretComponent;


/** /**
LookAndFeel objects define the appearance of all the JUCE widgets, and subclasses 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 fillTextEditorBackground (Graphics& g, int width, int height, TextEditor& textEditor);
virtual void drawTextEditorOutline (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 // 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. // a copy of this pointer anywhere, as it may become invalid in the future.
virtual const Drawable* getDefaultFolderImage(); virtual const Drawable* getDefaultFolderImage();


+ 1
- 1
src/core/juce_StandardHeader.h View File

@@ -33,7 +33,7 @@
*/ */
#define JUCE_MAJOR_VERSION 1 #define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53 #define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 55
#define JUCE_BUILDNUMBER 56
/** Current Juce version number. /** Current Juce version number.


+ 13
- 46
src/gui/components/code_editor/juce_CodeEditorComponent.cpp View File

@@ -32,44 +32,6 @@ BEGIN_JUCE_NAMESPACE
#include "../../../utilities/juce_SystemClipboard.h" #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 class CodeEditorComponent::CodeEditorLine
{ {
@@ -311,7 +273,7 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& document_,
addAndMakeVisible (&horizontalScrollBar); addAndMakeVisible (&horizontalScrollBar);
horizontalScrollBar.setSingleStepSize (1.0); horizontalScrollBar.setSingleStepSize (1.0);
addAndMakeVisible (caret = new CaretComponent (*this));
addAndMakeVisible (caret = getLookAndFeel().createCaretComponent (this));
Font f (12.0f); Font f (12.0f);
f.setTypefaceName (Font::getDefaultMonospacedFontName()); f.setTypefaceName (Font::getDefaultMonospacedFontName());
@@ -354,7 +316,7 @@ void CodeEditorComponent::codeDocumentChanged (const CodeDocument::Position& aff
triggerAsyncUpdate(); triggerAsyncUpdate();
caret->updatePosition();
updateCaretPosition();
columnToTryToMaintain = -1; columnToTryToMaintain = -1;
if (affectedTextEnd.getPosition() >= selectionStart.getPosition() if (affectedTextEnd.getPosition() >= selectionStart.getPosition()
@@ -374,7 +336,7 @@ void CodeEditorComponent::resized()
columnsOnScreen = (int) ((getWidth() - scrollbarThickness) / charWidth); columnsOnScreen = (int) ((getWidth() - scrollbarThickness) / charWidth);
lines.clear(); lines.clear();
rebuildLineTokens(); rebuildLineTokens();
caret->updatePosition();
updateCaretPosition();
verticalScrollBar.setBounds (getWidth() - scrollbarThickness, 0, scrollbarThickness, getHeight() - scrollbarThickness); verticalScrollBar.setBounds (getWidth() - scrollbarThickness, 0, scrollbarThickness, getHeight() - scrollbarThickness);
horizontalScrollBar.setBounds (gutter, getHeight() - scrollbarThickness, getWidth() - scrollbarThickness - gutter, 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) void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, const bool highlighting)
{ {
caretPos = newPos; caretPos = newPos;
@@ -517,7 +484,7 @@ void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, con
deselectAll(); deselectAll();
} }
caret->updatePosition();
updateCaretPosition();
scrollToKeepCaretOnScreen(); scrollToKeepCaretOnScreen();
updateScrollBars(); updateScrollBars();
} }
@@ -548,7 +515,7 @@ void CodeEditorComponent::scrollToLineInternal (int newFirstLineOnScreen)
if (newFirstLineOnScreen != firstLineOnScreen) if (newFirstLineOnScreen != firstLineOnScreen)
{ {
firstLineOnScreen = newFirstLineOnScreen; firstLineOnScreen = newFirstLineOnScreen;
caret->updatePosition();
updateCaretPosition();
updateCachedIterators (firstLineOnScreen); updateCachedIterators (firstLineOnScreen);
triggerAsyncUpdate(); triggerAsyncUpdate();
@@ -562,7 +529,7 @@ void CodeEditorComponent::scrollToColumnInternal (double column)
if (xOffset != newOffset) if (xOffset != newOffset)
{ {
xOffset = newOffset; xOffset = newOffset;
caret->updatePosition();
updateCaretPosition();
repaint(); repaint();
} }
} }
@@ -1104,12 +1071,12 @@ void CodeEditorComponent::scrollBarMoved (ScrollBar* scrollBarThatHasMoved, doub
//============================================================================== //==============================================================================
void CodeEditorComponent::focusGained (FocusChangeType) void CodeEditorComponent::focusGained (FocusChangeType)
{ {
caret->updatePosition();
updateCaretPosition();
} }
void CodeEditorComponent::focusLost (FocusChangeType) void CodeEditorComponent::focusLost (FocusChangeType)
{ {
caret->updatePosition();
updateCaretPosition();
} }
//============================================================================== //==============================================================================


+ 2
- 3
src/gui/components/code_editor/juce_CodeEditorComponent.h View File

@@ -29,6 +29,7 @@
#include "../juce_Component.h" #include "../juce_Component.h"
#include "../layout/juce_ScrollBar.h" #include "../layout/juce_ScrollBar.h"
#include "../keyboard/juce_TextInputTarget.h" #include "../keyboard/juce_TextInputTarget.h"
#include "../keyboard/juce_CaretComponent.h"
#include "juce_CodeDocument.h" #include "juce_CodeDocument.h"
#include "juce_CodeTokeniser.h" #include "juce_CodeTokeniser.h"
@@ -208,7 +209,6 @@ public:
enum ColourIds enum ColourIds
{ {
backgroundColourId = 0x1004500, /**< A colour to use to fill the editor's background. */ 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 highlightColourId = 0x1004502, /**< The colour to use for the highlighted background under
selected text. */ selected text. */
defaultTextColourId = 0x1004503 /**< The colour to use for text when no syntax colouring is defaultTextColourId = 0x1004503 /**< The colour to use for text when no syntax colouring is
@@ -270,8 +270,6 @@ private:
CodeDocument::Position caretPos; CodeDocument::Position caretPos;
CodeDocument::Position selectionStart, selectionEnd; CodeDocument::Position selectionStart, selectionEnd;
class CaretComponent;
friend class ScopedPointer <CaretComponent>;
ScopedPointer<CaretComponent> caret; ScopedPointer<CaretComponent> caret;
ScrollBar verticalScrollBar, horizontalScrollBar; ScrollBar verticalScrollBar, horizontalScrollBar;
@@ -299,6 +297,7 @@ private:
void moveLineDelta (int delta, bool selecting); void moveLineDelta (int delta, bool selecting);
//============================================================================== //==============================================================================
void updateCaretPosition();
void updateScrollBars(); void updateScrollBars();
void scrollToLineInternal (int line); void scrollToLineInternal (int line);
void scrollToColumnInternal (double column); void scrollToColumnInternal (double column);


+ 3
- 2
src/gui/components/controls/juce_Label.cpp View File

@@ -30,6 +30,7 @@ BEGIN_JUCE_NAMESPACE
#include "juce_Label.h" #include "juce_Label.h"
#include "../lookandfeel/juce_LookAndFeel.h" #include "../lookandfeel/juce_LookAndFeel.h"
#include "../windows/juce_ComponentPeer.h" #include "../windows/juce_ComponentPeer.h"
#include "../keyboard/juce_CaretComponent.h"
//============================================================================== //==============================================================================
@@ -311,10 +312,10 @@ TextEditor* Label::createEditorComponent()
TextEditor::textColourId, TextEditor::textColourId,
TextEditor::highlightColourId, TextEditor::highlightColourId,
TextEditor::highlightedTextColourId, TextEditor::highlightedTextColourId,
TextEditor::caretColourId,
TextEditor::outlineColourId, TextEditor::outlineColourId,
TextEditor::focusedOutlineColourId, TextEditor::focusedOutlineColourId,
TextEditor::shadowColourId };
TextEditor::shadowColourId,
CaretComponent::caretColourId };
for (int i = 0; i < numElementsInArray (cols); ++i) for (int i = 0; i < numElementsInArray (cols); ++i)
ed->setColour (cols[i], findColour (cols[i])); ed->setColour (cols[i], findColour (cols[i]));


+ 54
- 99
src/gui/components/controls/juce_TextEditor.cpp View File

@@ -884,6 +884,11 @@ public:
owner.drawContent (g); owner.drawContent (g);
} }
void restartTimer()
{
startTimer (350);
}
void timerCallback() void timerCallback()
{ {
owner.timerCallbackInt(); owner.timerCallbackInt();
@@ -943,8 +948,6 @@ private:
//============================================================================== //==============================================================================
namespace TextEditorDefs namespace TextEditorDefs
{ {
const int flashSpeedIntervalMs = 380;
const int textChangeMessageId = 0x10003001; const int textChangeMessageId = 0x10003001;
const int returnKeyMessageId = 0x10003002; const int returnKeyMessageId = 0x10003002;
const int escapeKeyMessageId = 0x10003003; const int escapeKeyMessageId = 0x10003003;
@@ -968,19 +971,14 @@ TextEditor::TextEditor (const String& name,
multiline (false), multiline (false),
wordWrap (false), wordWrap (false),
returnKeyStartsNewLine (false), returnKeyStartsNewLine (false),
caretVisible (true),
popupMenuEnabled (true), popupMenuEnabled (true),
selectAllTextWhenFocused (false), selectAllTextWhenFocused (false),
scrollbarVisible (true), scrollbarVisible (true),
wasFocused (false), wasFocused (false),
caretFlashState (true),
keepCursorOnScreen (true), keepCursorOnScreen (true),
tabKeyUsed (false), tabKeyUsed (false),
menuActive (false), menuActive (false),
valueTextNeedsUpdating (false), valueTextNeedsUpdating (false),
cursorX (0),
cursorY (0),
cursorHeight (0),
maxTextLength (0), maxTextLength (0),
leftIndent (4), leftIndent (4),
topIndent (4), topIndent (4),
@@ -998,8 +996,8 @@ TextEditor::TextEditor (const String& name,
viewport->setWantsKeyboardFocus (false); viewport->setWantsKeyboardFocus (false);
viewport->setScrollBarsShown (false, false); viewport->setScrollBarsShown (false, false);
setMouseCursor (MouseCursor::IBeamCursor);
setWantsKeyboardFocus (true); setWantsKeyboardFocus (true);
setCaretVisible (true);
} }
TextEditor::~TextEditor() TextEditor::~TextEditor()
@@ -1142,15 +1140,26 @@ void TextEditor::colourChanged()
void TextEditor::setCaretVisible (const bool shouldCaretBeVisible) 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 setMouseCursor (shouldCaretBeVisible ? MouseCursor::IBeamCursor
: MouseCursor::NormalCursor); : MouseCursor::NormalCursor);
} }
void TextEditor::updateCaretPosition()
{
if (caret != 0)
caret->setCaretPosition (getCaretRectangle().translated (leftIndent, topIndent));
}
void TextEditor::setInputRestrictions (const int maxLen, void TextEditor::setInputRestrictions (const int maxLen,
const String& chars) const String& chars)
{ {
@@ -1279,22 +1288,8 @@ void TextEditor::removeListener (TextEditorListener* const listenerToRemove)
//============================================================================== //==============================================================================
void TextEditor::timerCallbackInt() 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(); const unsigned int now = Time::getApproximateMillisecondCounter();
@@ -1302,15 +1297,6 @@ void TextEditor::timerCallbackInt()
newTransaction(); 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) void TextEditor::repaintText (const Range<int>& range)
{ {
if (! range.isEmpty()) if (! range.isEmpty())
@@ -1353,12 +1339,10 @@ void TextEditor::moveCaret (int newCaretPos)
if (newCaretPos != getCaretPosition()) if (newCaretPos != getCaretPosition())
{ {
repaintCaret();
caretFlashState = true;
caretPosition = newCaretPos; caretPosition = newCaretPos;
textHolder->startTimer (TextEditorDefs::flashSpeedIntervalMs);
textHolder->restartTimer();
scrollToMakeSureCursorIsVisible(); scrollToMakeSureCursorIsVisible();
repaintCaret();
updateCaretPosition();
} }
} }
@@ -1378,17 +1362,15 @@ void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX,
{ {
updateCaretPosition(); 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))) if (desiredCaretX < jmax (1, proportionOfWidth (0.05f)))
{
vx += desiredCaretX - proportionOfWidth (0.2f); vx += desiredCaretX - proportionOfWidth (0.2f);
}
else if (desiredCaretX > jmax (0, viewport->getMaximumVisibleWidth() - (wordWrap ? 2 : 10))) else if (desiredCaretX > jmax (0, viewport->getMaximumVisibleWidth() - (wordWrap ? 2 : 10)))
{
vx += desiredCaretX + (isMultiLine() ? proportionOfWidth (0.2f) : 10) - viewport->getMaximumVisibleWidth(); vx += desiredCaretX + (isMultiLine() ? proportionOfWidth (0.2f) : 10) - viewport->getMaximumVisibleWidth();
}
vx = jlimit (0, jmax (0, textHolder->getWidth() + 8 - viewport->getMaximumVisibleWidth()), vx); 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); vy = jlimit (0, jmax (0, textHolder->getHeight() - viewport->getMaximumVisibleHeight()), vy);
const int curH = roundToInt (cursorHeight);
if (desiredCaretY < 0) if (desiredCaretY < 0)
{
vy = jmax (0, desiredCaretY + vy); 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); viewport->setViewPosition (vx, vy);
@@ -1417,18 +1393,18 @@ void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX,
const Rectangle<int> TextEditor::getCaretRectangle() 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 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() void TextEditor::updateTextHolderSize()
@@ -1448,7 +1424,7 @@ void TextEditor::updateTextHolderSize()
const int h = topIndent + roundToInt (jmax (i.lineY + i.lineHeight, const int h = topIndent + roundToInt (jmax (i.lineY + i.lineHeight,
currentFont.getHeight())); 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; 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() void TextEditor::scrollToMakeSureCursorIsVisible()
{ {
updateCaretPosition(); updateCaretPosition();
@@ -1500,8 +1470,10 @@ void TextEditor::scrollToMakeSureCursorIsVisible()
int x = viewport->getViewPositionX(); int x = viewport->getViewPositionX();
int y = viewport->getViewPositionY(); 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))) if (relativeCursorX < jmax (1, proportionOfWidth (0.05f)))
{ {
@@ -1520,15 +1492,13 @@ void TextEditor::scrollToMakeSureCursorIsVisible()
} }
else else
{ {
const int curH = roundToInt (cursorHeight);
if (relativeCursorY < 0) if (relativeCursorY < 0)
{ {
y = jmax (0, relativeCursorY + y); 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) 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() if (textToShowWhenEmpty.isNotEmpty()
&& (! hasKeyboardFocus (false)) && (! hasKeyboardFocus (false))
&& getTotalNumChars() == 0) && getTotalNumChars() == 0)
@@ -1803,7 +1761,7 @@ void TextEditor::mouseDrag (const MouseEvent& e)
void TextEditor::mouseUp (const MouseEvent& e) void TextEditor::mouseUp (const MouseEvent& e)
{ {
newTransaction(); newTransaction();
textHolder->startTimer (TextEditorDefs::flashSpeedIntervalMs);
textHolder->restartTimer();
if (wasFocused || ! selectAllTextWhenFocused) if (wasFocused || ! selectAllTextWhenFocused)
{ {
@@ -1892,6 +1850,7 @@ bool TextEditor::keyPressed (const KeyPress& key)
return false; return false;
const bool moveInWholeWordSteps = key.getModifiers().isCtrlDown() || key.getModifiers().isAltDown(); const bool moveInWholeWordSteps = key.getModifiers().isCtrlDown() || key.getModifiers().isAltDown();
const Rectangle<float> caretPos (getCaretRectangle().toFloat());
if (key.isKeyCode (KeyPress::leftKey) if (key.isKeyCode (KeyPress::leftKey)
|| key.isKeyCode (KeyPress::upKey)) || key.isKeyCode (KeyPress::upKey))
@@ -1901,7 +1860,7 @@ bool TextEditor::keyPressed (const KeyPress& key)
int newPos; int newPos;
if (isMultiLine() && key.isKeyCode (KeyPress::upKey)) if (isMultiLine() && key.isKeyCode (KeyPress::upKey))
newPos = indexAtPosition (cursorX, cursorY - 1);
newPos = indexAtPosition (caretPos.getX(), caretPos.getY() - 1.0f);
else if (moveInWholeWordSteps) else if (moveInWholeWordSteps)
newPos = findWordBreakBefore (getCaretPosition()); newPos = findWordBreakBefore (getCaretPosition());
else else
@@ -1917,7 +1876,7 @@ bool TextEditor::keyPressed (const KeyPress& key)
int newPos; int newPos;
if (isMultiLine() && key.isKeyCode (KeyPress::downKey)) if (isMultiLine() && key.isKeyCode (KeyPress::downKey))
newPos = indexAtPosition (cursorX, cursorY + cursorHeight + 1);
newPos = indexAtPosition (caretPos.getX(), caretPos.getBottom() + 1.0f);
else if (moveInWholeWordSteps) else if (moveInWholeWordSteps)
newPos = findWordBreakAfter (getCaretPosition()); newPos = findWordBreakAfter (getCaretPosition());
else else
@@ -1929,14 +1888,14 @@ bool TextEditor::keyPressed (const KeyPress& key)
{ {
newTransaction(); newTransaction();
moveCursorTo (indexAtPosition (cursorX, cursorY + cursorHeight + viewport->getViewHeight()),
moveCursorTo (indexAtPosition (caretPos.getX(), caretPos.getBottom() + viewport->getViewHeight()),
key.getModifiers().isShiftDown()); key.getModifiers().isShiftDown());
} }
else if (key.isKeyCode (KeyPress::pageUpKey) && isMultiLine()) else if (key.isKeyCode (KeyPress::pageUpKey) && isMultiLine())
{ {
newTransaction(); newTransaction();
moveCursorTo (indexAtPosition (cursorX, cursorY - viewport->getViewHeight()),
moveCursorTo (indexAtPosition (caretPos.getX(), caretPos.getY() - viewport->getViewHeight()),
key.getModifiers().isShiftDown()); key.getModifiers().isShiftDown());
} }
else if (key.isKeyCode (KeyPress::homeKey)) else if (key.isKeyCode (KeyPress::homeKey))
@@ -1944,7 +1903,7 @@ bool TextEditor::keyPressed (const KeyPress& key)
newTransaction(); newTransaction();
if (isMultiLine() && ! moveInWholeWordSteps) if (isMultiLine() && ! moveInWholeWordSteps)
moveCursorTo (indexAtPosition (0.0f, cursorY),
moveCursorTo (indexAtPosition (0.0f, caretPos.getY()),
key.getModifiers().isShiftDown()); key.getModifiers().isShiftDown());
else else
moveCursorTo (0, key.getModifiers().isShiftDown()); moveCursorTo (0, key.getModifiers().isShiftDown());
@@ -1954,7 +1913,7 @@ bool TextEditor::keyPressed (const KeyPress& key)
newTransaction(); newTransaction();
if (isMultiLine() && ! moveInWholeWordSteps) if (isMultiLine() && ! moveInWholeWordSteps)
moveCursorTo (indexAtPosition ((float) textHolder->getWidth(), cursorY),
moveCursorTo (indexAtPosition ((float) textHolder->getWidth(), caretPos.getY()),
key.getModifiers().isShiftDown()); key.getModifiers().isShiftDown());
else else
moveCursorTo (getTotalNumChars(), key.getModifiers().isShiftDown()); moveCursorTo (getTotalNumChars(), key.getModifiers().isShiftDown());
@@ -2131,8 +2090,6 @@ void TextEditor::focusGained (FocusChangeType)
{ {
newTransaction(); newTransaction();
caretFlashState = true;
if (selectAllTextWhenFocused) if (selectAllTextWhenFocused)
{ {
moveCursorTo (0, false); moveCursorTo (0, false);
@@ -2140,9 +2097,7 @@ void TextEditor::focusGained (FocusChangeType)
} }
repaint(); repaint();
if (caretVisible)
textHolder->startTimer (TextEditorDefs::flashSpeedIntervalMs);
updateCaretPosition();
ComponentPeer* const peer = getPeer(); ComponentPeer* const peer = getPeer();
if (peer != 0 && ! isReadOnly()) if (peer != 0 && ! isReadOnly())
@@ -2155,7 +2110,7 @@ void TextEditor::focusLost (FocusChangeType)
wasFocused = false; wasFocused = false;
textHolder->stopTimer(); textHolder->stopTimer();
caretFlashState = false;
updateCaretPosition();
postCommandMessage (TextEditorDefs::focusLossMessageId); postCommandMessage (TextEditorDefs::focusLossMessageId);
repaint(); repaint();


+ 3
- 9
src/gui/components/controls/juce_TextEditor.h View File

@@ -34,6 +34,7 @@
#include "../menus/juce_PopupMenu.h" #include "../menus/juce_PopupMenu.h"
#include "../../../containers/juce_Value.h" #include "../../../containers/juce_Value.h"
#include "../keyboard/juce_TextInputTarget.h" #include "../keyboard/juce_TextInputTarget.h"
#include "../keyboard/juce_CaretComponent.h"
//============================================================================== //==============================================================================
@@ -133,9 +134,7 @@ public:
//============================================================================== //==============================================================================
/** Makes the caret visible or invisible. /** Makes the caret visible or invisible.
By default the caret is visible. By default the caret is visible.
@see setCaretColour, setCaretPosition @see setCaretColour, setCaretPosition
*/ */
void setCaretVisible (bool shouldBeVisible); void setCaretVisible (bool shouldBeVisible);
@@ -143,7 +142,7 @@ public:
/** Returns true if the caret is enabled. /** Returns true if the caret is enabled.
@see setCaretVisible @see setCaretVisible
*/ */
bool isCaretVisible() const { return caretVisible; }
bool isCaretVisible() const { return caret != 0; }
//============================================================================== //==============================================================================
/** Enables/disables a vertical scrollbar. /** Enables/disables a vertical scrollbar.
@@ -222,8 +221,6 @@ public:
highlightedTextColourId = 0x1000203, /**< The colour with which to draw the text in highlighted sections. */ 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 outlineColourId = 0x1000205, /**< If this is non-transparent, it will be used to draw a box around
the edge of the component. */ the edge of the component. */
@@ -622,19 +619,17 @@ private:
bool multiline : 1; bool multiline : 1;
bool wordWrap : 1; bool wordWrap : 1;
bool returnKeyStartsNewLine : 1; bool returnKeyStartsNewLine : 1;
bool caretVisible : 1;
bool popupMenuEnabled : 1; bool popupMenuEnabled : 1;
bool selectAllTextWhenFocused : 1; bool selectAllTextWhenFocused : 1;
bool scrollbarVisible : 1; bool scrollbarVisible : 1;
bool wasFocused : 1; bool wasFocused : 1;
bool caretFlashState : 1;
bool keepCursorOnScreen : 1; bool keepCursorOnScreen : 1;
bool tabKeyUsed : 1; bool tabKeyUsed : 1;
bool menuActive : 1; bool menuActive : 1;
bool valueTextNeedsUpdating : 1; bool valueTextNeedsUpdating : 1;
UndoManager undoManager; UndoManager undoManager;
float cursorX, cursorY, cursorHeight;
ScopedPointer<CaretComponent> caret;
int maxTextLength; int maxTextLength;
Range<int> selection; Range<int> selection;
int leftIndent, topIndent; int leftIndent, topIndent;
@@ -678,7 +673,6 @@ private:
void updateTextHolderSize(); void updateTextHolderSize();
float getWordWrapWidth() const; float getWordWrapWidth() const;
void timerCallbackInt(); void timerCallbackInt();
void repaintCaret();
void repaintText (const Range<int>& range); void repaintText (const Range<int>& range);
UndoManager* getUndoManager() throw(); UndoManager* getUndoManager() throw();


+ 69
- 0
src/gui/components/keyboard/juce_CaretComponent.cpp View 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
- 0
src/gui/components/keyboard/juce_CaretComponent.h View 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__

+ 8
- 2
src/gui/components/lookandfeel/juce_LookAndFeel.cpp View File

@@ -52,6 +52,7 @@ BEGIN_JUCE_NAMESPACE
#include "../controls/juce_ProgressBar.h" #include "../controls/juce_ProgressBar.h"
#include "../controls/juce_TreeView.h" #include "../controls/juce_TreeView.h"
#include "../keyboard/juce_KeyMappingEditorComponent.h" #include "../keyboard/juce_KeyMappingEditorComponent.h"
#include "../keyboard/juce_CaretComponent.h"
#include "../code_editor/juce_CodeEditorComponent.h" #include "../code_editor/juce_CodeEditorComponent.h"
#include "../filebrowser/juce_FilenameComponent.h" #include "../filebrowser/juce_FilenameComponent.h"
#include "../filebrowser/juce_DirectoryContentsDisplayComponent.h" #include "../filebrowser/juce_DirectoryContentsDisplayComponent.h"
@@ -191,11 +192,12 @@ LookAndFeel::LookAndFeel()
TextEditor::textColourId, 0xff000000, TextEditor::textColourId, 0xff000000,
TextEditor::highlightColourId, textHighlightColour, TextEditor::highlightColourId, textHighlightColour,
TextEditor::highlightedTextColourId, 0xff000000, TextEditor::highlightedTextColourId, 0xff000000,
TextEditor::caretColourId, 0xff000000,
TextEditor::outlineColourId, 0x00000000, TextEditor::outlineColourId, 0x00000000,
TextEditor::focusedOutlineColourId, textButtonColour, TextEditor::focusedOutlineColourId, textButtonColour,
TextEditor::shadowColourId, 0x38000000, TextEditor::shadowColourId, 0x38000000,
CaretComponent::caretColourId, 0xff000000,
Label::backgroundColourId, 0x00000000, Label::backgroundColourId, 0x00000000,
Label::textColourId, 0xff000000, Label::textColourId, 0xff000000,
Label::outlineColourId, 0x00000000, Label::outlineColourId, 0x00000000,
@@ -278,7 +280,6 @@ LookAndFeel::LookAndFeel()
MidiKeyboardComponent::upDownButtonArrowColourId, 0xff000000, MidiKeyboardComponent::upDownButtonArrowColourId, 0xff000000,
CodeEditorComponent::backgroundColourId, 0xffffffff, CodeEditorComponent::backgroundColourId, 0xffffffff,
CodeEditorComponent::caretColourId, 0xff000000,
CodeEditorComponent::highlightColourId, textHighlightColour, CodeEditorComponent::highlightColourId, textHighlightColour,
CodeEditorComponent::defaultTextColourId, 0xff000000, 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, void LookAndFeel::drawComboBox (Graphics& g, int width, int height,
const bool isButtonDown, const bool isButtonDown,


+ 3
- 0
src/gui/components/lookandfeel/juce_LookAndFeel.h View File

@@ -59,6 +59,7 @@ class FilePreviewComponent;
class ImageButton; class ImageButton;
class CallOutBox; class CallOutBox;
class Drawable; class Drawable;
class CaretComponent;
//============================================================================== //==============================================================================
/** /**
@@ -294,6 +295,8 @@ public:
virtual void fillTextEditorBackground (Graphics& g, int width, int height, TextEditor& textEditor); virtual void fillTextEditorBackground (Graphics& g, int width, int height, TextEditor& textEditor);
virtual void drawTextEditorOutline (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 // 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. // a copy of this pointer anywhere, as it may become invalid in the future.


+ 3
- 0
src/juce_app_includes.h View File

@@ -401,6 +401,9 @@
#ifndef __JUCE_MODALCOMPONENTMANAGER_JUCEHEADER__ #ifndef __JUCE_MODALCOMPONENTMANAGER_JUCEHEADER__
#include "gui/components/juce_ModalComponentManager.h" #include "gui/components/juce_ModalComponentManager.h"
#endif #endif
#ifndef __JUCE_CARETCOMPONENT_JUCEHEADER__
#include "gui/components/keyboard/juce_CaretComponent.h"
#endif
#ifndef __JUCE_KEYBOARDFOCUSTRAVERSER_JUCEHEADER__ #ifndef __JUCE_KEYBOARDFOCUSTRAVERSER_JUCEHEADER__
#include "gui/components/keyboard/juce_KeyboardFocusTraverser.h" #include "gui/components/keyboard/juce_KeyboardFocusTraverser.h"
#endif #endif


Loading…
Cancel
Save