diff options
| author | nyamatongwe <unknown> | 2000-07-22 06:51:09 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2000-07-22 06:51:09 +0000 | 
| commit | c8ab474fa173218cfe16309c8fbf37ab29635ccc (patch) | |
| tree | e7dec8b009cb188dfeae386c35b8a845114d13dd | |
| parent | 1e00d4f26ac7e2a7ac67195c0a3516f832edf34c (diff) | |
| download | scintilla-mirror-c8ab474fa173218cfe16309c8fbf37ab29635ccc.tar.gz | |
Updates to make new API work on both GTK+ and Win32.
| -rw-r--r-- | gtk/PlatGTK.cxx | 7 | ||||
| -rw-r--r-- | gtk/ScintillaGTK.cxx | 19 | ||||
| -rw-r--r-- | include/Platform.h | 16 | ||||
| -rw-r--r-- | include/Scintilla.h | 2 | ||||
| -rw-r--r-- | src/Editor.cxx | 23 | ||||
| -rw-r--r-- | src/LexHTML.cxx | 2 | ||||
| -rw-r--r-- | win32/PlatWin.cxx | 2 | 
7 files changed, 45 insertions, 26 deletions
| diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 32323e807..40c8c76af 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -13,11 +13,10 @@  #include "ScintillaWidget.h"  #include "Scintilla.h" -#define LOWORD(x) (x & 0xffff) -#define HIWORD(x) (x >> 16) -  Point Point::FromLong(long lpoint) { -	return Point(LOWORD(lpoint), HIWORD(lpoint)); +	return Point( +		Platform::LowShortFromLong(lpoint),  +		Platform::HighShortFromLong(lpoint));  }  static GdkColor ColourfromRGB(unsigned int red, unsigned int green, unsigned int blue) { diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index bd4c98ccc..f150a9297 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -125,6 +125,8 @@ private:  	static gint TimeOut(ScintillaGTK *sciThis);  	static void PopUpCB(ScintillaGTK *sciThis, guint action, GtkWidget *widget);  	static gint ExposeCT(GtkWidget *widget, GdkEventExpose *ose, CallTip *ct); +	static long DirectFunction(ScintillaGTK *sciThis,  +		unsigned int iMessage, unsigned long wParam, long lParam);  };  enum { @@ -327,6 +329,12 @@ long ScintillaGTK::WndProc(unsigned int iMessage, unsigned long wParam, long lPa  		gtk_widget_grab_focus(wMain.GetID());  		break; +	case SCI_GETDIRECTFUNCTION: +		return reinterpret_cast<long>(DirectFunction); +	 +	case SCI_GETDIRECTPOINTER: +		return reinterpret_cast<long>(this); +  	default:  		return ScintillaBase::WndProc(iMessage,wParam,lParam);  	} @@ -464,12 +472,12 @@ void ScintillaGTK::ReconfigureScrollBars() {  void ScintillaGTK::NotifyChange() {  	gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], -                	MAKELONG(ctrlID, SCEN_CHANGE), wMain.GetID()); +                Platform::LongFromTwoShorts(ctrlID, SCEN_CHANGE), wMain.GetID());  }  void ScintillaGTK::NotifyFocus(bool focus) {  	gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], -                	MAKELONG(ctrlID, focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), wMain.GetID()); +                Platform::LongFromTwoShorts(ctrlID, focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), wMain.GetID());  }  void ScintillaGTK::NotifyParent(SCNotification scn) { @@ -718,7 +726,7 @@ gint ScintillaGTK::MoveResize(GtkWidget *, GtkAllocation *allocation, ScintillaG  }  gint ScintillaGTK::Press(GtkWidget *, GdkEventButton *event, ScintillaGTK *sciThis) { -	Platform::DebugPrintf("Press %x time=%d state = %x button = %x\n",sciThis,event->time, event->state, event->button); +	//Platform::DebugPrintf("Press %x time=%d state = %x button = %x\n",sciThis,event->time, event->state, event->button);  	// Do not use GTK+ double click events as Scintilla has its own double click detection  	if (event->type != GDK_BUTTON_PRESS)   		return FALSE; @@ -1026,6 +1034,11 @@ gint ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, CallTip  	return TRUE;  } +long ScintillaGTK::DirectFunction( +    ScintillaGTK *sciThis, unsigned int iMessage, unsigned long wParam, long lParam) { +	return sciThis->WndProc(iMessage, wParam, lParam); +} +  long scintilla_send_message(ScintillaObject *sci, int iMessage, int wParam, int lParam) {  	ScintillaGTK *psci = reinterpret_cast<ScintillaGTK *>(sci->pscin);  	return psci->WndProc(iMessage, wParam, lParam); diff --git a/include/Platform.h b/include/Platform.h index 14be5cebd..de9cf202a 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -80,12 +80,6 @@ typedef wxWindow* WindowID;  typedef wxMenu* MenuID;  #endif -#if PLAT_GTK || PLAT_WX -#define SHIFT_PRESSED 1 -#define LEFT_CTRL_PRESSED 2 -#define LEFT_ALT_PRESSED 4 -#endif -  // Point is exactly the same as the Win32 POINT and GTK+ GdkPoint so can be used interchangeably  class Point { @@ -400,6 +394,16 @@ public:  	// These are utility functions not really tied to a platform  	static int Minimum(int a, int b);  	static int Maximum(int a, int b); +	// Next three assume 16 bit shorts and 32 bit longs +	static long LongFromTwoShorts(short a,short b) { +		return (a) | ((b) << 16); +	} +	static short HighShortFromLong(long x) { +		return static_cast<short>(x >> 16); +	} +	static short LowShortFromLong(long x) { +		return static_cast<short>(x & 0xffff); +	}  	static void DebugPrintf(const char *format, ...);  	static int Clamp(int val, int minVal, int maxVal);  }; diff --git a/include/Scintilla.h b/include/Scintilla.h index 7a7ee8c05..1b23dfdca 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -15,6 +15,8 @@ void Scintilla_RegisterClasses(HINSTANCE hInstance);  #endif  #endif +typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wParam, long lParam); +  // Start of section which could be automatically generated from Scintilla.iface  #define INVALID_POSITION -1  diff --git a/src/Editor.cxx b/src/Editor.cxx index 4a7b4c5b4..f9cf12f9e 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -14,9 +14,6 @@  #if PLAT_WX || PLAT_GTK  #include "WinDefs.h" -#define MAKELONG(a, b) ((a) | ((b) << 16)) -#define LOWORD(x) (x & 0xffff) -#define HIWORD(x) (x >> 16)  #endif  #include "ContractionState.h" @@ -3141,7 +3138,9 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {  			*reinterpret_cast<int *>(wParam) = SelectionStart();  		if (lParam)  			*reinterpret_cast<int *>(lParam) = SelectionEnd(); -		return MAKELONG(SelectionStart(), SelectionEnd()); +		return Platform::LongFromTwoShorts( +			static_cast<short>(SelectionStart()),  +			static_cast<short>(SelectionEnd()));  	case EM_EXGETSEL: {  			if (lParam == 0) @@ -3290,7 +3289,8 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {  			Point *ppt = reinterpret_cast<Point *>(lParam);  			int pos = PositionFromLocation(*ppt);  			int line = pdoc->LineFromPosition(pos); -			return MAKELONG(pos, line); +			return Platform::LongFromTwoShorts( +				static_cast<short>(pos), static_cast<short>(line));  		}  	case EM_POSFROMCHAR: { @@ -3365,7 +3365,8 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {  		return FormatRange(wParam, reinterpret_cast<RangeToFormat *>(lParam));  	case EM_GETMARGINS: -		return MAKELONG(vs.leftMarginWidth, vs.rightMarginWidth); +		return Platform::LongFromTwoShorts(static_cast<short>(vs.leftMarginWidth),  +			static_cast<short>(vs.rightMarginWidth));  	case SCI_GETMARGINLEFT:  		return vs.leftMarginWidth; @@ -3376,10 +3377,10 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {  	case EM_SETMARGINS:  #ifdef EC_LEFTMARGIN  		if (wParam & EC_LEFTMARGIN) { -			vs.leftMarginWidth = LOWORD(lParam); +			vs.leftMarginWidth = Platform::LowShortFromLong(lParam);  		}  		if (wParam & EC_RIGHTMARGIN) { -			vs.rightMarginWidth = HIWORD(lParam); +			vs.rightMarginWidth = Platform::HighShortFromLong(lParam);  		}  		if (wParam == EC_USEFONTINFO) {  			vs.leftMarginWidth = vs.aveCharWidth / 2; @@ -4004,11 +4005,13 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {  		return vs.caretcolour.desired.AsLong();  	case SCI_ASSIGNCMDKEY: -		kmap.AssignCmdKey(LOWORD(wParam), HIWORD(wParam), lParam); +		kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),  +			Platform::HighShortFromLong(wParam), lParam);  		break;  	case SCI_CLEARCMDKEY: -		kmap.AssignCmdKey(LOWORD(wParam), HIWORD(wParam), WM_NULL); +		kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),  +			Platform::HighShortFromLong(wParam), WM_NULL);  		break;  	case SCI_CLEARALLCMDKEYS: diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx index cb6eadaab..244eb2b6e 100644 --- a/src/LexHTML.cxx +++ b/src/LexHTML.cxx @@ -345,7 +345,6 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty  		// Handle DBCS codepages  		if (styler.IsLeadByte(ch)) { -			chPrev2 = ' ';  			chPrev = ' ';  			i += 1;  			continue; @@ -434,7 +433,6 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty  				scriptLanguage = eScriptNone;  				i += 2;  				continue; -				break;  			}  		} diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 87f90cfa1..4eb1e2b47 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -127,7 +127,7 @@ void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, int size, b  	lf.lfHeight = -(abs(size));  	lf.lfWeight = bold ? FW_BOLD : FW_NORMAL;  	lf.lfItalic = static_cast<BYTE>(italic ? 1 : 0); -	lf.lfCharSet = characterSet; +	lf.lfCharSet = static_cast<BYTE>(characterSet);  	strcpy(lf.lfFaceName, faceName);  } | 
