Native Mac OS X OtaClock replica
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MainView.m 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // MainView.m
  3. // OtaClock
  4. //
  5. // Created by Thomas Buck on 16.08.15.
  6. // Copyright (c) 2015 xythobuz. All rights reserved.
  7. //
  8. #import "MainWindow.h"
  9. #import "MainView.h"
  10. #define BASE_IMAGE_RESIZE_FACTOR 0.2
  11. @implementation MainView
  12. @synthesize otaconImage;
  13. -(void)awakeFromNib {
  14. // Load background image
  15. self.otaconImage = [NSImage imageNamed:@"Otacon"];
  16. // Set window to a useful default size
  17. NSSize newSize = [otaconImage size];
  18. newSize.width *= BASE_IMAGE_RESIZE_FACTOR;
  19. newSize.height *= BASE_IMAGE_RESIZE_FACTOR;
  20. [(MainWindow*)[self window] setDefaultBackgroundSize:newSize];
  21. }
  22. -(void)drawRect:(NSRect)dirtyRect {
  23. // Clear background
  24. [[NSColor clearColor] set];
  25. NSRectFill([self frame]);
  26. // Draw main image into window bounds
  27. [otaconImage drawInRect:[self bounds]];
  28. }
  29. -(BOOL)acceptsFirstMouse:(NSEvent *)theEvent {
  30. // This is required so we get mouse events even if we don't have focus
  31. // (needed to allow dragging the window without focus)
  32. return YES;
  33. }
  34. @end