blob: 08acfcc526471576a13b8e9927e766ba0bc79f0f [file] [log] [blame]
bsalomon@google.com48dd1a22011-10-31 14:18:20 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#ifndef GMSampleView_DEFINED
11#define GMSampleView_DEFINED
12
13#include "SampleCode.h"
14#include "gm.h"
15
16class GMSampleView : public SampleView {
17private:
18 typedef skiagm::GM GM;
19
20public:
21 GMSampleView(GM* gm)
22 : fGM(gm) {}
23
24 virtual ~GMSampleView() {
25 delete fGM;
26 }
27
28protected:
29 virtual bool onQuery(SkEvent* evt) {
30 if (SampleCode::TitleQ(*evt)) {
31 SampleCode::TitleR(evt, fGM->shortName());
32 return true;
33 }
34 return this->INHERITED::onQuery(evt);
35 }
36
37 virtual void onDrawContent(SkCanvas* canvas) {
38 fGM->drawContent(canvas);
39 }
40
41 virtual void onDrawBackground(SkCanvas* canvas) {
42 fGM->drawBackground(canvas);
43 }
44
45private:
46 GM* fGM;
47 typedef SampleView INHERITED;
48};
49
50#endif