Thursday, 9 October 2008

A week with WoW makes all the difference

moneyLounge is starting to take shape nicely now. I'm still working in a corporate contract during the day, so I'm only really getting the evenings to spend working on moneyLounge but without Warcraft to distract me I'm finally making some decent progress again. Check out the screen shot included with this blog. I've added a vertical gradient fill to the line graphs to give a nice textured look to them. A horizontal gradient has been added to the bar graphs to make them look like pillars poking out of the x-axis. The NSDrawer to the right hand side of the screen now adjusts it's height at the window resizes and also self computes its own internal height by inspecting the objects within it's own view. I've attached the code that does all this at the bottom of the entry. Oddly by programmatically setting the value of the leadingoffset using [NSDrawer setLeadingOffset:x] it seems to significantly slow the response time of a window resize. The effect only appears noticeable it certain quick mouse movements, so I haven't invested too much time in fixing this.
The treeview now contains income and expense categories. When you select a category it'll also display a graph for that category showing monthly spend/income for the category across all accounts. You can use this to visually compare power bills for example. I've also implemented currency rate maintenance (i.e. add or delete new currency rates), and changes to currencies automatically flow through to dependent accounts and investments.
The whole Cocoa concept of bindings still eludes me however. I simply have not been able to use them at all in this project, meaning that I've had to develop everything with pages of old style glue code to stick the user interface and data objects together. It's very frustrating, but for now I'm going to have to live with it. Most of the maintenance type UI is now done so I shouldn't need to do much more of this.

/* ***************************************************************/
/* objectFrameInDrawer. */
/* Finds the visible height and width of the furtherest objects */
/* in the drawer. Used to setup the size of the drawer when the */
/* content view gets changed */
/* ***************************************************************/
-(NSSize)objectFrameInDrawer
{
id view;
NSEnumerator *viewEnumerator;
float width = 0.0, height = 0.0;
NSSize returnSize;

viewEnumerator = [[[entryDrawer contentView] subviews] objectEnumerator];

while(view=[viewEnumerator nextObject]) {
if(([view frame].origin.y + [view frame].size.height)>height)
height = [view frame].origin.y + [view frame].size.height;
if(([view frame].origin.x + [view frame].size.width)>width)
width = [view frame].origin.x + [view frame].size.width;
}

returnSize.height = height;
returnSize.width = width;

return returnSize;
}

-(void)alignDrawer
{
float defaultMargin = 50.00;

[entryDrawer setLeadingOffset:([window frame].size.height - drawerBounds.height - [entryDrawer trailingOffset])- defaultMargin];
}

/* **********************************************************************************/
/* objectFrameInDrawer. */
/* Before the drawer is opened determine the size of the view inside of the drawer */
/* set the minimum size and the size of the content view to this determined size */
/* and align the drawer vertically along the window */
/* **********************************************************************************/

-(void)drawerWillOpen:(NSNotification *)notification
{
drawerBounds = [self objectFrameInDrawer];
[entryDrawer setContentSize:drawerBounds];
[entryDrawer setMinContentSize:drawerBounds];

[self alignDrawer];
}

-(void)windowDidResize:(NSNotification *)notification
{
[self alignDrawer];
}

No comments: