180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2006 The Android Open Source Project 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkWidgetViews_DEFINED 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkWidgetViews_DEFINED 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkView.h" 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruenum SkWidgetEnum { 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kBorder_WidgetEnum, //!< <sk-border> 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kButton_WidgetEnum, //!< <sk-button> 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kImage_WidgetEnum, //!< <sk-image> 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kList_WidgetEnum, //!< <sk-list> 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kProgress_WidgetEnum, //!< <sk-progress> 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kScroll_WidgetEnum, //!< <sk-scroll> 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kText_WidgetEnum, //!< <sk-text> 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kWidgetEnumCount 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//determines which skin to use 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruenum SkinEnum { 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kBorder_SkinEnum, 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kButton_SkinEnum, 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kProgress_SkinEnum, 3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kScroll_SkinEnum, 3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kStaticText_SkinEnum, 3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kSkinEnumCount 3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkAnimator.h" 4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//used for inflates 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruconst char* get_skin_enum_path(SkinEnum se); 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid init_skin_anim(const char path[], SkAnimator* anim); 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid init_skin_anim(SkinEnum se, SkAnimator* anim); 4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid init_skin_paint(SkinEnum se, SkPaint* paint); 4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid inflate_paint(const SkDOM& dom, const SkDOM::Node* node, SkPaint* paint); 4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/** Given an enum value, return an instance of the specified widget. 4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru If the enum is out of range, returns null 4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru*/ 5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkView* SkWidgetFactory(SkWidgetEnum); 5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/** Given the inflate/element name of a widget, return an instance of 5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru the specified widget, or null if name does not match any known 5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru widget type. 5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru*/ 5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkView* SkWidgetFactory(const char name[]); 5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//////////////////////////////////////////////////////////////////////////////////////////////// 5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkWidgetView : public SkView { 6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkWidgetView(); 6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const char* getLabel() const; 6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void getLabel(SkString* label) const; 6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setLabel(const char[]); 6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setLabel(const char[], size_t len); 6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setLabel(const SkString&); 6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkEvent& event() { return fEvent; } 7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkEvent& event() const { return fEvent; } 7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** Returns true if the widget can post its event to its listeners. 7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool postWidgetEvent(); 7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** Returns the sinkID of the widgetview that posted the event, or 0 7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static SkEventSinkID GetWidgetEventSinkID(const SkEvent&); 8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected: 8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** called when the label changes. override in subclasses. default action invals the view's bounds. 8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru called with the old and new labels, before the label has actually changed. 8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onLabelChange(const char oldLabel[], const char newLabel[]); 8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** called before posting the event to our listeners. Override to add slots to the event 8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru before posting. Return true to proceed with posting, or false to not post the event to any 8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru listener. Note: the event passed in may not be the same as calling this->event(). 8980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru Be sure to call your INHERITED method as well, so that all classes in the hierarchy get a shot 9080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru at modifying the event (and possibly returning false to abort). 9180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 9280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual bool onPrepareWidgetEvent(SkEvent* evt); 9380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 9480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // overrides 9580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onInflate(const SkDOM& dom, const SkDOM::Node*); 9680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 9780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 9880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkString fLabel; 9980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkEvent fEvent; 10080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 10180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru typedef SkView INHERITED; 10280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 10380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 10480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//////////////////////////////////////////////////////////////////////////////////////////////// 10580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 10680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkButtonView : public SkWidgetView { 10780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 10880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // inflate: "sk-button" 10980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 11080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected: 11180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // overrides 11280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual bool onEvent(const SkEvent&); 11380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 11480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru typedef SkWidgetView INHERITED; 11580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 11680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 11780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//////////////////////////////////////////////////////////////////////////////////////////////// 11880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 11980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkCheckButtonView : public SkWidgetView { 12080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 12180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkCheckButtonView(); 12280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 12380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // inflate: "sk-checkbutton" 12480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 12580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru enum CheckState { 12680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kOff_CheckState, //!< inflate: check-state="off" 12780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kOn_CheckState, //!< inflate: check-state="on" 12880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kUnknown_CheckState //!< inflate: check-state="unknown" 12980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru }; 13080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru CheckState getCheckState() const { return (CheckState)fCheckState; } 13180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setCheckState(CheckState); 13280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 13380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** use this to extract the CheckState from an event (i.e. one that as posted 13480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru by a SkCheckButtonView). Returns true if the proper slot was present in the event, 13580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru and sets state to that value. If no proper slot is found, returns false and does not 13680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru modify state. 13780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 13880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static bool GetWidgetEventCheckState(const SkEvent&, CheckState* state); 13980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 14080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected: 14180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // called when the check-state is about to change, but before it actually has 14280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onCheckStateChange(CheckState oldState, CheckState newState); 14380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 14480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // overrides 14580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onInflate(const SkDOM& dom, const SkDOM::Node*); 14680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual bool onPrepareWidgetEvent(SkEvent* evt); 14780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 14880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 14980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru uint8_t fCheckState; 15080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 15180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru typedef SkWidgetView INHERITED; 15280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 15380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 15480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//////////////////////////////////////////////////////////////////////////////////////////////// 15580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkTextBox.h" 15680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 15780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkStaticTextView : public SkView { 15880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 15980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkStaticTextView(); 16080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual ~SkStaticTextView(); 16180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 16280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru enum Mode { 16380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kFixedSize_Mode, 16480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kAutoWidth_Mode, 16580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kAutoHeight_Mode, 16680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 16780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kModeCount 16880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru }; 16980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru Mode getMode() const { return (Mode)fMode; } 17080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setMode(Mode); 17180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 17280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkTextBox::SpacingAlign getSpacingAlign() const { return (SkTextBox::SpacingAlign)fSpacingAlign; } 17380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setSpacingAlign(SkTextBox::SpacingAlign); 17480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 17580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void getMargin(SkPoint* margin) const; 17680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setMargin(SkScalar dx, SkScalar dy); 17780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 17880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru size_t getText(SkString* text = NULL) const; 17980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru size_t getText(char text[] = NULL) const; 18080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setText(const SkString&); 18180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setText(const char text[]); 18280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setText(const char text[], size_t len); 18380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 18480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void getPaint(SkPaint*) const; 18580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setPaint(const SkPaint&); 18680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 18780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected: 18880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // overrides 18980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onDraw(SkCanvas*); 19080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onInflate(const SkDOM& dom, const SkDOM::Node*); 19180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 19280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 19380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkPoint fMargin; 19480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkString fText; 19580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkPaint fPaint; 19680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru uint8_t fMode; 19780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru uint8_t fSpacingAlign; 19880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 19980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void computeSize(); 20080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 20180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru typedef SkView INHERITED; 20280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 20380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 20480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//////////////////////////////////////////////////////////////////////////////////////////////// 20580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 20680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkAnimator; 20780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkListSource; 20880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkScrollBarView; 20980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 21080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkListView : public SkWidgetView { 21180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 21280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkListView(); 21380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual ~SkListView(); 21480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 21580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool hasScrollBar() const { return fScrollBar != NULL; } 21680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setHasScrollBar(bool); 21780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 21880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** Return the number of visible rows 21980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 22080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int getVisibleRowCount() const { return fVisibleRowCount; } 22180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** Return the index of the selected row, or -1 if none 22280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 22380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int getSelection() const { return fCurrIndex; } 22480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** Set the index of the selected row, or -1 for none 22580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 22680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setSelection(int); 22780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** If possible, move the selection up and return true, 22880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru else do nothing and return false 22980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru If nothing is selected, select the last item (unless there are no items). 23080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 23180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool moveSelectionUp(); 23280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** If possible, move the selection down and return true, 23380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru else do nothing and return false. 23480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru If nothing is selected, select the first item (unless there are no items). 23580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 23680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool moveSelectionDown(); 23780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 23880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkListSource* getListSource() const { return fSource; } 23980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkListSource* setListSource(SkListSource*); 24080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 24180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** Call this in your event handler. If the specified event is from a SkListView, 24280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru then it returns the index of the selected item in this list, otherwise it 24380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru returns -1 24480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 24580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static int GetWidgetEventListIndex(const SkEvent&); 24680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 24780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected: 24880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // overrides 24980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onDraw(SkCanvas*); 25080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onSizeChange(); 25180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual bool onEvent(const SkEvent&); 25280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node); 25380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual bool onPrepareWidgetEvent(SkEvent*); 25480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 25580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 25680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru enum DirtyFlags { 25780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kAnimCount_DirtyFlag = 0x01, 25880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kAnimContent_DirtyFlag = 0x02 25980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru }; 26080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void dirtyCache(unsigned dirtyFlags); 26180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool ensureCache(); 26280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 26380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int logicalToVisualIndex(int index) const { return index - fScrollIndex; } 26480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void invalSelection(); 26580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkScalar getContentWidth() const; 26680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool getRowRect(int index, SkRect*) const; 26780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void ensureSelectionIsVisible(); 26880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void ensureVisibleRowCount(); 26980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 27080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru struct BindingRec; 27180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 27280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru enum Heights { 27380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kNormal_Height, 27480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kSelected_Height 27580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru }; 27680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkListSource* fSource; 27780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkScrollBarView* fScrollBar; 27880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkAnimator* fAnims; 27980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru BindingRec* fBindings; 28080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkString fSkinName; 28180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkScalar fHeights[2]; 28280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int16_t fScrollIndex, fCurrIndex; 28380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru uint16_t fVisibleRowCount, fBindingCount; 28480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkBool8 fAnimContentDirty; 28580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkBool8 fAnimFocusDirty; 28680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 28780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru typedef SkWidgetView INHERITED; 28880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 28980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 29080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkListSource : public SkRefCnt { 29180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 29280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_DECLARE_INST_COUNT(SkListSource) 29380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 29480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual int countFields(); 29580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void getFieldName(int index, SkString* field); 29680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** Return the index of the named field, or -1 if not found */ 29780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual int findFieldIndex(const char field[]); 29880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 29980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual int countRecords(); 30080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void getRecord(int rowIndex, int fieldIndex, SkString* data); 30180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 30280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual bool prepareWidgetEvent(SkEvent*, int rowIndex); 30380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 30480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static SkListSource* Factory(const char name[]); 30580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 30680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru typedef SkRefCnt INHERITED; 30780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 30880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 30980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 310