File: TestApplication.m

package info (click to toggle)
mysql-query-browser 1.1.6-1sarge0
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 36,320 kB
  • ctags: 24,680
  • sloc: pascal: 203,479; xml: 136,561; ansic: 47,502; cpp: 28,926; sh: 12,433; objc: 4,823; java: 1,849; php: 1,485; python: 1,225; sql: 1,128; makefile: 872
file content (126 lines) | stat: -rw-r--r-- 3,566 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#import "TestApplication.h"
#import "MConnectionPanel.h"
#import "MBoxLayout.h"
#import "MTableEditor.h"

@interface MTestBoxLayout : MBoxLayout
{
  NSColor *color;
  NSString *name;
}
- (void)setColor:(NSColor*)color name:(NSString*)name;
- (void)drawRect:(NSRect)rect;
@end

@implementation MTestBoxLayout
- (void)setColor:(NSColor*)aColor name:(NSString*)aName;
{
  color= aColor;
  name= aName;
}

- (void)drawRect:(NSRect)rect
{
  NSPoint pt1, pt2;
  NSRect r= [self frame];
  [color set];
  r.size.width-=1;
  r.size.height-=1;
  [NSBezierPath strokeRect:r];
  NSLog(@"painting %@ %@", name, NSStringFromRect([self frame]));
  pt1= [self frame].origin;
  pt2= pt1;
  pt2.x+= [self frame].size.width;
  pt2.y+= [self frame].size.height;
  
  [NSBezierPath strokeLineFromPoint:pt1
                            toPoint:pt2];
  [super drawRect:rect];
}
@end


@implementation TestApplication

- (IBAction)showConnectionPanel:(id)sender
{
  _cpanel= [[MConnectionPanel alloc] 
          initWithConnectionsFile: @"mysqlx_user_connections.xml"];
 
  [_cpanel show];
}

- (IBAction)showBoxTest:(id)sender
{
  MTestBoxLayout *topBox, *hbox1, *hbox2, *hbox3;
  
  topBox= [[MTestBoxLayout alloc] initWithFrame:NSInsetRect([testWindow frame],5,5)];
  [topBox setColor:[NSColor blueColor] name:@"toplevel"];
  [topBox setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
  [topBox setAllBorders:10];
  [topBox setVertical:YES];
  [topBox setSpacing:10];
  [testWindow setContentView:topBox];
  
  hbox1= [[MTestBoxLayout alloc] initWithFrame:NSMakeRect(10,110,100,50)];
  [hbox1 setColor:[NSColor redColor] name:@"hb1"];
  [topBox pack:hbox1 expand:YES];

  hbox2= [[MTestBoxLayout alloc] initWithFrame:NSMakeRect(10,10,100,50)];
  [hbox2 setColor:[NSColor greenColor] name:@"hb2"];
  [topBox pack:hbox2 expand:YES];
  
  hbox3= [[MTestBoxLayout alloc] initWithFrame:NSMakeRect(10,10,100,50)];
  [hbox3 setColor:[NSColor lightGrayColor] name:@"hb3"];
  [topBox pack:hbox3 expand:NO];
  
  [topBox updateLayout];
  
  NSLog(@"%@", NSStringFromRect([hbox1 frame]));
  
  [testWindow makeKeyAndOrderFront:self];
}

- (IBAction)showButtonTest:(id)sender
{
  NSPanel *panel= [[NSPanel alloc] initWithContentRect:NSMakeRect(0,00,360,107)
                                             styleMask:NSTitledWindowMask
                                               backing:NSBackingStoreRetained
                                                 defer:YES];
  NSView *view= [[NSView alloc] initWithFrame:[panel frame]];
  NSTextField *text= [[[NSTextField alloc] initWithFrame:NSMakeRect(17,70,326,17)] autorelease];
  NSProgressIndicator *prog= [[[NSProgressIndicator alloc] initWithFrame:NSMakeRect(18,18,250,20)] autorelease];
  NSButton *button= [[[NSButton alloc] initWithFrame:NSMakeRect(268,12,78,32)] autorelease];
  
  [panel setAcceptsMouseMovedEvents:YES];
//  [panel setAlphaValue:0.9];
   
//  [panel setBecomesKeyOnlyIfNeeded:NO];
  [panel setWorksWhenModal:YES];
  [panel setIgnoresMouseEvents:NO];
  [panel setInitialFirstResponder:button];
  
  [button setAction:@selector(closeWindow:)];
  [button setTarget:panel];
  
  [button setBezelStyle:NSRoundedBezelStyle];
  [button setTitle:@"Stop"];
  
  [panel setHasShadow:YES];
  [text setStringValue:@"Hello World"];
  [text setDrawsBackground:NO];
  [text setBordered:NO];
  [prog startAnimation:self];
  
  [view addSubview:text];
  [view addSubview:prog];
  [view addSubview:button];
  [panel setContentView:view];
  
  [panel makeKeyAndOrderFront:self];
    
  //[NSApp runModalForWindow:panel];
  
}

@end