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