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
commita0cd9e4e57d2d9a5ffa1ca898cca0dd6954298c5 (patch)
treed68aa18a574f08452cf935dd85ca47a4a9adf7ad
parent32e45fe23c42df8534267ce36724bf30f36b17dd (diff)
downloadscintilla-mirror-a0cd9e4e57d2d9a5ffa1ca898cca0dd6954298c5.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