/Polish/CPWindowAdditions.j

http://github.com/polymar/polish · Unknown · 76 lines · 65 code · 11 blank · 0 comment · 0 complexity · 9a51b12f37fcc5bd27408478caa92a64 MD5 · raw file

  1. /*
  2. * CPWindowAdditions.j
  3. *
  4. * Created by Roberto Gamboni on 02/17/2009.
  5. * Copyright 2008 Roberto Gamboni. All rights reserved.
  6. */
  7. @import <AppKit/CPWindow.j>
  8. @import "CPObjectAdditions.j"
  9. @import "POColor.j"
  10. @implementation CPWindow (Polish)
  11. /*
  12. * Set the dimension of the main window.
  13. */
  14. - (void) width:(CGFloat) width height:(CGFloat) height {
  15. var f = [self frame];
  16. [self setFrame:CGRectMake(f.origin.x, f.origin.y, width, height) display:YES animate:NO];
  17. }
  18. /*
  19. * this are boring but they get handy when performing selectors created from parameters list.
  20. */
  21. - (void) width:(CGFloat) width {
  22. var f = [self frame];
  23. [self setFrame:CGRectMake(f.origin.x, f.origin.y, width, f.size.height) display:NO animate:NO];
  24. }
  25. - (void) height:(CGFloat) height {
  26. var f = [self frame];
  27. [self setFrame:CGRectMake(f.origin.x, f.origin.y, f.size.width, height) display:NO animate:NO];
  28. }
  29. /*
  30. * Forces the content of the window to redraw.
  31. */
  32. - (void) display {
  33. cv = [self contentView];
  34. [cv setNeedsDisplayInRect:[cv frame]];
  35. }
  36. /*
  37. * Set the title of the window.
  38. */
  39. - (void) title:(CPString) title {
  40. [self setTitle:title];
  41. }
  42. /*
  43. * Set YES and the the window will show the resizable indicator on the right-bottom.
  44. */
  45. - (void) resizable:(BOOL) flag {
  46. [self setShowsResizeIndicator:flag];
  47. }
  48. /*
  49. * Change the background color of the main window.
  50. */
  51. - (void) color:(CPString) colorName {
  52. c = [POColor color:colorName];
  53. if(c != nil)
  54. [self setBackgroundColor:c];
  55. else
  56. console.log(color + ' is not a supported color.');
  57. }
  58. /*
  59. * !!!Debugging - Error handling
  60. */
  61. - (void)forward:(SEL)aSelector :(marg_list)args
  62. {
  63. console.warn('@#!Polish Warning - app does not support '+aSelector);
  64. }
  65. @end