adding CPU files from CPU Usage app.
[cpuHistory.git] / CPUUsageMonitor.h
bloba9896be2b8a60787091ab2e73a20b24c89e32cd2
1 //
2 // CPUUsageMonitor.h
3 // CPU Usage
4 //
5 // Created by Peter Hosey on 2006-06-21.
6 // Copyright 2006 Peter Hosey. All rights reserved.
7 //
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 {
22 NSWindow *window;
23 NSPanel *dockIconWindow; //Dock icon view is put in here.
25 //Preferences views.
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;
39 NSTimer *updateTimer;
40 processor_info_array_t lastProcessorInfo;
41 mach_msg_type_number_t numLastProcessorInfo;
42 unsigned numCPUs;
43 float *CPUUsage;
44 NSLock *CPUUsageLock, *deathLock;
45 unsigned threadsRemainingToDie;
46 BOOL threadsShouldExit;
48 //Saved preferences, for restoration after Cancel.
49 NSColor *savedBackgroundColor;
50 NSSize savedCellSize;
51 enum CPUUsageOrientation savedOrientation;
54 #pragma mark Accessors
56 - (NSColor *)backgroundColor;
57 - (void)setBackgroundColor:(NSColor *)newBackgroundColor;
59 - (float)cellWidth;
60 - (void)setCellWidth:(float)newCellWidth;
62 - (float)cellHeight;
63 - (void)setCellHeight:(float)newCellHeight;
65 - (BOOL)shouldDrawToDockIcon;
66 - (void)setShouldDrawToDockIcon:(BOOL)flag;
68 - (BOOL)shouldDrawToWindow;
69 - (void)setShouldDrawToWindow:(BOOL)flag;
71 #pragma mark Actions
73 - (IBAction)setOrientationToVertical:sender;
74 - (IBAction)setOrientationToHorizontal:sender;
75 - (IBAction)setOrientationToRectangular:sender;
77 @end