-
/*
* Copyright 2006 The Android Open Source Project
*
* found in the LICENSE file.
*/
-
#ifndef SkWidget_DEFINED
#define SkWidget_DEFINED
-#include "SkView.h"
#include "SkBitmap.h"
#include "SkDOM.h"
#include "SkPaint.h"
#include "SkString.h"
#include "SkTDArray.h"
+#include "SkTextBox.h"
+#include "SkView.h"
+
+class SkEvent;
+class SkInterpolator;
+class SkShader;
-//////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
class SkWidget : public SkView {
public:
typedef SkView INHERITED;
};
+////////////////////////////////////////////////////////////////////////////////
+
class SkHasLabelWidget : public SkWidget {
public:
SkHasLabelWidget(uint32_t flags = 0) : SkWidget(flags) {}
typedef SkWidget INHERITED;
};
+////////////////////////////////////////////////////////////////////////////////
+
class SkButtonWidget : public SkHasLabelWidget {
public:
SkButtonWidget(uint32_t flags = 0) : SkHasLabelWidget(flags), fState(kOff_State) {}
typedef SkHasLabelWidget INHERITED;
};
+////////////////////////////////////////////////////////////////////////////////
+
class SkPushButtonWidget : public SkButtonWidget {
public:
SkPushButtonWidget(uint32_t flags = 0) : SkButtonWidget(flags) {}
typedef SkButtonWidget INHERITED;
};
+////////////////////////////////////////////////////////////////////////////////
+
class SkCheckBoxWidget : public SkButtonWidget {
public:
SkCheckBoxWidget(uint32_t flags = 0);
typedef SkButtonWidget INHERITED;
};
-#include "SkTextBox.h"
+////////////////////////////////////////////////////////////////////////////////
class SkStaticTextView : public SkView {
public:
typedef SkView INHERITED;
};
+////////////////////////////////////////////////////////////////////////////////
+
class SkBitmapView : public SkView {
public:
SkBitmapView(uint32_t flags = 0);
typedef SkView INHERITED;
};
-/////////////////////////////////////////////////////////////////////////////
-
-class SkShader;
-class SkInterpolator;
-
-class SkWidgetView : public SkView {
-public:
- SkWidgetView(uint32_t flags = 0);
- virtual ~SkWidgetView();
-
- static const char* GetEventType();
-};
-
-class SkSliderView : public SkWidgetView {
-public:
- SkSliderView(uint32_t flags = 0);
-
- uint16_t getValue() const { return fValue; }
- uint16_t getMax() const { return fMax; }
-
- void setMax(U16CPU max);
- void setValue(U16CPU value);
-
-protected:
- virtual void onDraw(SkCanvas*);
- virtual Click* onFindClickHandler(SkScalar x, SkScalar y);
- virtual bool onClick(Click*);
-
-private:
- uint16_t fValue, fMax;
-
- typedef SkWidgetView INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
class SkHasLabelView : public SkView {
public:
virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
};
+////////////////////////////////////////////////////////////////////////////////
+
class SkPushButtonView : public SkHasLabelView {
public:
SkPushButtonView(uint32_t flags = 0);
virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
};
+////////////////////////////////////////////////////////////////////////////////
+
class SkCheckBoxView : public SkHasLabelView {
public:
SkCheckBoxView(uint32_t flags = 0);
State fState;
};
+////////////////////////////////////////////////////////////////////////////////
+
class SkProgressView : public SkView {
public:
SkProgressView(uint32_t flags = 0);
typedef SkView INHERITED;
};
-class SkTextView : public SkView {
-public:
- SkTextView(uint32_t flags = 0);
- virtual ~SkTextView();
-
- enum AnimaDir {
- kNeutral_AnimDir,
- kForward_AnimDir,
- kBackward_AnimDir,
- kAnimDirCount
- };
-
- void getText(SkString*) const;
- void setText(const SkString&, AnimaDir dir = kNeutral_AnimDir);
- void setText(const char text[], AnimaDir dir = kNeutral_AnimDir);
- void setText(const char text[], size_t len, AnimaDir dir = kNeutral_AnimDir);
-
- void getMargin(SkPoint* margin) const;
- void setMargin(const SkPoint&);
-
- SkPaint& paint() { return fPaint; }
-
-protected:
- virtual void onDraw(SkCanvas*);
- virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
-
-private:
- SkString fText;
- SkPaint fPaint;
- SkPoint fMargin;
-
- class Interp;
- Interp* fInterp;
- bool fDoInterp;
- // called by the other setText methods. This guy does not check for !=
- // before doing the assign, so the caller must check for us
- void privSetText(const SkString&, AnimaDir dir);
-
- typedef SkView INHERITED;
-};
-
-//////////////////////////////////////////////////////////
-
-class SkEvent;
+////////////////////////////////////////////////////////////////////////////////
class SkListSource : public SkEventSink {
public:
static SkListSource* CreateFromDOM(const SkDOM& dom, const SkDOM::Node* node);
};
-class SkListView : public SkWidgetView {
+////////////////////////////////////////////////////////////////////////////////
+
+class SkListView : public SkView {
public:
SkListView(uint32_t flags = 0);
virtual ~SkListView();
bool getRowRect(int index, SkRect*) const;
void ensureSelectionIsVisible();
- typedef SkWidgetView INHERITED;
+ typedef SkView INHERITED;
};
-//////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
-class SkGridView : public SkWidgetView {
+class SkGridView : public SkView {
public:
SkGridView(uint32_t flags = 0);
virtual ~SkGridView();
bool getCellRect(int index, SkRect*) const;
void ensureSelectionIsVisible();
- typedef SkWidgetView INHERITED;
+ typedef SkView INHERITED;
};
#endif
-