Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 Savoir-faire Linux Inc. |
| 3 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | */ |
| 19 | |
| 20 | #import "IMTableCellView.h" |
| 21 | |
| 22 | #import "NSColor+RingTheme.h" |
| 23 | |
| 24 | @implementation IMTableCellView |
| 25 | @synthesize msgView; |
| 26 | @synthesize photoView; |
| 27 | |
| 28 | |
| 29 | - (void) setup |
| 30 | { |
| 31 | if ([self.identifier isEqualToString:@"RightMessageView"]) { |
Kateryna Kostiuk | 58276bc | 2017-06-07 08:50:48 -0400 | [diff] [blame] | 32 | self.msgBackground.pointerDirection = RIGHT; |
Kateryna Kostiuk | 3308987 | 2017-07-14 16:43:59 -0400 | [diff] [blame] | 33 | self.msgBackground.bgColor = [NSColor ringLightBlue]; |
Kateryna Kostiuk | 58276bc | 2017-06-07 08:50:48 -0400 | [diff] [blame] | 34 | |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 35 | } |
Kateryna Kostiuk | 58276bc | 2017-06-07 08:50:48 -0400 | [diff] [blame] | 36 | else { |
| 37 | self.msgBackground.pointerDirection = LEFT; |
| 38 | self.msgBackground.bgColor = [NSColor whiteColor]; |
| 39 | } |
| 40 | [self.msgView setBackgroundColor:[NSColor clearColor]]; |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 41 | [self.msgView setString:@""]; |
| 42 | [self.msgView setAutoresizingMask:NSViewWidthSizable]; |
Kateryna Kostiuk | 58276bc | 2017-06-07 08:50:48 -0400 | [diff] [blame] | 43 | [self.msgView setAutoresizingMask:NSViewHeightSizable]; |
| 44 | [self.msgBackground setAutoresizingMask:NSViewWidthSizable]; |
| 45 | [self.msgBackground setAutoresizingMask:NSViewHeightSizable]; |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 46 | [self.msgView setEnabledTextCheckingTypes:NSTextCheckingTypeLink]; |
| 47 | [self.msgView setAutomaticLinkDetectionEnabled:YES]; |
Kateryna Kostiuk | 58276bc | 2017-06-07 08:50:48 -0400 | [diff] [blame] | 48 | } |
Alexandre Lision | 0f66bd3 | 2016-01-18 11:30:45 -0500 | [diff] [blame] | 49 | |
| 50 | - (void) updateWidthConstraint:(CGFloat) newWidth |
| 51 | { |
| 52 | [self.msgView removeConstraints:[self.msgView constraints]]; |
| 53 | NSLayoutConstraint* constraint = [NSLayoutConstraint |
| 54 | constraintWithItem:self.msgView |
| 55 | attribute:NSLayoutAttributeWidth |
| 56 | relatedBy:NSLayoutRelationEqual |
| 57 | toItem: nil |
| 58 | attribute:NSLayoutAttributeWidth |
| 59 | multiplier:1.0f |
| 60 | constant:newWidth]; |
| 61 | |
| 62 | [self.msgView addConstraint:constraint]; |
| 63 | } |
| 64 | |
| 65 | @end |