]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) | |
3 | * | |
4 | * This library is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU Library General Public | |
6 | * License as published by the Free Software Foundation; either | |
7 | * version 2 of the License, or (at your option) any later version. | |
8 | * | |
9 | * This library is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | * Library General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU Library General Public License | |
15 | * along with this library; see the file COPYING.LIB. If not, write to | |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
17 | * Boston, MA 02110-1301, USA. | |
18 | * | |
19 | */ | |
20 | ||
21 | #ifndef RenderTextControlSingleLine_h | |
22 | #define RenderTextControlSingleLine_h | |
23 | ||
24 | #include "PopupMenuClient.h" | |
25 | #include "RenderTextControl.h" | |
26 | #include "Timer.h" | |
27 | ||
28 | namespace WebCore { | |
29 | ||
30 | class InputElement; | |
31 | class SearchFieldCancelButtonElement; | |
32 | class SearchFieldResultsButtonElement; | |
33 | class SearchPopupMenu; | |
34 | class TextControlInnerElement; | |
35 | ||
36 | class RenderTextControlSingleLine : public RenderTextControl, private PopupMenuClient { | |
37 | public: | |
38 | RenderTextControlSingleLine(Node*); | |
39 | virtual ~RenderTextControlSingleLine(); | |
40 | ||
41 | virtual bool hasControlClip() const { return m_cancelButton; } | |
42 | virtual bool isTextField() const { return true; } | |
43 | ||
44 | bool placeholderIsVisible() const { return m_placeholderVisible; } | |
45 | bool placeholderShouldBeVisible() const; | |
46 | void updatePlaceholderVisibility(); | |
47 | ||
48 | void addSearchResult(); | |
49 | void stopSearchEventTimer(); | |
50 | ||
51 | bool popupIsVisible() const { return m_searchPopupIsVisible; } | |
52 | void showPopup(); | |
53 | virtual void hidePopup(); // PopupMenuClient method | |
54 | ||
55 | virtual void subtreeHasChanged(); | |
56 | virtual void paint(PaintInfo&, int tx, int ty); | |
57 | virtual void layout(); | |
58 | ||
59 | virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); | |
60 | void forwardEvent(Event*); | |
61 | ||
62 | private: | |
63 | virtual void capsLockStateMayHaveChanged(); | |
64 | ||
65 | int textBlockWidth() const; | |
66 | virtual int preferredContentWidth(float charWidth) const; | |
67 | virtual void adjustControlHeightBasedOnLineHeight(int lineHeight); | |
68 | ||
69 | void createSubtreeIfNeeded(); | |
70 | virtual void updateFromElement(); | |
71 | virtual void cacheSelection(int start, int end); | |
72 | virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); | |
73 | ||
74 | virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const; | |
75 | PassRefPtr<RenderStyle> createInnerBlockStyle(const RenderStyle* startStyle) const; | |
76 | PassRefPtr<RenderStyle> createResultsButtonStyle(const RenderStyle* startStyle) const; | |
77 | PassRefPtr<RenderStyle> createCancelButtonStyle(const RenderStyle* startStyle) const; | |
78 | ||
79 | void updateCancelButtonVisibility() const; | |
80 | EVisibility visibilityForCancelButton() const; | |
81 | const AtomicString& autosaveName() const; | |
82 | ||
83 | void startSearchEventTimer(); | |
84 | void searchEventTimerFired(Timer<RenderTextControlSingleLine>*); | |
85 | ||
86 | private: | |
87 | // PopupMenuClient methods | |
88 | virtual void valueChanged(unsigned listIndex, bool fireEvents = true); | |
89 | virtual String itemText(unsigned listIndex) const; | |
90 | virtual bool itemIsEnabled(unsigned listIndex) const; | |
91 | virtual PopupMenuStyle itemStyle(unsigned listIndex) const; | |
92 | virtual PopupMenuStyle menuStyle() const; | |
93 | virtual int clientInsetLeft() const; | |
94 | virtual int clientInsetRight() const; | |
95 | virtual int clientPaddingLeft() const; | |
96 | virtual int clientPaddingRight() const; | |
97 | virtual int listSize() const; | |
98 | virtual int selectedIndex() const; | |
99 | virtual bool itemIsSeparator(unsigned listIndex) const; | |
100 | virtual bool itemIsLabel(unsigned listIndex) const; | |
101 | virtual bool itemIsSelected(unsigned listIndex) const; | |
102 | virtual bool shouldPopOver() const { return false; } | |
103 | virtual bool valueShouldChangeOnHotTrack() const { return false; } | |
104 | virtual void setTextFromItem(unsigned listIndex); | |
105 | virtual FontSelector* fontSelector() const; | |
106 | virtual HostWindow* hostWindow() const; | |
107 | virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize); | |
108 | ||
109 | InputElement* inputElement() const; | |
110 | ||
111 | private: | |
112 | bool m_placeholderVisible; | |
113 | bool m_searchPopupIsVisible; | |
114 | bool m_shouldDrawCapsLockIndicator; | |
115 | ||
116 | RefPtr<TextControlInnerElement> m_innerBlock; | |
117 | RefPtr<SearchFieldResultsButtonElement> m_resultsButton; | |
118 | RefPtr<SearchFieldCancelButtonElement> m_cancelButton; | |
119 | ||
120 | Timer<RenderTextControlSingleLine> m_searchEventTimer; | |
121 | RefPtr<SearchPopupMenu> m_searchPopup; | |
122 | Vector<String> m_recentSearches; | |
123 | }; | |
124 | ||
125 | } | |
126 | ||
127 | #endif |