Ilya Moiseenko | 0c9ab7c | 2013-10-29 15:08:23 -0700 | [diff] [blame] | 1 | /* -*- Mode: objc; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 2 | /** |
| 3 | * Copyright (c) 2013-2014, Regents of the University of California, |
Ilya Moiseenko | 0c9ab7c | 2013-10-29 15:08:23 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 5 | * This file is part of NFD Control Center. See AUTHORS.md for complete list of NFD |
| 6 | * authors and contributors. |
| 7 | * |
| 8 | * NFD Control Center is free software: you can redistribute it and/or modify it under the |
| 9 | * terms of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * NFD Control Center is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 14 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with NFD |
| 17 | * Control Center, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * \author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html> |
| 20 | * \author Ilya Moiseenko <http://ilyamoiseenko.com/> |
Ilya Moiseenko | 0c9ab7c | 2013-10-29 15:08:23 -0700 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | #import "tight-menu-item-view.h" |
| 24 | |
| 25 | @implementation TightMenuItemView |
| 26 | |
| 27 | -(void)setStatus:(NSString*)value |
| 28 | { |
| 29 | status = value; |
| 30 | } |
| 31 | |
| 32 | - (void) drawRect:(NSRect)dirtyRect |
| 33 | { |
| 34 | [self setSubviews:[NSArray array]]; |
| 35 | |
| 36 | NSRect fullBounds = [self bounds]; |
| 37 | fullBounds.size.height += 4; |
| 38 | [[NSBezierPath bezierPathWithRect:fullBounds] setClip]; |
| 39 | |
| 40 | |
| 41 | [[NSColor colorWithCalibratedRed:(70.0f/255.0f) |
| 42 | green:(70.0f/255.0f) |
| 43 | blue:(70.0f/255.0f) |
| 44 | alpha:1.0] set]; |
| 45 | NSRectFill(fullBounds); |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 46 | |
Ilya Moiseenko | 0c9ab7c | 2013-10-29 15:08:23 -0700 | [diff] [blame] | 47 | NSTextField *connectionStatusText = [[NSTextField alloc] initWithFrame:[self bounds]]; |
| 48 | [connectionStatusText setTextColor:[NSColor whiteColor]]; |
| 49 | [connectionStatusText setStringValue:status]; |
| 50 | [connectionStatusText setEditable:NO]; |
| 51 | [connectionStatusText setBezeled:NO]; |
| 52 | [connectionStatusText setDrawsBackground:NO]; |
| 53 | [connectionStatusText setSelectable:NO]; |
| 54 | [connectionStatusText setAlignment:NSCenterTextAlignment]; |
| 55 | NSFont *theFont = [NSFont fontWithName:@"Lucida Grande" size:14]; |
| 56 | [connectionStatusText setFont:theFont]; |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 57 | |
Ilya Moiseenko | 0c9ab7c | 2013-10-29 15:08:23 -0700 | [diff] [blame] | 58 | [self addSubview: connectionStatusText]; |
| 59 | } |
| 60 | |
| 61 | |
| 62 | @end |