1#include "SkApplication.h"
2#import "SkCanvas.h"
3#import "SkPaint.h"
4#import "SkWindow.h"
5#include "SkGraphics.h"
6#include "SkCGUtils.h"
7
8void dummy_main(int , char *[]) {
9}
10
11class SkSampleView : public SkView {
12public:
13    SkSampleView() {
14        this->setVisibleP(true);
15        this->setClipToBounds(false);
16    };
17protected:
18    virtual void onDraw(SkCanvas* canvas) {
19        canvas->drawColor(0xFFFFFFFF);
20        SkPaint p;
21        p.setTextSize(20);
22        p.setAntiAlias(true);
23        canvas->drawText("finished", 13, 50, 30, p);
24        SkRect r = {50, 50, 80, 80};
25        p.setColor(0xAA11EEAA);
26        canvas->drawRect(r, p);
27    }
28private:
29    typedef SkView INHERITED;
30};
31
32void application_init() {
33    SkGraphics::Init();
34    SkEvent::Init();
35}
36
37void application_term() {
38    SkGraphics::Term();
39    SkEvent::Term();
40}
41
42int saved_argc;
43char** saved_argv;
44
45IOS_launch_type set_cmd_line_args(int argc, char *argv[], const char* ) {
46    saved_argc = argc;
47    saved_argv = argv;
48    return kTool_iOSLaunchType;
49}
50
51class FillLayout : public SkView::Layout {
52protected:
53    virtual void onLayoutChildren(SkView* parent) {
54        SkView* view = SkView::F2BIter(parent).next();
55        view->setSize(parent->width(), parent->height());
56    }
57};
58
59#import "SimpleApp.h"
60@implementation SimpleApp
61
62- (id)initWithDefaults {
63    dummy_main(saved_argc, saved_argv);
64    if (self = [super initWithDefaults]) {
65        fWind = new SkOSWindow(self);
66        fWind->setLayout(new FillLayout, false);
67        fWind->attachChildToFront(new SkSampleView)->unref();
68    }
69    return self;
70}
71
72@end
73