Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 1 | /* |
Anthony Léonard | e7d62ed | 2018-01-25 10:51:47 -0500 | [diff] [blame] | 2 | * Copyright (C) 2016-2018 Savoir-faire Linux Inc. |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 3 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
Anthony Léonard | e7d62ed | 2018-01-25 10:51:47 -0500 | [diff] [blame] | 4 | * Author: Anthony Léonard <anthony.leonard@savoirfairelinux.com> |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | */ |
| 20 | |
| 21 | #import "IMTableCellView.h" |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 22 | #import "NSColor+RingTheme.h" |
| 23 | |
Anthony Léonard | e7d62ed | 2018-01-25 10:51:47 -0500 | [diff] [blame] | 24 | @implementation IMTableCellView { |
| 25 | uint64_t interaction; |
| 26 | } |
| 27 | |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 28 | @synthesize msgView; |
| 29 | @synthesize photoView; |
Anthony Léonard | e7d62ed | 2018-01-25 10:51:47 -0500 | [diff] [blame] | 30 | @synthesize acceptButton; |
| 31 | @synthesize declineButton; |
| 32 | @synthesize progressIndicator; |
| 33 | @synthesize statusLabel; |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 34 | |
Anthony Léonard | e7d62ed | 2018-01-25 10:51:47 -0500 | [diff] [blame] | 35 | - (void) setupDirection |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 36 | { |
Anthony Léonard | e7d62ed | 2018-01-25 10:51:47 -0500 | [diff] [blame] | 37 | if ([self.identifier containsString:@"Right"]) { |
Kateryna Kostiuk | 58276bc | 2017-06-07 08:50:48 -0400 | [diff] [blame] | 38 | self.msgBackground.pointerDirection = RIGHT; |
Kateryna Kostiuk | 3308987 | 2017-07-14 16:43:59 -0400 | [diff] [blame] | 39 | self.msgBackground.bgColor = [NSColor ringLightBlue]; |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 40 | } |
Kateryna Kostiuk | 58276bc | 2017-06-07 08:50:48 -0400 | [diff] [blame] | 41 | else { |
| 42 | self.msgBackground.pointerDirection = LEFT; |
| 43 | self.msgBackground.bgColor = [NSColor whiteColor]; |
| 44 | } |
Anthony Léonard | e7d62ed | 2018-01-25 10:51:47 -0500 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | - (void) setupForInteraction:(uint64_t)inter |
| 48 | { |
| 49 | interaction = inter; |
| 50 | [self setupDirection]; |
Kateryna Kostiuk | 58276bc | 2017-06-07 08:50:48 -0400 | [diff] [blame] | 51 | [self.msgView setBackgroundColor:[NSColor clearColor]]; |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 52 | [self.msgView setString:@""]; |
| 53 | [self.msgView setAutoresizingMask:NSViewWidthSizable]; |
Anthony Léonard | 3ad4811 | 2018-01-19 11:57:21 -0500 | [diff] [blame] | 54 | [self.msgView setAutoresizingMask:NSViewHeightSizable]; |
Kateryna Kostiuk | 58276bc | 2017-06-07 08:50:48 -0400 | [diff] [blame] | 55 | [self.msgBackground setAutoresizingMask:NSViewWidthSizable]; |
| 56 | [self.msgBackground setAutoresizingMask:NSViewHeightSizable]; |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 57 | [self.msgView setEnabledTextCheckingTypes:NSTextCheckingTypeLink]; |
| 58 | [self.msgView setAutomaticLinkDetectionEnabled:YES]; |
Anthony Léonard | e7d62ed | 2018-01-25 10:51:47 -0500 | [diff] [blame] | 59 | [self.msgView setEditable:NO]; |
| 60 | if ([self.identifier containsString:@"Message"]) { |
| 61 | [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-5-[msgView]" |
| 62 | options:0 |
| 63 | metrics:nil |
| 64 | views:NSDictionaryOfVariableBindings(msgView)]]; |
| 65 | } |
| 66 | } |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 67 | |
| 68 | - (void) updateWidthConstraint:(CGFloat) newWidth |
| 69 | { |
| 70 | [self.msgView removeConstraints:[self.msgView constraints]]; |
| 71 | NSLayoutConstraint* constraint = [NSLayoutConstraint |
| 72 | constraintWithItem:self.msgView |
| 73 | attribute:NSLayoutAttributeWidth |
| 74 | relatedBy:NSLayoutRelationEqual |
| 75 | toItem: nil |
| 76 | attribute:NSLayoutAttributeWidth |
| 77 | multiplier:1.0f |
| 78 | constant:newWidth]; |
| 79 | |
| 80 | [self.msgView addConstraint:constraint]; |
| 81 | } |
| 82 | |
Anthony Léonard | e7d62ed | 2018-01-25 10:51:47 -0500 | [diff] [blame] | 83 | - (uint64_t)interaction |
| 84 | { |
| 85 | return interaction; |
| 86 | } |
| 87 | |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 88 | @end |