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 932B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 "Render.h"
  10. #import "MainView.h"
  11. @interface MainView ()
  12. @property (strong) Render *render;
  13. @end
  14. @implementation MainView
  15. @synthesize render;
  16. -(void)awakeFromNib {
  17. render = [[Render alloc] init];
  18. [(MainWindow*)[self window] setDefaultBackgroundSize:[render baseSize]]; // Set window to a useful default size
  19. }
  20. -(void)drawRect:(NSRect)dirtyRect {
  21. // Clear background
  22. [[NSColor clearColor] set];
  23. NSRectFill([self frame]);
  24. [render drawWith:0]; // Should be done somewhere else!
  25. [render drawInto:self]; // Draw composite image
  26. }
  27. -(BOOL)acceptsFirstMouse:(NSEvent *)theEvent {
  28. // This is required so we get mouse events even if we don't have focus
  29. // (needed to allow dragging the window without focus)
  30. return YES;
  31. }
  32. @end