diff options
author | nyamatongwe <unknown> | 2009-05-06 11:00:26 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2009-05-06 11:00:26 +0000 |
commit | 55d4a1dcbbe2f7b5f4651808825f40bd16c78b66 (patch) | |
tree | 2bd35ffd1403abdc76a0575740266be72dd6731d | |
parent | d5903ff90d8aad528c5f47f549563f3730d65d0c (diff) | |
download | scintilla-mirror-55d4a1dcbbe2f7b5f4651808825f40bd16c78b66.tar.gz |
First stage of Cocoa platform addition.
Changed identifier id since this is a reserved word in Objective C.
SCI_LEXER and SCI_NAMESPACE turned on automatically for OS X native
compilation.
-rw-r--r-- | gtk/PlatGTK.cxx | 108 | ||||
-rw-r--r-- | include/Platform.h | 31 | ||||
-rw-r--r-- | macosx/PlatMacOSX.cxx | 62 | ||||
-rw-r--r-- | macosx/makefile | 4 | ||||
-rw-r--r-- | src/XPM.h | 6 | ||||
-rw-r--r-- | win32/PlatWin.cxx | 76 |
6 files changed, 145 insertions, 142 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 9bc207896..2109c4d62 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -173,8 +173,8 @@ static FontHandle *PFont(Font &f) { return reinterpret_cast<FontHandle *>(f.GetID()); } -static GtkWidget *PWidget(WindowID id) { - return reinterpret_cast<GtkWidget *>(id); +static GtkWidget *PWidget(WindowID wid) { + return reinterpret_cast<GtkWidget *>(wid); } static GtkWidget *PWidget(Window &w) { @@ -421,7 +421,7 @@ class FontCached : Font { static FontCached *first; public: static FontID FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_); - static void ReleaseId(FontID id_); + static void ReleaseId(FontID fid_); }; FontCached *FontCached::first = 0; @@ -430,7 +430,7 @@ FontCached::FontCached(const char *faceName_, int characterSet_, int size_, bool next(0), usage(0), hash(0) { ::SetLogFont(lf, faceName_, characterSet_, size_, bold_, italic_); hash = HashFont(faceName_, characterSet_, size_, bold_, italic_); - id = CreateNewFont(faceName_, characterSet_, size_, bold_, italic_); + fid = CreateNewFont(faceName_, characterSet_, size_, bold_, italic_); usage = 1; } @@ -444,9 +444,9 @@ bool FontCached::SameAs(const char *faceName_, int characterSet_, int size_, boo } void FontCached::Release() { - if (id) + if (fid) delete PFont(*this); - id = 0; + fid = 0; } FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) { @@ -457,7 +457,7 @@ FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int si if ((cur->hash == hashFind) && cur->SameAs(faceName_, characterSet_, size_, bold_, italic_)) { cur->usage++; - ret = cur->id; + ret = cur->fid; } } if (ret == 0) { @@ -465,18 +465,18 @@ FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int si if (fc) { fc->next = first; first = fc; - ret = fc->id; + ret = fc->fid; } } FontMutexUnlock(); return ret; } -void FontCached::ReleaseId(FontID id_) { +void FontCached::ReleaseId(FontID fid_) { FontMutexLock(); FontCached **pcur = &first; for (FontCached *cur = first; cur; cur = cur->next) { - if (cur->id == id_) { + if (cur->fid == fid_) { cur->usage--; if (cur->usage == 0) { *pcur = cur->next; @@ -661,20 +661,20 @@ FontID FontCached::CreateNewFont(const char *fontName, int characterSet, return new FontHandle(newid); } -Font::Font() : id(0) {} +Font::Font() : fid(0) {} Font::~Font() {} void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic, bool) { Release(); - id = FontCached::FindOrCreate(faceName, characterSet, size, bold, italic); + fid = FontCached::FindOrCreate(faceName, characterSet, size, bold, italic); } void Font::Release() { - if (id) - FontCached::ReleaseId(id); - id = 0; + if (fid) + FontCached::ReleaseId(fid); + fid = 0; } // Required on OS X @@ -1735,24 +1735,24 @@ Surface *Surface::Allocate() { Window::~Window() {} void Window::Destroy() { - if (id) - gtk_widget_destroy(GTK_WIDGET(id)); - id = 0; + if (wid) + gtk_widget_destroy(GTK_WIDGET(wid)); + wid = 0; } bool Window::HasFocus() { - return GTK_WIDGET_HAS_FOCUS(id); + return GTK_WIDGET_HAS_FOCUS(wid); } PRectangle Window::GetPosition() { // Before any size allocated pretend its 1000 wide so not scrolled PRectangle rc(0, 0, 1000, 1000); - if (id) { - rc.left = PWidget(id)->allocation.x; - rc.top = PWidget(id)->allocation.y; - if (PWidget(id)->allocation.width > 20) { - rc.right = rc.left + PWidget(id)->allocation.width; - rc.bottom = rc.top + PWidget(id)->allocation.height; + if (wid) { + rc.left = PWidget(wid)->allocation.x; + rc.top = PWidget(wid)->allocation.y; + if (PWidget(wid)->allocation.width > 20) { + rc.right = rc.left + PWidget(wid)->allocation.width; + rc.bottom = rc.top + PWidget(wid)->allocation.height; } } return rc; @@ -1765,18 +1765,18 @@ void Window::SetPosition(PRectangle rc) { alloc.y = rc.top; alloc.width = rc.Width(); alloc.height = rc.Height(); - gtk_widget_size_allocate(PWidget(id), &alloc); + gtk_widget_size_allocate(PWidget(wid), &alloc); #else - gtk_widget_set_uposition(id, rc.left, rc.top); - gtk_widget_set_usize(id, rc.right - rc.left, rc.bottom - rc.top); + gtk_widget_set_uposition(wid, rc.left, rc.top); + gtk_widget_set_usize(wid, rc.right - rc.left, rc.bottom - rc.top); #endif } void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { int ox = 0; int oy = 0; - gdk_window_get_origin(PWidget(relativeTo.id)->window, &ox, &oy); + gdk_window_get_origin(PWidget(relativeTo.wid)->window, &ox, &oy); ox += rc.left; if (ox < 0) ox = 0; @@ -1797,9 +1797,9 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { oy = screenHeight - sizey; #if GTK_MAJOR_VERSION >= 2 - gtk_window_move(GTK_WINDOW(PWidget(id)), ox, oy); + gtk_window_move(GTK_WINDOW(PWidget(wid)), ox, oy); #else - gtk_widget_set_uposition(PWidget(id), ox, oy); + gtk_widget_set_uposition(PWidget(wid), ox, oy); #endif #if 0 @@ -1809,9 +1809,9 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { alloc.y = rc.top + oy; alloc.width = rc.right - rc.left; alloc.height = rc.bottom - rc.top; - gtk_widget_size_allocate(id, &alloc); + gtk_widget_size_allocate(wid, &alloc); #endif - gtk_widget_set_usize(PWidget(id), sizex, sizey); + gtk_widget_set_usize(PWidget(wid), sizex, sizey); } PRectangle Window::GetClientPosition() { @@ -1821,18 +1821,18 @@ PRectangle Window::GetClientPosition() { void Window::Show(bool show) { if (show) - gtk_widget_show(PWidget(id)); + gtk_widget_show(PWidget(wid)); } void Window::InvalidateAll() { - if (id) { - gtk_widget_queue_draw(PWidget(id)); + if (wid) { + gtk_widget_queue_draw(PWidget(wid)); } } void Window::InvalidateRectangle(PRectangle rc) { - if (id) { - gtk_widget_queue_draw_area(PWidget(id), + if (wid) { + gtk_widget_queue_draw_area(PWidget(wid), rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); } @@ -1875,13 +1875,13 @@ void Window::SetCursor(Cursor curs) { break; } - if (PWidget(id)->window) - gdk_window_set_cursor(PWidget(id)->window, gdkCurs); + if (PWidget(wid)->window) + gdk_window_set_cursor(PWidget(wid)->window, gdkCurs); gdk_cursor_destroy(gdkCurs); } void Window::SetTitle(const char *s) { - gtk_window_set_title(GTK_WINDOW(id), s); + gtk_window_set_title(GTK_WINDOW(wid), s); } /* Returns rectangle of monitor pt is on, both rect and pt are in Window's @@ -1890,7 +1890,7 @@ PRectangle Window::GetMonitorRect(Point pt) { gint x_offset, y_offset; pt = pt; - gdk_window_get_origin(PWidget(id)->window, &x_offset, &y_offset); + gdk_window_get_origin(PWidget(wid)->window, &x_offset, &y_offset); // gtk 2.2+ #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 2) @@ -1899,7 +1899,7 @@ PRectangle Window::GetMonitorRect(Point pt) { gint monitor_num; GdkRectangle rect; - screen = gtk_widget_get_screen(PWidget(id)); + screen = gtk_widget_get_screen(PWidget(wid)); monitor_num = gdk_screen_get_monitor_at_point(screen, pt.x + x_offset, pt.y + y_offset); gdk_screen_get_monitor_geometry(screen, monitor_num, &rect); rect.x -= x_offset; @@ -2060,7 +2060,7 @@ static void StyleSet(GtkWidget *w, GtkStyle*, void*) { #endif void ListBoxX::Create(Window &, int, Point, int, bool) { - id = gtk_window_new(GTK_WINDOW_POPUP); + wid = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget *frame = gtk_frame_new(NULL); gtk_widget_show(frame); @@ -2129,7 +2129,7 @@ void ListBoxX::Create(Window &, int, Point, int, bool) { g_signal_connect(G_OBJECT(wid), "button_press_event", G_CALLBACK(ButtonPress), this); #endif - gtk_widget_realize(PWidget(id)); + gtk_widget_realize(PWidget(wid)); } void ListBoxX::SetFont(Font &scint_font) { @@ -2167,7 +2167,7 @@ int ListBoxX::GetVisibleRows() const { PRectangle ListBoxX::GetDesiredRect() { // Before any size allocated pretend its 100 wide so not scrolled PRectangle rc(0, 0, 100, 100); - if (id) { + if (wid) { int rows = Length(); if ((rows == 0) || (rows > desiredVisibleRows)) rows = desiredVisibleRows; @@ -2316,7 +2316,7 @@ void ListBoxX::Append(char *s, int type) { } int ListBoxX::Length() { - if (id) + if (wid) #if GTK_MAJOR_VERSION < 2 return GTK_CLIST(list)->rows; #else @@ -2538,27 +2538,27 @@ void ListBoxX::SetList(const char *listText, char separator, char typesep) { } } -Menu::Menu() : id(0) {} +Menu::Menu() : mid(0) {} void Menu::CreatePopUp() { Destroy(); - id = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL); + mid = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL); } void Menu::Destroy() { - if (id) + if (mid) #if GTK_MAJOR_VERSION < 2 - gtk_object_unref(GTK_OBJECT(id)); + gtk_object_unref(GTK_OBJECT(mid)); #else - g_object_unref(G_OBJECT(id)); + g_object_unref(G_OBJECT(mid)); #endif - id = 0; + mid = 0; } void Menu::Show(Point pt, Window &) { int screenHeight = gdk_screen_height(); int screenWidth = gdk_screen_width(); - GtkItemFactory *factory = reinterpret_cast<GtkItemFactory *>(id); + GtkItemFactory *factory = reinterpret_cast<GtkItemFactory *>(mid); GtkWidget *widget = gtk_item_factory_get_widget(factory, "<main>"); gtk_widget_show_all(widget); GtkRequisition requisition; diff --git a/include/Platform.h b/include/Platform.h index 98fd7e042..c552c170e 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -38,7 +38,10 @@ #define PLAT_GTK_WIN32 1 #endif -#elif defined(MACOSX) +#elif defined(__APPLE__) +#define SCI_NAMESPACE +#define SCI_LEXER + #undef PLAT_MACOSX #define PLAT_MACOSX 1 @@ -282,13 +285,13 @@ public: */ class Font { protected: - FontID id; + FontID fid; #if PLAT_WX int ascent; #endif // Private so Font objects can not be copied Font(const Font &) {} - Font &operator=(const Font &) { id=0; return *this; } + Font &operator=(const Font &) { fid=0; return *this; } public: Font(); virtual ~Font(); @@ -297,9 +300,9 @@ public: bool bold, bool italic, bool extraFontFlag=false); virtual void Release(); - FontID GetID() { return id; } + FontID GetID() { return fid; } // Alias another font - caller guarantees not to Release - void SetID(FontID id_) { id = id_; } + void SetID(FontID fid_) { fid = fid_; } friend class Surface; friend class SurfaceImpl; }; @@ -370,31 +373,31 @@ typedef void (*CallBackAction)(void*); */ class Window { protected: - WindowID id; + WindowID wid; #if PLAT_MACOSX void *windowRef; void *control; #endif public: - Window() : id(0), cursorLast(cursorInvalid) { + Window() : wid(0), cursorLast(cursorInvalid) { #if PLAT_MACOSX windowRef = 0; control = 0; #endif } - Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) { + Window(const Window &source) : wid(source.wid), cursorLast(cursorInvalid) { #if PLAT_MACOSX windowRef = 0; control = 0; #endif } virtual ~Window(); - Window &operator=(WindowID id_) { - id = id_; + Window &operator=(WindowID wid_) { + wid = wid_; return *this; } - WindowID GetID() const { return id; } - bool Created() const { return id != 0; } + WindowID GetID() const { return wid; } + bool Created() const { return wid != 0; } void Destroy(); bool HasFocus(); PRectangle GetPosition(); @@ -451,10 +454,10 @@ public: * Menu management. */ class Menu { - MenuID id; + MenuID mid; public: Menu(); - MenuID GetID() { return id; } + MenuID GetID() { return mid; } void CreatePopUp(); void Destroy(); void Show(Point pt, Window &w); diff --git a/macosx/PlatMacOSX.cxx b/macosx/PlatMacOSX.cxx index 7613e4f90..eb262da33 100644 --- a/macosx/PlatMacOSX.cxx +++ b/macosx/PlatMacOSX.cxx @@ -69,7 +69,7 @@ void Scintilla::Palette::Allocate(Window &/*w*/) { // OS X always runs in thousands or millions of colours } -Font::Font() : id(0) {} +Font::Font() : fid(0) {} Font::~Font() { Release(); } @@ -79,7 +79,7 @@ void Font::Create(const char *faceName, int /*characterSet*/, // TODO: How should I handle the characterSet request? Release(); - id = new QuartzTextStyle(); + fid = new QuartzTextStyle(); // Find the font QuartzFont font( faceName, strlen( faceName ) ); @@ -91,20 +91,20 @@ void Font::Create(const char *faceName, int /*characterSet*/, // Actually set the attributes QuartzTextStyleAttribute* attributes[] = { &font, &textSize, &isBold, &isItalic }; - reinterpret_cast<QuartzTextStyle*>( id )->setAttributes( attributes, sizeof( attributes ) / sizeof( *attributes ) ); + reinterpret_cast<QuartzTextStyle*>( fid )->setAttributes( attributes, sizeof( attributes ) / sizeof( *attributes ) ); //ATSStyleRenderingOptions rendering = kATSStyleNoAntiAliasing; - //reinterpret_cast<QuartzTextStyle*>( id )->setAttribute( kATSUStyleRenderingOptionsTag, sizeof( rendering ), &rendering ); + //reinterpret_cast<QuartzTextStyle*>( fid )->setAttribute( kATSUStyleRenderingOptionsTag, sizeof( rendering ), &rendering ); // TODO: Why do I have to manually set this? - reinterpret_cast<QuartzTextStyle*>( id )->setFontFeature( kLigaturesType, kCommonLigaturesOffSelector ); + reinterpret_cast<QuartzTextStyle*>( fid )->setFontFeature( kLigaturesType, kCommonLigaturesOffSelector ); } void Font::Release() { - if (id) - delete reinterpret_cast<QuartzTextStyle*>( id ); + if (fid) + delete reinterpret_cast<QuartzTextStyle*>( fid ); - id = 0; + fid = 0; } SurfaceImpl::SurfaceImpl() { @@ -843,12 +843,12 @@ void Window::Destroy() { if (windowRef) { DisposeWindow(reinterpret_cast<WindowRef>( windowRef )); } - id = 0; + wid = 0; } bool Window::HasFocus() { // TODO: Test this - return HIViewSubtreeContainsFocus( reinterpret_cast<HIViewRef>( id ) ); + return HIViewSubtreeContainsFocus( reinterpret_cast<HIViewRef>( wid ) ); } PRectangle Window::GetPosition() { @@ -856,9 +856,9 @@ PRectangle Window::GetPosition() { PRectangle rc(0, 0, 1000, 1000); // The frame rectangle gives the position of this view inside the parent view - if (id) { + if (wid) { HIRect controlFrame; - HIViewGetFrame( reinterpret_cast<HIViewRef>( id ), &controlFrame ); + HIViewGetFrame( reinterpret_cast<HIViewRef>( wid ), &controlFrame ); rc = CGRectToPRectangle( controlFrame ); } @@ -867,11 +867,11 @@ PRectangle Window::GetPosition() { void Window::SetPosition(PRectangle rc) { // Moves this view inside the parent view - if ( id ) + if ( wid ) { // Set the frame on the view, the function handles the rest CGRect r = PRectangleToCGRect( rc ); - HIViewSetFrame( reinterpret_cast<HIViewRef>( id ), &r ); + HIViewSetFrame( reinterpret_cast<HIViewRef>( wid ), &r ); } } @@ -917,8 +917,8 @@ PRectangle Window::GetClientPosition() { } void Window::Show(bool show) { - if ( id ) { - HIViewSetVisible( reinterpret_cast<HIViewRef>( id ), show ); + if ( wid ) { + HIViewSetVisible( reinterpret_cast<HIViewRef>( wid ), show ); } // this is necessary for calltip/listbox if (windowRef) { @@ -932,19 +932,19 @@ void Window::Show(bool show) { } void Window::InvalidateAll() { - if ( id ) { - HIViewSetNeedsDisplay( reinterpret_cast<HIViewRef>( id ), true ); + if ( wid ) { + HIViewSetNeedsDisplay( reinterpret_cast<HIViewRef>( wid ), true ); } } void Window::InvalidateRectangle(PRectangle rc) { - if (id) { + if (wid) { // Create a rectangular region RgnHandle region = NewRgn(); SetRectRgn( region, rc.left, rc.top, rc.right, rc.bottom ); // Make that region invalid - HIViewSetNeedsDisplayInRegion( reinterpret_cast<HIViewRef>( id ), region, true ); + HIViewSetNeedsDisplayInRegion( reinterpret_cast<HIViewRef>( wid ), region, true ); DisposeRgn( region ); } } @@ -954,7 +954,7 @@ void Window::SetFont(Font &) { } void Window::SetCursor(Cursor curs) { - if (id) { + if (wid) { // TODO: This isn't really implemented correctly. I should be using // mouse tracking rectangles to only set the mouse cursor when it is over the control ThemeCursor cursor; @@ -987,7 +987,7 @@ void Window::SetCursor(Cursor curs) { } void Window::SetTitle(const char *s) { - WindowRef window = GetControlOwner(reinterpret_cast<HIViewRef>( id )); + WindowRef window = GetControlOwner(reinterpret_cast<HIViewRef>( wid )); CFStringRef title = CFStringCreateWithCString(kCFAllocatorDefault, s, kCFStringEncodingMacRoman); SetWindowTitleWithCFString(window, title); CFRelease(title); @@ -1206,7 +1206,7 @@ void ListBoxImpl::Create(Window &/*parent*/, int /*ctrlID*/, Scintilla::Point /* GetEventTypeCount( kWindowEvents ), kWindowEvents, this, &eventHandler ); - id = lb; + wid = lb; SetControlVisibility(lb, true, true); SetControl(lb); SetWindow(outWindow); @@ -1644,7 +1644,7 @@ void ListBoxImpl::ClearRegisteredImages() { xset.Clear(); } -Menu::Menu() : id(0) { } +Menu::Menu() : mid(0) { } void Menu::CreatePopUp() { // TODO: Could I just feed a constant menu ID parameter, or does @@ -1652,14 +1652,14 @@ void Menu::CreatePopUp() { static int nextMenuID = 1; Destroy(); OSStatus err; - err = CreateNewMenu( nextMenuID++, 0, reinterpret_cast<MenuRef*>( &id ) ); + err = CreateNewMenu( nextMenuID++, 0, reinterpret_cast<MenuRef*>( &mid ) ); } void Menu::Destroy() { - if ( id != NULL ) + if ( mid != NULL ) { - ReleaseMenu( reinterpret_cast<MenuRef>( id ) ); - id = NULL; + ReleaseMenu( reinterpret_cast<MenuRef>( mid ) ); + mid = NULL; } } @@ -1671,7 +1671,7 @@ void Menu::Show(Point pt, Window &) { globalPoint.h = pt.x; globalPoint.v = pt.y; OSStatus err; - err = ContextualMenuSelect( reinterpret_cast<MenuRef>( id ), globalPoint, + err = ContextualMenuSelect( reinterpret_cast<MenuRef>( mid ), globalPoint, false, kCMHelpItemRemoveHelp, NULL, NULL, &userSelection, &menuId, @@ -1719,8 +1719,8 @@ ColourDesired Platform::ChromeHighlight() { static Str255 PlatformDefaultFontName; const char *Platform::DefaultFont() { - long id = HighShortFromLong(GetScriptVariable(smCurrentScript, smScriptAppFondSize)); - FMGetFontFamilyName(id, PlatformDefaultFontName); + long fid = HighShortFromLong(GetScriptVariable(smCurrentScript, smScriptAppFondSize)); + FMGetFontFamilyName(fid, PlatformDefaultFontName); char* defaultFontName = (char*) PlatformDefaultFontName; defaultFontName[defaultFontName[0]+1] = 0; ++defaultFontName; diff --git a/macosx/makefile b/macosx/makefile index 462326965..963c4e4f6 100644 --- a/macosx/makefile +++ b/macosx/makefile @@ -36,7 +36,7 @@ DYN_FLAGS=$(LINK_FLAGS) -framework Carbon -bundle endif endif -OPTIONS=-Wall -Wno-missing-braces -Wno-char-subscripts -DSCI_NAMESPACE -DMACOSX -DSCI_LEXER +OPTIONS=-Wall -Wno-missing-braces -Wno-char-subscripts -DMACOSX #DEBUG = 1 @@ -86,7 +86,7 @@ clean: rm -f *.o $(COMPLIB) deps: - $(CC) -MM -DSCI_NAMESPACE -DMACOSX -DSCI_LEXER $(CXXFLAGS) $(INCLUDEDIRS) *.cxx ../src/*.cxx >deps.mak + $(CC) -MM -DMACOSX $(CXXFLAGS) $(INCLUDEDIRS) *.cxx ../src/*.cxx >deps.mak COMPLIB=DocumentAccessor.o WindowAccessor.o KeyWords.o StyleContext.o \ CharClassify.o Decoration.o Document.o CallTip.o PositionCache.o \ @@ -16,7 +16,7 @@ namespace Scintilla { * Hold a pixmap in XPM format. */ class XPM { - int id; // Assigned by container + int pid; // Assigned by container int height; int width; int nColours; @@ -42,8 +42,8 @@ public: /// Decompose image into runs and use FillRectangle for each run void Draw(Surface *surface, PRectangle &rc); char **InLinesForm() { return lines; } - void SetId(int id_) { id = id_; } - int GetId() { return id; } + void SetId(int pid_) { pid = pid_; } + int GetId() { return pid; } int GetHeight() { return height; } int GetWidth() { return width; } static const char **LinesFormFromTextForm(const char *textForm); diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 012d8a9af..54eb5e3cc 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -216,7 +216,7 @@ class FontCached : Font { static FontCached *first; public: static FontID FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_); - static void ReleaseId(FontID id_); + static void ReleaseId(FontID fid_); }; FontCached *FontCached::first = 0; @@ -225,7 +225,7 @@ FontCached::FontCached(const char *faceName_, int characterSet_, int size_, bool next(0), usage(0), hash(0) { SetLogFont(lf, faceName_, characterSet_, size_, bold_, italic_); hash = HashFont(faceName_, characterSet_, size_, bold_, italic_); - id = ::CreateFontIndirectA(&lf); + fid = ::CreateFontIndirectA(&lf); usage = 1; } @@ -239,9 +239,9 @@ bool FontCached::SameAs(const char *faceName_, int characterSet_, int size_, boo } void FontCached::Release() { - if (id) - ::DeleteObject(id); - id = 0; + if (fid) + ::DeleteObject(fid); + fid = 0; } FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) { @@ -252,7 +252,7 @@ FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int si if ((cur->hash == hashFind) && cur->SameAs(faceName_, characterSet_, size_, bold_, italic_)) { cur->usage++; - ret = cur->id; + ret = cur->fid; } } if (ret == 0) { @@ -260,18 +260,18 @@ FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int si if (fc) { fc->next = first; first = fc; - ret = fc->id; + ret = fc->fid; } } ::LeaveCriticalSection(&crPlatformLock); return ret; } -void FontCached::ReleaseId(FontID id_) { +void FontCached::ReleaseId(FontID fid_) { ::EnterCriticalSection(&crPlatformLock); FontCached **pcur=&first; for (FontCached *cur=first; cur; cur=cur->next) { - if (cur->id == id_) { + if (cur->fid == fid_) { cur->usage--; if (cur->usage == 0) { *pcur = cur->next; @@ -287,7 +287,7 @@ void FontCached::ReleaseId(FontID id_) { } Font::Font() { - id = 0; + fid = 0; } Font::~Font() { @@ -301,21 +301,21 @@ void Font::Create(const char *faceName, int characterSet, int size, #ifndef FONTS_CACHED LOGFONT lf; SetLogFont(lf, faceName, characterSet, size, bold, italic); - id = ::CreateFontIndirect(&lf); + fid = ::CreateFontIndirect(&lf); #else - id = FontCached::FindOrCreate(faceName, characterSet, size, bold, italic); + fid = FontCached::FindOrCreate(faceName, characterSet, size, bold, italic); #endif } void Font::Release() { #ifndef FONTS_CACHED - if (id) - ::DeleteObject(id); + if (fid) + ::DeleteObject(fid); #else - if (id) - FontCached::ReleaseId(id); + if (fid) + FontCached::ReleaseId(fid); #endif - id = 0; + fid = 0; } #ifdef SCI_NAMESPACE @@ -969,28 +969,28 @@ Window::~Window() { } void Window::Destroy() { - if (id) - ::DestroyWindow(reinterpret_cast<HWND>(id)); - id = 0; + if (wid) + ::DestroyWindow(reinterpret_cast<HWND>(wid)); + wid = 0; } bool Window::HasFocus() { - return ::GetFocus() == id; + return ::GetFocus() == wid; } PRectangle Window::GetPosition() { RECT rc; - ::GetWindowRect(reinterpret_cast<HWND>(id), &rc); + ::GetWindowRect(reinterpret_cast<HWND>(wid), &rc); return PRectangle(rc.left, rc.top, rc.right, rc.bottom); } void Window::SetPosition(PRectangle rc) { - ::SetWindowPos(reinterpret_cast<HWND>(id), + ::SetWindowPos(reinterpret_cast<HWND>(wid), 0, rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOZORDER|SWP_NOACTIVATE); } void Window::SetPositionRelative(PRectangle rc, Window w) { - LONG style = ::GetWindowLong(reinterpret_cast<HWND>(id), GWL_STYLE); + LONG style = ::GetWindowLong(reinterpret_cast<HWND>(wid), GWL_STYLE); if (style & WS_POPUP) { RECT rcOther; ::GetWindowRect(reinterpret_cast<HWND>(w.GetID()), &rcOther); @@ -1017,25 +1017,25 @@ void Window::SetPositionRelative(PRectangle rc, Window w) { PRectangle Window::GetClientPosition() { RECT rc={0,0,0,0}; - if (id) - ::GetClientRect(reinterpret_cast<HWND>(id), &rc); + if (wid) + ::GetClientRect(reinterpret_cast<HWND>(wid), &rc); return PRectangle(rc.left, rc.top, rc.right, rc.bottom); } void Window::Show(bool show) { if (show) - ::ShowWindow(reinterpret_cast<HWND>(id), SW_SHOWNOACTIVATE); + ::ShowWindow(reinterpret_cast<HWND>(wid), SW_SHOWNOACTIVATE); else - ::ShowWindow(reinterpret_cast<HWND>(id), SW_HIDE); + ::ShowWindow(reinterpret_cast<HWND>(wid), SW_HIDE); } void Window::InvalidateAll() { - ::InvalidateRect(reinterpret_cast<HWND>(id), NULL, FALSE); + ::InvalidateRect(reinterpret_cast<HWND>(wid), NULL, FALSE); } void Window::InvalidateRectangle(PRectangle rc) { RECT rcw = RectFromPRectangle(rc); - ::InvalidateRect(reinterpret_cast<HWND>(id), &rcw, FALSE); + ::InvalidateRect(reinterpret_cast<HWND>(wid), &rcw, FALSE); } static LRESULT Window_SendMessage(Window *w, UINT msg, WPARAM wParam=0, LPARAM lParam=0) { @@ -1089,7 +1089,7 @@ void Window::SetCursor(Cursor curs) { } void Window::SetTitle(const char *s) { - ::SetWindowTextA(reinterpret_cast<HWND>(id), s); + ::SetWindowTextA(reinterpret_cast<HWND>(wid), s); } /* Returns rectangle of monitor pt is on, both rect and pt are in Window's @@ -1329,7 +1329,7 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei HWND hwndParent = reinterpret_cast<HWND>(parent->GetID()); HINSTANCE hinstanceParent = GetWindowInstance(hwndParent); // Window created as popup so not clipped within parent client area - id = ::CreateWindowEx( + wid = ::CreateWindowEx( WS_EX_WINDOWEDGE, ListBoxX_ClassName, TEXT(""), WS_POPUP | WS_THICKFRAME, 100,100, 150,80, hwndParent, @@ -2007,22 +2007,22 @@ bool ListBoxX_Unregister() { return ::UnregisterClass(ListBoxX_ClassName, hinstPlatformRes) != 0; } -Menu::Menu() : id(0) { +Menu::Menu() : mid(0) { } void Menu::CreatePopUp() { Destroy(); - id = ::CreatePopupMenu(); + mid = ::CreatePopupMenu(); } void Menu::Destroy() { - if (id) - ::DestroyMenu(reinterpret_cast<HMENU>(id)); - id = 0; + if (mid) + ::DestroyMenu(reinterpret_cast<HMENU>(mid)); + mid = 0; } void Menu::Show(Point pt, Window &w) { - ::TrackPopupMenu(reinterpret_cast<HMENU>(id), + ::TrackPopupMenu(reinterpret_cast<HMENU>(mid), 0, pt.x - 4, pt.y, 0, reinterpret_cast<HWND>(w.GetID()), NULL); Destroy(); |