aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <nyamatongwe@gmail.com>2012-07-15 10:52:45 +1000
committernyamatongwe <nyamatongwe@gmail.com>2012-07-15 10:52:45 +1000
commitce92ec12ea4a0c199eed176c636912f5b3596eef (patch)
tree958225f9df453f238cb08a5c5860612707a57302
parent71e3d0e5595cb606910c625e8d5ab1322ae22fd4 (diff)
downloadscintilla-mirror-ce92ec12ea4a0c199eed176c636912f5b3596eef.tar.gz
Use unnamed namespace so that ListBox implementation is not visible outside this file.
Use IListBox interface to limit exposure of ListBoxImpl to AutoCompletionDataSource. Changes only affect visibility and declarations with no change to functionality.
-rw-r--r--cocoa/PlatCocoa.mm167
1 files changed, 91 insertions, 76 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index 7b9f976c4..00380ffbc 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -1351,19 +1351,85 @@ static NSImage* ImageFromXPM(XPM* pxpm)
return img;
}
-//----------------- ListBox ------------------------------------------------------------------------
+//----------------- ListBox and related classes ----------------------------------------------------
-ListBox::ListBox()
+namespace {
+
+// unnamed namespace hides IListBox interface
+
+class IListBox {
+public:
+ virtual int Rows() = 0;
+ virtual NSImage* ImageForRow(NSInteger row) = 0;
+ virtual NSString* TextForRow(NSInteger row) = 0;
+ virtual void DoubleClick() = 0;
+};
+
+} // unnamed namespace
+
+//----------------- AutoCompletionDataSource -------------------------------------------------------
+
+@interface AutoCompletionDataSource :
+NSObject
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
+<NSTableViewDataSource>
+#endif
{
+ IListBox* box;
}
-//--------------------------------------------------------------------------------------------------
+@property IListBox* box;
-ListBox::~ListBox()
+@end
+
+@implementation AutoCompletionDataSource
+
+@synthesize box;
+
+- (void) doubleClick: (id) sender
{
+#pragma unused(sender)
+ if (box)
+ {
+ box->DoubleClick();
+ }
}
-//--------------------------------------------------------------------------------------------------
+- (id)tableView: (NSTableView*)aTableView objectValueForTableColumn: (NSTableColumn*)aTableColumn row: (NSInteger)rowIndex
+{
+#pragma unused(aTableView)
+ if (!box)
+ return nil;
+ if ([(NSString*)[aTableColumn identifier] isEqualToString: @"icon"])
+ {
+ return box->ImageForRow(rowIndex);
+ }
+ else {
+ return box->TextForRow(rowIndex);
+ }
+}
+
+- (void)tableView: (NSTableView*)aTableView setObjectValue: anObject forTableColumn: (NSTableColumn*)aTableColumn row: (NSInteger)rowIndex
+{
+#pragma unused(aTableView)
+#pragma unused(anObject)
+#pragma unused(aTableColumn)
+#pragma unused(rowIndex)
+}
+
+- (NSInteger)numberOfRowsInTableView: (NSTableView*)aTableView
+{
+#pragma unused(aTableView)
+ if (!box)
+ return 0;
+ return box->Rows();
+}
+
+@end
+
+//----------------- ListBoxImpl --------------------------------------------------------------------
+
+namespace { // unnamed namespace hides ListBoxImpl and associated classes
struct RowData
{
@@ -1421,25 +1487,10 @@ public:
}
};
-class ListBoxImpl;
-
-@interface AutoCompletionDataSource :
-NSObject
-#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
-<NSTableViewDataSource>
-#endif
-{
- ListBoxImpl* box;
-}
-
-@end
-
-//----------------- ListBoxImpl --------------------------------------------------------------------
-
// Map from icon type to an NSImage*
typedef std::map<NSInteger, NSImage*> ImageMap;
-class ListBoxImpl : public ListBox
+class ListBoxImpl : public ListBox, IListBox
{
private:
ControlRef lb;
@@ -1496,67 +1547,13 @@ public:
}
void SetList(const char* list, char separator, char typesep);
- // For access from AutoCompletionDataSource
+ // For access from AutoCompletionDataSource implement IListBox
int Rows();
NSImage* ImageForRow(NSInteger row);
NSString* TextForRow(NSInteger row);
void DoubleClick();
};
-@implementation AutoCompletionDataSource
-
-- (void)setBox: (ListBoxImpl*)box_
-{
- box = box_;
-}
-
-- (void) doubleClick: (id) sender
-{
-#pragma unused(sender)
- if (box)
- {
- box->DoubleClick();
- }
-}
-
-- (id)tableView: (NSTableView*)aTableView objectValueForTableColumn: (NSTableColumn*)aTableColumn row: (NSInteger)rowIndex
-{
-#pragma unused(aTableView)
- if (!box)
- return nil;
- if ([(NSString*)[aTableColumn identifier] isEqualToString: @"icon"])
- {
- return box->ImageForRow(rowIndex);
- }
- else {
- return box->TextForRow(rowIndex);
- }
-}
-
-- (void)tableView: (NSTableView*)aTableView setObjectValue: anObject forTableColumn: (NSTableColumn*)aTableColumn row: (NSInteger)rowIndex
-{
-#pragma unused(aTableView)
-#pragma unused(anObject)
-#pragma unused(aTableColumn)
-#pragma unused(rowIndex)
-}
-
-- (NSInteger)numberOfRowsInTableView: (NSTableView*)aTableView
-{
-#pragma unused(aTableView)
- if (!box)
- return 0;
- return box->Rows();
-}
-
-@end
-
-ListBox* ListBox::Allocate()
-{
- ListBoxImpl* lb = new ListBoxImpl();
- return lb;
-}
-
void ListBoxImpl::Create(Window& /*parent*/, int /*ctrlID*/, Scintilla::Point pt,
int lineHeight_, bool unicodeMode_, int)
{
@@ -1869,6 +1866,24 @@ void ListBoxImpl::DoubleClick()
}
}
+} // unnamed namespace
+
+//----------------- ListBox ------------------------------------------------------------------------
+
+ListBox::ListBox()
+{
+}
+
+ListBox::~ListBox()
+{
+}
+
+ListBox* ListBox::Allocate()
+{
+ ListBoxImpl* lb = new ListBoxImpl();
+ return lb;
+}
+
//----------------- ScintillaContextMenu -----------------------------------------------------------
@implementation ScintillaContextMenu : NSMenu