Guest User

Untitled

a guest
Jul 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.25 KB | None | 0 0
  1. @import <Foundation/CPObject.j>
  2.  
  3.  
  4. @implementation ProjectsController : CPObject
  5. {
  6. // CPTableView datasource methods
  7. - (int)numberOfRowsInTableView:(CPTableView)tableView
  8. {
  9. return 1;
  10. }
  11.  
  12. - (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row
  13. {
  14. return @"data";
  15. }
  16.  
  17. }
  18.  
  19. @end
  20.  
  21.  
  22. @implementation AppController : CPObject
  23. {
  24. CPSplitView verticalSplitter;
  25. CPSplitView horizontalSplitter;
  26.  
  27. CPArray projects;
  28. CPTableView projectsView;
  29. }
  30.  
  31. - (void)applicationDidFinishLaunching:(CPNotification)aNotification
  32. {
  33. /* Enable Logging (DEBUG) */
  34. // CPLogRegister(CPLogPopup);
  35.  
  36. var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask];
  37. var contentView = [theWindow contentView];
  38.  
  39. verticalSplitter = [[CPSplitView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]))];
  40. [verticalSplitter setDelegate:self];
  41. [verticalSplitter setVertical:YES];
  42. [verticalSplitter setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ];
  43. [contentView addSubview:verticalSplitter];
  44.  
  45.  
  46. /*
  47. *
  48. * Projects Navigation
  49. *
  50. */
  51.  
  52. var leftView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 250, CGRectGetHeight([verticalSplitter bounds]))];
  53. [bottomView setAutoresizingMask:CPViewHeightSizable ];
  54.  
  55.  
  56. projectSearchField = [[CPSearchField alloc] initWithFrame:CGRectMake(0, 0, 250, 32)];
  57. //[projectSearchField setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
  58. [leftView addSubview:projectSearchField];
  59.  
  60.  
  61. // create the CPTableView
  62. projectsView = [[CPTableView alloc] initWithFrame:[leftView bounds]];
  63. [projectsView setDataSource:ProjectsController];
  64. [projectsView setUsesAlternatingRowBackgroundColors:YES];
  65.  
  66. [leftView setDocumentView:projectsView];
  67.  
  68.  
  69. /*
  70. *
  71. *
  72. * Tasks Navigation
  73. *
  74. *
  75. */
  76.  
  77.  
  78.  
  79.  
  80.  
  81. var middleView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 250, CGRectGetHeight([verticalSplitter bounds]))];
  82. [middleView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ];
  83.  
  84. taskSearchField = [[CPSearchField alloc] initWithFrame:CGRectMake(0, 0, 250, 32)];
  85. //[taskSearchField setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
  86. [middleView addSubview:taskSearchField];
  87.  
  88. var rightView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([verticalSplitter bounds]) - 500, CGRectGetHeight([verticalSplitter bounds]))];
  89. [rightView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ];
  90.  
  91.  
  92. // Add the views the the VerticalSplitter
  93. [verticalSplitter addSubview:leftView];
  94. [verticalSplitter addSubview:middleView];
  95. [verticalSplitter addSubview:rightView];
  96.  
  97.  
  98. horizontalSplitter = [[CPSplitView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([rightView bounds]), CGRectGetHeight([rightView bounds]))];
  99. [horizontalSplitter setDelegate:self];
  100. [horizontalSplitter setVertical:NO];
  101. [horizontalSplitter setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ];
  102. // 1 pixel size for the splitter
  103. [horizontalSplitter setIsPaneSplitter:YES];
  104.  
  105.  
  106. [rightView addSubview:horizontalSplitter];
  107.  
  108. var topView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([horizontalSplitter bounds]), 64)];
  109. [topView setAutoresizingMask:CPViewWidthSizable];
  110.  
  111. var timerButton = [[CPButton alloc] initWithFrame: CGRectMake( 10, 10, 80, 24 )];
  112. [timerButton setTitle:"Start"];
  113. [topView addSubview:timerButton];
  114.  
  115. var completionCheckbox = [[CPCheckBox alloc] initWithFrame: CGRectMake(CGRectGetWidth([rightView bounds]) - 100 , 10, 80, 24 )];
  116. [completionCheckbox setTitle:"Completed"];
  117. [completionCheckbox setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
  118.  
  119. [topView addSubview:completionCheckbox];
  120.  
  121. var timingLabel = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
  122.  
  123. [timingLabel setStringValue:@"00:00:00"];
  124. [timingLabel setFont:[CPFont boldSystemFontOfSize:24.0]];
  125. [timingLabel sizeToFit];
  126.  
  127. [timingLabel setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
  128. [timingLabel setFrameOrigin:CGPointMake((CGRectGetWidth([topView bounds]) - CGRectGetWidth([timingLabel frame])) / 2.0,
  129. (CGRectGetHeight([topView bounds]) - CGRectGetHeight([timingLabel frame])) / 2.0)];
  130.  
  131. [topView addSubview:timingLabel];
  132.  
  133.  
  134. var bottomView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([horizontalSplitter bounds]), CGRectGetHeight([horizontalSplitter bounds]) - 64)];
  135. [bottomView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ];
  136.  
  137. [horizontalSplitter addSubview:topView];
  138. [horizontalSplitter addSubview:bottomView];
  139.  
  140. var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
  141.  
  142. [label setStringValue:@"NuTimer"];
  143. [label setFont:[CPFont boldSystemFontOfSize:24.0]];
  144. [label sizeToFit];
  145.  
  146. [label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
  147. [label setFrameOrigin:CGPointMake((CGRectGetWidth([bottomView bounds]) - CGRectGetWidth([label frame])) / 2.0,
  148. (CGRectGetHeight([bottomView bounds]) - CGRectGetHeight([label frame])) / 2.0)];
  149.  
  150. [bottomView addSubview:label];
  151.  
  152. [theWindow orderFront:self];
  153.  
  154. // Uncomment the following line to turn on the standard menu bar.
  155. //[CPMenu setMenuBarVisible:YES];
  156. }
  157.  
  158. -(void) splitViewDidResizeSubviews:(CPNotification)notification
  159. {
  160. var splitView = [notification object];
  161.  
  162. CPLog.trace(@"splitViewDidResizeSubviews:");
  163. if (splitView == verticalSplitter)
  164. {
  165. CPLog.trace(@"Vertical splitter: " + [splitView description]);
  166. }
  167. else
  168. {
  169. CPLog.trace(@"Horizontal splitter: " + [splitView description]);
  170. }
  171.  
  172. }
  173.  
  174. -(void) splitViewWillResizeSubviews:(CPNotification)notification
  175. {
  176. var splitView = [notification object];
  177.  
  178. CPLog.trace(@"splitViewWillResizeSubviews:");
  179.  
  180. if (splitView == verticalSplitter)
  181. {
  182. CPLog.trace(@"Vertical splitter: " + [splitView description]);
  183. }
  184. else
  185. {
  186. CPLog.trace(@"Horizontal splitter: " + [splitView description]);
  187. }
  188.  
  189. }
  190.  
  191. /*
  192. -(CGRect)splitView:(CPSplitView)splitView effectiveRect:(CGRect)effectiveRect forDrawnRect:(CGRect)drawnRect ofDividerAtIndex:(int)anIndex
  193. {
  194. }
  195. */
  196.  
  197. // Add additional size for tracking the splitter
  198. /*
  199. -(CGRect) splitView:(CPSplitView)splitView additionalEffectiveRectOfDividerAtIndex:(int)anIndex
  200. {
  201. CPLog.trace(@"splitView:additionalEffectiveRectOfDividerAtIndex:");
  202.  
  203. if (splitView == horizontalSplitter)
  204. {
  205. CPLog.trace(@"Horizontal");
  206.  
  207. var rect = [self rectOfDividerAtIndex:anIndex];
  208. CPLog.trace(CPStringFromRect(rect));
  209.  
  210. //var newRect = CPRectInset(rect, -5, -5);
  211.  
  212. newRect = CGRectMake(0, 0, 500, 500)
  213. CPLog.trace(CPStringFromRect(newRect));
  214. return newRect;
  215. }
  216. else
  217. {
  218. CPLog.trace(@"Vertical");
  219.  
  220. var newRect = CGRectMake(0, 0, 0, 0);
  221. CPLog.trace(CPStringFromRect(newRect));
  222. //return newRect;
  223. return null;
  224. }
  225. }
  226. */
  227.  
  228. -(BOOL) splitView:(CPSplitView)splitView shouldCollapseSubview:(CPView)view forDoubleClickOnDividerAtIndex:(int)anIndex
  229. {
  230. CPLog.trace(@"splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:");
  231. return YES;
  232. }
  233.  
  234. -(BOOL) splitView:(CPSplitView)splitView canCollapseSubView:(CPView)view
  235. {
  236. // debugger;
  237. CPLog.trace(@"splitView:canCollapseSubView:");
  238. return YES;
  239. }
  240.  
  241. @end
Add Comment
Please, Sign In to add comment