Skip to content

Commit

Permalink
finish framework, now the menulet can be loaded, and popover window c…
Browse files Browse the repository at this point in the history
…an be shown
  • Loading branch information
zfdang committed Sep 25, 2014
1 parent eb4a878 commit 0e2c0f5
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 53 deletions.
2 changes: 1 addition & 1 deletion CLCMenuExtra/CLCMenuExtra/CLCMenuExtraView.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{
}

@property(strong, nonatomic) CLCPopoverViewController *control;
@property(strong, nonatomic) NSPopover *popover;
@property(strong, nonatomic) CLCCalendar *calendar;
@property BOOL active;

Expand Down
32 changes: 19 additions & 13 deletions CLCMenuExtra/CLCMenuExtra/CLCMenuExtraView.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "CLCMenuExtraView.h"
#import "CLCPopoverViewController.h"
#import "CLCPopController.h"
#import "CLCCalendar.h"

@interface CLCMenuExtraView()
Expand All @@ -20,7 +20,7 @@ @interface CLCMenuExtraView()

@implementation CLCMenuExtraView

@synthesize control;
@synthesize popover;
@synthesize active;
@synthesize calendar;

Expand All @@ -40,7 +40,7 @@ - (void)drawRect:(CGRect)rect
// init the status item popup
if(self.active)
{
[[NSColor blueColor] set];
[[NSColor brownColor] set];
} else {
[[NSColor blackColor] set];
}
Expand Down Expand Up @@ -84,21 +84,25 @@ - (void)mouseDown:(id)arg1
}
}

- (void) setupPopover
{
if(! self.popover)
{
self.popover = [[NSPopover alloc] init];
self.popover.contentViewController = [[CLCPopController alloc] initWithNibName:@"CLCPopController" bundle:_menuExtra.bundle];
}
}

