Thread: [zephyrchat-cvs] zchat/zChat AKStackedView.h,1.1,1.2 AKStackedView.m,1.2,1.3 ZChatFriendViewControll
Status: Alpha
                
                Brought to you by:
                
                    akosut
                    
                
            | 
     
      
      
      From: <ak...@us...> - 2003-03-28 22:19:11
       
   | 
Update of /cvsroot/zephyrchat/zchat/zChat
In directory sc8-pr-cvs1:/tmp/cvs-serv27034
Modified Files:
	AKStackedView.h AKStackedView.m ZChatFriendViewController.h 
	ZChatFriendViewController.mm 
Log Message:
Nearly-complete location list implementation using NSMatrix.
Index: AKStackedView.h
===================================================================
RCS file: /cvsroot/zephyrchat/zchat/zChat/AKStackedView.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- AKStackedView.h	19 Mar 2003 02:46:10 -0000	1.1
+++ AKStackedView.h	28 Mar 2003 22:18:31 -0000	1.2
@@ -20,6 +20,9 @@
     IBOutlet id <AKStackedViewDelegate> _delegate;
 }
 
+- (IBAction)action:(id)sender;
+- (IBAction)doubleAction:(id)sender;
+
 - (void)setDelegate:(id <AKStackedViewDelegate>)delegate;
 - (id)delegate;
 
Index: AKStackedView.m
===================================================================
RCS file: /cvsroot/zephyrchat/zchat/zChat/AKStackedView.m,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- AKStackedView.m	25 Mar 2003 14:53:03 -0000	1.2
+++ AKStackedView.m	28 Mar 2003 22:18:31 -0000	1.3
@@ -54,6 +54,10 @@
     [[self superview] displayIfNeeded];
 }
 
+- (IBAction)action:(id)sender {
+    [self mouseDown:[[sender window] currentEvent]];   
+}
+
 - (void)mouseDown:(NSEvent *)event {
     if (_delegate != nil) {
         if ([_delegate selectViewIsSelected:self] && [event modifierFlags] & NSCommandKeyMask) {
@@ -70,8 +74,12 @@
 
 - (void)mouseUp:(NSEvent *)event {
     if ([event clickCount] == 2 && [_delegate respondsToSelector:@selector(selectViewAction:)]) {
-        [_delegate selectViewAction:self];
+        [self doubleAction:nil];
     }
+}
+
+- (IBAction)doubleAction:(id)sender {
+    [_delegate selectViewAction:self];
 }
 
 - (void)setDelegate:(id <AKStackedViewDelegate>)delegate {
Index: ZChatFriendViewController.h
===================================================================
RCS file: /cvsroot/zephyrchat/zchat/zChat/ZChatFriendViewController.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ZChatFriendViewController.h	28 Mar 2003 18:59:54 -0000	1.10
+++ ZChatFriendViewController.h	28 Mar 2003 22:18:32 -0000	1.11
@@ -21,7 +21,7 @@
 
     IBOutlet NSView *_expandedView;
     IBOutlet NSTextField *_expandedTitle;
-    IBOutlet NSTableView *_locationTable;
+    IBOutlet NSMatrix *_locationMatrix;
     
     NSString *_user;
 
Index: ZChatFriendViewController.mm
===================================================================
RCS file: /cvsroot/zephyrchat/zchat/zChat/ZChatFriendViewController.mm,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- ZChatFriendViewController.mm	28 Mar 2003 18:59:54 -0000	1.18
+++ ZChatFriendViewController.mm	28 Mar 2003 22:18:32 -0000	1.19
@@ -50,6 +50,7 @@
 }
 
 - (void)awakeFromNib {
+    [_locationMatrix setDoubleAction:@selector(doubleAction:)];
     [self updateNames];
 }
 
@@ -128,16 +129,29 @@
 - (void)locateSuccess:(const vector<zephyrlib::ZephyrLocation> &)locations {
     *_locations = locations;
 
+    if (!_locations->empty()) {
+        /* The first row in the matrix is the header */
+        [_locationMatrix renewRows:_locations->size() + 1 columns:3];
+        NSAssert([_locationMatrix numberOfRows] >= 2, @"Location matrix should always have at least two rows");
 
-    [_locationTable reloadData];
-    [_expandedView setFrameSize:NSMakeSize([_expandedView frame].size.width,
-                                           [_expandedView frame].size.height - [_locationTable frame].size.height
-                                           + ([_locationTable numberOfRows]
-                                              * ([_locationTable rowHeight]
-                                                 + [_locationTable intercellSpacing].height))
-                                           )];
-    [_expandedView setNeedsDisplay:YES];
-        
+        for (unsigned i = 0; i < _locations->size(); ++i) {
+            ZephyrLocation &location = (*_locations)[i];
+            [[_locationMatrix cellAtRow:i + 1 column:0] setObjectValue:
+                [NSString stringWithSTLString:location.machine_name]];
+            [[_locationMatrix cellAtRow:i + 1 column:1] setObjectValue:
+                [NSString stringWithSTLString:location.terminal]];
+            [[_locationMatrix cellAtRow:i + 1 column:2] setObjectValue:
+                [NSString stringWithSTLString:location.login_time]];
+        }
+            
+        [_locationMatrix sizeToCells];
+
+        /* We shouldn't have to hard-code 20.  But I'm having a tough time fixing this one */
+        [_expandedView setFrameSize:NSMakeSize(NSWidth([_expandedView frame]),
+                                               20 + NSHeight([_locationMatrix frame]))];
+        [_expandedView setNeedsDisplay:YES];
+    }
+            
     // TODO
 
     _busy = false;
@@ -238,35 +252,6 @@
     }
     
     return email;
-}
-
-- (int)numberOfRowsInTableView:(NSTableView *)tableView {
-    return _locations->size();
-}
-
-- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row {
-    if (tableView == _locationTable) {
-        ZephyrLocation &location = (*_locations)[row];
-        switch ([[tableView tableColumns] indexOfObject:tableColumn]) {
-            case 0:
-                return [NSString stringWithSTLString:location.machine_name];
-            case 1:
-                return [NSString stringWithSTLString:location.terminal];
-            case 2:
-                return [NSString stringWithSTLString:location.login_time];
-        }
-    }
-        
-    return nil;
-}
-
-- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row {
-    if (tableView == _locationTable) {
-        /* Do not allow expanded view table to be selected */
-        return NO;
-    }
-
-    return YES;
 }
 
 @end
 |