| 1 |
/* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ |
| 2 |
|
| 3 |
/* Aiksaurus / Cocoa front-end |
| 4 |
* Copyright (C) 2003 Francis James Franklin <[email protected]> |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU General Public License |
| 8 |
* as published by the Free Software Foundation; either version 2 |
| 9 |
* of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 |
* 02111-1307, USA. |
| 20 |
*/ |
| 21 |
|
| 22 |
#import <Cocoa/Cocoa.h> |
| 23 |
|
| 24 |
@interface AiksaurusCocoaMeaning : NSObject |
| 25 |
{ |
| 26 |
BOOL m_titles; |
| 27 |
|
| 28 |
NSString * m_title_1; |
| 29 |
NSString * m_title_2; |
| 30 |
|
| 31 |
NSMutableArray * m_synonyms; |
| 32 |
|
| 33 |
int m_rows; |
| 34 |
} |
| 35 |
- (id)initWithoutTitles; |
| 36 |
- (id)initWithTitle:(NSString *)title withAlternativeTitle:(NSString *)alt; |
| 37 |
- (void)dealloc; |
| 38 |
|
| 39 |
- (void)synonymAdd:(NSString *)synonym; |
| 40 |
- (NSString *)synonymAtPosition:(unsigned)position; |
| 41 |
- (unsigned)synonyms; |
| 42 |
|
| 43 |
- (NSString *)clickColumn:(int)column atRow:(int)row; |
| 44 |
|
| 45 |
- (int)numberOfRowsInTableView; |
| 46 |
- (NSString *)objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex; |
| 47 |
@end |
| 48 |
|
| 49 |
@interface AiksaurusCocoa : NSObject |
| 50 |
{ |
| 51 |
void * m_aiksaurus; |
| 52 |
|
| 53 |
unsigned m_length; |
| 54 |
int m_position; |
| 55 |
|
| 56 |
NSMutableArray * m_history; |
| 57 |
NSMutableArray * m_meanings; |
| 58 |
|
| 59 |
int m_rows; |
| 60 |
int m_highlight_row; |
| 61 |
int m_highlight_col; |
| 62 |
} |
| 63 |
- (id)init; |
| 64 |
- (void)dealloc; |
| 65 |
|
| 66 |
- (BOOL)okay; |
| 67 |
- (NSString *)lastError; |
| 68 |
|
| 69 |
- (BOOL)historyBack; |
| 70 |
- (BOOL)historyForward; |
| 71 |
- (BOOL)historyCanGoBack; |
| 72 |
- (BOOL)historyCanGoForward; |
| 73 |
|
| 74 |
- (void)setWord:(NSString *)word reorderHistory:(BOOL)reorder; |
| 75 |
- (NSString *)word; |
| 76 |
|
| 77 |
- (BOOL)lookupWord:(NSString *)word reorderHistory:(BOOL)reorder; |
| 78 |
|
| 79 |
- (AiksaurusCocoaMeaning *)meaningAtPosition:(unsigned)position; |
| 80 |
- (unsigned)meanings; |
| 81 |
|
| 82 |
- (NSString *)clickColumn:(int)column atRow:(int)row; |
| 83 |
|
| 84 |
/* NSTableDataSource informal protocol |
| 85 |
*/ |
| 86 |
- (int)numberOfRowsInTableView:(NSTableView *)aTableView; |
| 87 |
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex; |
| 88 |
|
| 89 |
/* NSTableView delegate |
| 90 |
*/ |
| 91 |
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex; |
| 92 |
- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)rowIndex; |
| 93 |
@end |
| 94 |
|
| 95 |
@interface AiksaurusCocoaPanel : NSWindowController |
| 96 |
{ |
| 97 |
AiksaurusCocoa * m_aiksaurus; |
| 98 |
|
| 99 |
IBOutlet NSButton * oBack; |
| 100 |
IBOutlet NSButton * oForward; |
| 101 |
IBOutlet NSPopUpButton * oHistory; |
| 102 |
IBOutlet NSButton * oInsert; |
| 103 |
IBOutlet NSPanel * oPanel; |
| 104 |
IBOutlet NSTableView * oResultsTable; |
| 105 |
IBOutlet NSTextField * oSearchField; |
| 106 |
IBOutlet NSTextField * oStatus; |
| 107 |
|
| 108 |
id m_target; |
| 109 |
SEL m_action; |
| 110 |
} |
| 111 |
- (id)init; |
| 112 |
- (void)dealloc; |
| 113 |
|
| 114 |
- (void)lookupWord:(NSString *)word; |
| 115 |
|
| 116 |
- (void)sync; |
| 117 |
|
| 118 |
- (IBAction)aBack:(id)sender; |
| 119 |
- (IBAction)aForward:(id)sender; |
| 120 |
- (IBAction)aHistory:(id)sender; |
| 121 |
- (IBAction)aDoubleClick:(id)sender; |
| 122 |
- (IBAction)aResultsTable:(id)sender; |
| 123 |
- (IBAction)aSearch:(id)sender; |
| 124 |
- (IBAction)aSearchField:(id)sender; |
| 125 |
|
| 126 |
- (IBAction)aInsert:(id)sender; |
| 127 |
|
| 128 |
/* and, where target's action method has the form @selector(insertWord:), i.e. |
| 129 |
- (void)insertWord:(NSString *)word; |
| 130 |
*/ |
| 131 |
- (void)setTargetForInsert:(id)target withAction:(SEL)action; |
| 132 |
|
| 133 |
@end |