- (void) showPopover
{
self.active = true;

if(!self.control)
{
self.control = [[CLCPopoverViewController alloc] initWithNibName:@"CLCPopoverViewController" bundle:nil];
}
if(self.control && self.control.popover)
{
// [self.control.popover showRelativeToRect:[self bounds] ofView:self preferredEdge:NSMaxYEdge];
}


[self setupPopover];

[self.popover showRelativeToRect:[self bounds]
ofView:self
preferredEdge:NSMinYEdge];

// if user click area outside of our menulet, hide the popover
_popoverTransiencyMonitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask|NSRightMouseDownMask handler:^(NSEvent* event) {
[self hidePopover];
Expand All @@ -112,6 +116,8 @@ - (void) hidePopover
{
self.active = false;

[self.popover performClose:nil];

// remove the monitor
[NSEvent removeMonitor:_popoverTransiencyMonitor];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// CLCPopoverViewController.h
// CLCPopController.h
// chinese lunar calendar
//
// Created by Zhengfa DANG on 9/25/14.
Expand All @@ -8,10 +8,6 @@

#import <Cocoa/Cocoa.h>

@interface CLCPopoverViewController : NSViewController
{
}

@property (retain) NSPopover *popover;
@interface CLCPopController : NSViewController

@end
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
//
// CLCPopoverViewController.m
// CLCPopController.m
// chinese lunar calendar
//
// Created by Zhengfa DANG on 9/25/14.
// Copyright (c) 2014 Zhengfa. All rights reserved.
//

#import "CLCPopoverViewController.h"
#import "CLCPopController.h"

@interface CLCPopoverViewController ()
@interface CLCPopController ()

@end

@implementation CLCPopoverViewController
@implementation CLCPopController

@synthesize popover;
- (void)viewDidLoad {
// [super viewDidLoad];
// Do view setup here.
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Initialization code here.
self.popover = [[NSPopover alloc] init];
self.popover.contentViewController = self;
}

return self;
}



@end
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,25 @@
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6245"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="CLCPopoverViewController">
<customObject id="-2" userLabel="File's Owner" customClass="CLCPopController">
<connections>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY" userLabel="PopoverView">
<customView id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cG3-v7-mWm">
<rect key="frame" x="202" y="128" width="77" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Hello World" id="XNA-Uu-cTI">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cf8-wy-Aea">
<rect key="frame" x="208" y="128" width="75" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="hello world" id="cUn-iH-U1u">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="TYJ-YS-eg6">
<rect key="frame" x="185" y="51" width="111" height="25"/>
<buttonCell key="cell" type="squareTextured" title="Dismissed" bezelStyle="texturedSquare" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="MVq-12-afI">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="dismissPopover:" target="-2" id="5MZ-3d-NeL"/>
</connections>
</button>
</subviews>
</customView>
</objects>
Expand Down
20 changes: 10 additions & 10 deletions CLCMenuExtra/chinese lunar calendar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
691657AC19D3F8410086C6D9 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 691657A819D3F8410086C6D9 /* [email protected] */; };
691657AD19D3F8410086C6D9 /* cloudgrey.png in Resources */ = {isa = PBXBuildFile; fileRef = 691657A919D3F8410086C6D9 /* cloudgrey.png */; };
691657AE19D3F8410086C6D9 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 691657AA19D3F8410086C6D9 /* [email protected] */; };
6985D80B19D4423F00343F35 /* CLCPopController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6985D80919D4423F00343F35 /* CLCPopController.m */; };
6985D80C19D4423F00343F35 /* CLCPopController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6985D80A19D4423F00343F35 /* CLCPopController.xib */; };
69C45CD219D3B17D004AC6DD /* CLCCalendar.m in Sources */ = {isa = PBXBuildFile; fileRef = 69C45CD119D3B17D004AC6DD /* CLCCalendar.m */; };
69C45CD619D3B230004AC6DD /* CLCPopoverViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 69C45CD419D3B230004AC6DD /* CLCPopoverViewController.m */; };
69C45CD719D3B230004AC6DD /* CLCPopoverViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 69C45CD519D3B230004AC6DD /* CLCPopoverViewController.xib */; };
69D8B52019D27A3E00A75B32 /* SystemUIPlugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 69D8B51F19D27A3E00A75B32 /* SystemUIPlugin.framework */; };
69D8B52419D27AF900A75B32 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 69D8B52319D27AF900A75B32 /* Cocoa.framework */; };
69D8B53D19D290E400A75B32 /* CLCMenuExtra.m in Sources */ = {isa = PBXBuildFile; fileRef = 69D8B53A19D290E400A75B32 /* CLCMenuExtra.m */; };
Expand All @@ -25,11 +25,11 @@
691657A819D3F8410086C6D9 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "CLCMenuExtra/Resources/[email protected]"; sourceTree = "<group>"; };
691657A919D3F8410086C6D9 /* cloudgrey.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = cloudgrey.png; path = CLCMenuExtra/Resources/cloudgrey.png; sourceTree = "<group>"; };
691657AA19D3F8410086C6D9 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "CLCMenuExtra/Resources/[email protected]"; sourceTree = "<group>"; };
6985D80819D4423F00343F35 /* CLCPopController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLCPopController.h; path = CLCMenuExtra/CLCPopController.h; sourceTree = "<group>"; };
6985D80919D4423F00343F35 /* CLCPopController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLCPopController.m; path = CLCMenuExtra/CLCPopController.m; sourceTree = "<group>"; };
6985D80A19D4423F00343F35 /* CLCPopController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = CLCPopController.xib; path = CLCMenuExtra/CLCPopController.xib; sourceTree = "<group>"; };
69C45CD019D3B17D004AC6DD /* CLCCalendar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLCCalendar.h; path = CLCMenuExtra/CLCCalendar.h; sourceTree = "<group>"; };
69C45CD119D3B17D004AC6DD /* CLCCalendar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLCCalendar.m; path = CLCMenuExtra/CLCCalendar.m; sourceTree = "<group>"; };
69C45CD319D3B230004AC6DD /* CLCPopoverViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLCPopoverViewController.h; path = CLCMenuExtra/CLCPopoverViewController.h; sourceTree = "<group>"; };
69C45CD419D3B230004AC6DD /* CLCPopoverViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLCPopoverViewController.m; path = CLCMenuExtra/CLCPopoverViewController.m; sourceTree = "<group>"; };
69C45CD519D3B230004AC6DD /* CLCPopoverViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = CLCPopoverViewController.xib; path = CLCMenuExtra/CLCPopoverViewController.xib; sourceTree = "<group>"; };
69D8B51519D278A900A75B32 /* CLCMenuExtra.menu */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CLCMenuExtra.menu; sourceTree = BUILT_PRODUCTS_DIR; };
69D8B51919D278A900A75B32 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
69D8B51F19D27A3E00A75B32 /* SystemUIPlugin.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SystemUIPlugin.framework; sourceTree = "<group>"; };
Expand Down Expand Up @@ -120,9 +120,8 @@
69D8B53A19D290E400A75B32 /* CLCMenuExtra.m */,
69D8B53B19D290E400A75B32 /* CLCMenuExtraView.h */,
69D8B53C19D290E400A75B32 /* CLCMenuExtraView.m */,
69C45CD319D3B230004AC6DD /* CLCPopoverViewController.h */,
69C45CD419D3B230004AC6DD /* CLCPopoverViewController.m */,
69C45CD519D3B230004AC6DD /* CLCPopoverViewController.xib */,
6985D80819D4423F00343F35 /* CLCPopController.h */,
6985D80919D4423F00343F35 /* CLCPopController.m */,
69C45CD019D3B17D004AC6DD /* CLCCalendar.h */,
69C45CD119D3B17D004AC6DD /* CLCCalendar.m */,
);
Expand All @@ -132,6 +131,7 @@
69D8B53F19D2946300A75B32 /* Resources */ = {
isa = PBXGroup;
children = (
6985D80A19D4423F00343F35 /* CLCPopController.xib */,
691657A719D3F8410086C6D9 /* cloud.png */,
691657A819D3F8410086C6D9 /* [email protected] */,
691657A919D3F8410086C6D9 /* cloudgrey.png */,
Expand Down Expand Up @@ -196,7 +196,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
69C45CD719D3B230004AC6DD /* CLCPopoverViewController.xib in Resources */,
6985D80C19D4423F00343F35 /* CLCPopController.xib in Resources */,
691657AB19D3F8410086C6D9 /* cloud.png in Resources */,
691657AE19D3F8410086C6D9 /* [email protected] in Resources */,
691657AD19D3F8410086C6D9 /* cloudgrey.png in Resources */,
Expand All @@ -212,8 +212,8 @@
buildActionMask = 2147483647;
files = (
69C45CD219D3B17D004AC6DD /* CLCCalendar.m in Sources */,
69C45CD619D3B230004AC6DD /* CLCPopoverViewController.m in Sources */,
69D8B53D19D290E400A75B32 /* CLCMenuExtra.m in Sources */,
6985D80B19D4423F00343F35 /* CLCPopController.m in Sources */,
69D8B53E19D290E400A75B32 /* CLCMenuExtraView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Binary file not shown.

0 comments on commit 0e2c0f5

Please sign in to comment.