5 // Created by Peter Hosey on 2006-06-21.
6 // Copyright 2006 Peter Hosey. All rights reserved.
9 #import <Cocoa/Cocoa.h>
11 #include <mach/mach.h>
12 #include <mach/processor_info.h>
13 #include <mach/mach_host.h>
15 enum CPUUsageOrientation
{
16 CPUUsageOrientationVertical
,
17 CPUUsageOrientationHorizontal
,
18 CPUUsageOrientationRectangular
21 @interface CPUUsageMonitor
: NSObject
{
23 NSPanel
*dockIconWindow
; //Dock icon view is put in here.
26 IBOutlet NSPanel
*preferencesPanel
;
27 NSColor
*backgroundColor
;
28 float cellWidth
, cellHeight
;
29 IBOutlet NSTextField
*widthField
, *heightField
;
30 IBOutlet NSButton
*horizontalButton
, *verticalButton
, *rectangularButton
;
32 IBOutlet NSMenu
*contextualMenu
;
34 NSMutableArray
*usageViews
, *dockIconUsageViews
;
35 NSView
*dockIconUsageViewsContainingView
;
36 enum CPUUsageOrientation orientation
;
37 BOOL shouldDrawToDockIcon
, shouldDrawToWindow
;
40 processor_info_array_t lastProcessorInfo
;
41 mach_msg_type_number_t numLastProcessorInfo
;
44 NSLock
*CPUUsageLock
, *deathLock
;
45 unsigned threadsRemainingToDie
;
46 BOOL threadsShouldExit
;
48 //Saved preferences, for restoration after Cancel.
49 NSColor
*savedBackgroundColor
;
51 enum CPUUsageOrientation savedOrientation
;
54 #pragma mark Accessors
56 - (NSColor
*)backgroundColor
;
57 - (void)setBackgroundColor
:(NSColor
*)newBackgroundColor
;
60 - (void)setCellWidth
:(float)newCellWidth
;
63 - (void)setCellHeight
:(float)newCellHeight
;
65 - (BOOL
)shouldDrawToDockIcon
;
66 - (void)setShouldDrawToDockIcon
:(BOOL
)flag
;
68 - (BOOL
)shouldDrawToWindow
;
69 - (void)setShouldDrawToWindow
:(BOOL
)flag
;
73 - (IBAction
)setOrientationToVertical
:sender
;
74 - (IBAction
)setOrientationToHorizontal
:sender
;
75 - (IBAction
)setOrientationToRectangular
:sender
;