aboutsummaryrefslogtreecommitdiffhomepage
path: root/macosx/ScintillaCallTip.cxx
diff options
context:
space:
mode:
authorscaraveo <unknown>2007-06-01 00:57:26 +0000
committerscaraveo <unknown>2007-06-01 00:57:26 +0000
commit710f716e96f6e9ee9eb410b343b78b3c4d95bc46 (patch)
tree55e5547869daa67b6a639c89825058baf75545c7 /macosx/ScintillaCallTip.cxx
parentcac98b923422b91839f7c285a9b78ea282cd6f0a (diff)
downloadscintilla-mirror-710f716e96f6e9ee9eb410b343b78b3c4d95bc46.tar.gz
integrate OS X support for scintilla. a big patch with a little commit message :)
- now uses namespaces (optionally for non-os x) to avoid conflicts with OS X libraries - several fixes in the OS X layer since the branch was commited in 2005 - used in Komodo since 2005, so pretty stable
Diffstat (limited to 'macosx/ScintillaCallTip.cxx')
-rw-r--r--macosx/ScintillaCallTip.cxx117
1 files changed, 117 insertions, 0 deletions
diff --git a/macosx/ScintillaCallTip.cxx b/macosx/ScintillaCallTip.cxx
new file mode 100644
index 000000000..6799b435a
--- /dev/null
+++ b/macosx/ScintillaCallTip.cxx
@@ -0,0 +1,117 @@
+
+#include "ScintillaMacOSX.h"
+#include "ScintillaCallTip.h"
+#include "CallTip.h"
+
+using namespace Scintilla;
+
+const CFStringRef ScintillaCallTip::kScintillaCallTipClassID = CFSTR( "org.scintilla.calltip" );
+const ControlKind ScintillaCallTip::kScintillaCallTipKind = { 'ejon', 'Scct' };
+
+ScintillaCallTip::ScintillaCallTip( void* windowid ) :
+ TView( reinterpret_cast<HIViewRef>( windowid ) )
+{
+ ActivateInterface( kMouse );
+ // debugPrint = true;
+}
+
+void ScintillaCallTip::Draw(
+ RgnHandle /*inLimitRgn*/,
+ CGContextRef inContext )
+{
+ // Get a reference to the Scintilla C++ object
+ CallTip* ctip = NULL;
+ OSStatus err;
+ err = GetControlProperty( GetViewRef(), scintillaCallTipType, 0, sizeof( ctip ), NULL, &ctip );
+ assert(err == noErr);
+ if (ctip == NULL) return;
+
+ Rect contentBounds;
+ GetControlBounds(GetViewRef(), &contentBounds);
+
+ HIRect controlFrame;
+ HIViewGetFrame( GetViewRef(), &controlFrame );
+
+ // what is the global pos?
+ Surface *surfaceWindow = Surface::Allocate();
+ if (surfaceWindow) {
+ surfaceWindow->Init(inContext, GetViewRef());
+ ctip->PaintCT(surfaceWindow);
+ surfaceWindow->Release();
+ delete surfaceWindow;
+ }
+
+}
+
+ControlPartCode ScintillaCallTip::HitTest( const HIPoint& where )
+{
+ if ( CGRectContainsPoint( Bounds(), where ) )
+ return 1;
+ else
+ return kControlNoPart;
+}
+
+OSStatus ScintillaCallTip::MouseDown(HIPoint& location, UInt32 /*inKeyModifiers*/, EventMouseButton button, UInt32 /*inClickCount*/ )
+{
+ if ( button != kEventMouseButtonPrimary ) return eventNotHandledErr;
+ CallTip* ctip = NULL;
+ ScintillaMacOSX *sciThis = NULL;
+ OSStatus err = GetControlProperty( GetViewRef(), scintillaCallTipType, 0, sizeof( ctip ), NULL, &ctip );
+ err = GetControlProperty( GetViewRef(), scintillaMacOSType, 0, sizeof( sciThis ), NULL, &sciThis );
+ ctip->MouseClick( Scintilla::Point( static_cast<int>( location.x ), static_cast<int>( location.y ) ));
+ sciThis->CallTipClick();
+ return noErr;
+}
+
+OSStatus ScintillaCallTip::MouseUp(HIPoint& /*inMouseLocation*/, UInt32 /*inKeyModifiers*/, EventMouseButton button, UInt32 /*inClickCount*/ )
+{
+ if ( button != kEventMouseButtonPrimary ) return eventNotHandledErr;
+ return noErr;
+}
+
+OSStatus ScintillaCallTip::MouseDragged( HIPoint& location, UInt32 /*modifiers*/, EventMouseButton /*button*/, UInt32 /*clickCount*/ )
+{
+ SetThemeCursor( kThemeArrowCursor );
+ return noErr;
+}
+
+HIViewRef ScintillaCallTip::Create()
+{
+ // Register the HIView, if needed
+ static bool registered = false;
+
+ if ( not registered )
+ {
+ TView::RegisterSubclass( kScintillaCallTipClassID, Construct );
+ registered = true;
+ }
+
+ OSStatus err = noErr;
+ EventRef event = CreateInitializationEvent();
+ assert( event != NULL );
+
+ HIViewRef control = NULL;
+ err = HIObjectCreate( kScintillaCallTipClassID, event, reinterpret_cast<HIObjectRef*>( &control ) );
+ ReleaseEvent( event );
+ if ( err == noErr ) {
+ Platform::DebugPrintf("ScintillaCallTip::Create control %08X\n",control);
+ return control;
+ }
+ return NULL;
+}
+
+OSStatus ScintillaCallTip::Construct( HIViewRef inControl, TView** outView )
+{
+ *outView = new ScintillaCallTip( inControl );
+ Platform::DebugPrintf("ScintillaCallTip::Construct scintilla %08X\n",*outView);
+ if ( *outView != NULL )
+ return noErr;
+ else
+ return memFullErr;
+}
+
+extern "C" {
+HIViewRef scintilla_calltip_new() {
+ return ScintillaCallTip::Create();
+}
+}