blob: 4b8bd07aaa6a0a8ed33be59df329ac2b048674dc [file] [log] [blame]
Alexandre Lision0f66bd32016-01-18 11:30:45 -05001/*
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 Kostiuk58276bc2017-06-07 08:50:48 -040032 self.msgBackground.pointerDirection = RIGHT;
33 self.msgBackground.bgColor = [NSColor ringBlue];
34
Alexandre Lision0f66bd32016-01-18 11:30:45 -050035 }
Kateryna Kostiuk58276bc2017-06-07 08:50:48 -040036 else {
37 self.msgBackground.pointerDirection = LEFT;
38 self.msgBackground.bgColor = [NSColor whiteColor];
39 }
40 [self.msgView setBackgroundColor:[NSColor clearColor]];
Alexandre Lision0f66bd32016-01-18 11:30:45 -050041 [self.msgView setString:@""];
42 [self.msgView setAutoresizingMask:NSViewWidthSizable];
Kateryna Kostiuk58276bc2017-06-07 08:50:48 -040043 [self.msgView setAutoresizingMask:NSViewHeightSizable];
44 [self.msgBackground setAutoresizingMask:NSViewWidthSizable];
45 [self.msgBackground setAutoresizingMask:NSViewHeightSizable];
Alexandre Lision0f66bd32016-01-18 11:30:45 -050046 [self.msgView setEnabledTextCheckingTypes:NSTextCheckingTypeLink];
47 [self.msgView setAutomaticLinkDetectionEnabled:YES];
Kateryna Kostiuk58276bc2017-06-07 08:50:48 -040048 }
Alexandre Lision0f66bd32016-01-18 11:30:45 -050049
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