sbSimpleButtonPropertyInfo.cpp
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
28 #include "sbStandardOperators.h"
29 
30 #include <sbIPropertyArray.h>
31 #include <sbIPropertyManager.h>
32 #include <nsIStringBundle.h>
33 #include <nsITreeView.h>
34 
39 
40 /*
41  * The value of simple button properties is formatted as follows:
42  *
43  * <label>[|<disable state>]
44  *
45  * A disable state of 1 means the button is disabled, otherwise it is enabled
46  *
47  */
48 sbSimpleButtonPropertyInfo::sbSimpleButtonPropertyInfo(const nsAString& aPropertyID,
49  const nsAString& aDisplayName,
50  const nsAString& aLocalizationKey,
51  PRBool aHasLabel,
52  const nsAString& aLabel,
53  const PRBool aRemoteReadable,
54  const PRBool aRemoteWritable,
55  const PRBool aUserViewable,
56  const PRBool aUserEditable)
57 {
58  mID = aPropertyID;
59  mDisplayName = aDisplayName;
60  mLocalizationKey = aLocalizationKey;
61  mHasLabel = aHasLabel;
62  mLabel = aLabel;
63  mUserViewable = aUserViewable;
64  mUserEditable = aUserEditable;
65  mRemoteReadable = aRemoteReadable;
66  mRemoteWritable = aRemoteWritable;
67  mType.AssignLiteral("button");
68  mSuppressSelect = PR_TRUE;
69 }
70 
71 nsresult
73 {
74  nsresult rv;
75 
77  NS_ENSURE_SUCCESS(rv, rv);
78 
79  return NS_OK;
80 }
81 
82 // sbITreeViewPropertyInfo
83 
84 NS_IMETHODIMP
85 sbSimpleButtonPropertyInfo::GetImageSrc(const nsAString& aValue,
86  nsAString& _retval)
87 {
88  _retval.Truncate();
89  return NS_OK;
90 }
91 
92 NS_IMETHODIMP
93 sbSimpleButtonPropertyInfo::GetProgressMode(const nsAString& aValue,
94  PRInt32* _retval)
95 {
96  NS_ENSURE_ARG_POINTER(_retval);
97  *_retval = nsITreeView::PROGRESS_NONE;
98  return NS_OK;
99 }
100 
101 NS_IMETHODIMP
102 sbSimpleButtonPropertyInfo::GetCellValue(const nsAString& aValue,
103  nsAString& _retval)
104 {
105  _retval.Truncate();
106  return NS_OK;
107 }
108 
109 NS_IMETHODIMP
110 sbSimpleButtonPropertyInfo::GetRowProperties(const nsAString& aValue,
111  nsAString& _retval)
112 {
113  _retval.Truncate();
114  return NS_OK;
115 }
116 
117 NS_IMETHODIMP
118 sbSimpleButtonPropertyInfo::GetCellProperties(const nsAString& aValue,
119  nsAString& _retval)
120 {
121  _retval.AssignLiteral("button");
122  return NS_OK;
123 }
124 
125 NS_IMETHODIMP
126 sbSimpleButtonPropertyInfo::GetColumnType(nsAString& _retval)
127 {
128  _retval.AssignLiteral("text");
129  return NS_OK;
130 }
131 
132 // sbIClickablePropertyInfo
133 
134 NS_IMETHODIMP
135 sbSimpleButtonPropertyInfo::GetSuppressSelect(PRBool* aSuppressSelect)
136 {
137  NS_ENSURE_ARG_POINTER(aSuppressSelect);
138  *aSuppressSelect = mSuppressSelect;
139  return NS_OK;
140 }
141 
142 NS_IMETHODIMP
143 sbSimpleButtonPropertyInfo::SetSuppressSelect(PRBool aSuppressSelect)
144 {
145  mSuppressSelect = aSuppressSelect;
146  return NS_OK;
147 }
148 
149 NS_IMETHODIMP
150 sbSimpleButtonPropertyInfo::IsDisabled(const nsAString& aCurrentValue,
151  PRBool* _retval)
152 {
153  NS_ENSURE_ARG_POINTER(_retval);
154 
155  PRInt32 pos = aCurrentValue.FindChar('|');
156  if (pos >= 0) {
157  *_retval = Substring(aCurrentValue, pos + 1).EqualsLiteral("1");
158  }
159  else {
160  *_retval = PR_FALSE;
161  }
162 
163  return NS_OK;
164 }
165 
166 NS_IMETHODIMP
167 sbSimpleButtonPropertyInfo::HitTest(const nsAString& aCurrentValue,
168  const nsAString& aPart,
169  PRUint32 aBoxWidth,
170  PRUint32 aBoxHeight,
171  PRUint32 aMouseX,
172  PRUint32 aMouseY,
173  PRBool* _retval)
174 {
175  NS_ENSURE_ARG_POINTER(_retval);
176 
177  PRBool isDisabled;
178  nsresult rv = IsDisabled(aCurrentValue, &isDisabled);
179  NS_ENSURE_SUCCESS(rv, rv);
180 
181  if (isDisabled) {
182  *_retval = PR_FALSE;
183  }
184  else {
185  *_retval = aPart.EqualsLiteral("text");
186  }
187  return NS_OK;
188 }
189 
190 NS_IMETHODIMP
191 sbSimpleButtonPropertyInfo::GetValueForClick(const nsAString& aCurrentValue,
192  PRUint32 aBoxWidth,
193  PRUint32 aBoxHeight,
194  PRUint32 aMouseX,
195  PRUint32 aMouseY,
196  nsAString& _retval)
197 {
198  return NS_ERROR_NOT_IMPLEMENTED;
199 }
200 
201 /* boolean onClick (in sbIMediaItem aItem,
202  [optional] in nsISupports aEvent,
203  [optional] in nsISupports aContext); */
204 NS_IMETHODIMP
205 sbSimpleButtonPropertyInfo::OnClick(sbIMediaItem *aItem,
206  nsISupports *aEvent,
207  nsISupports *aContext,
208  PRBool *_retval NS_OUTPARAM)
209 {
210  NS_ENSURE_ARG_POINTER(_retval);
211  *_retval = PR_FALSE;
212  return NS_OK;
213 }
214 
215 // sbIPropertyInfo
216 
217 NS_IMETHODIMP
218 sbSimpleButtonPropertyInfo::Format(const nsAString& aValue,
219  nsAString& _retval)
220 {
221  if (mHasLabel) {
222  _retval = mLabel;
223  }
224  else {
225  PRInt32 pos = aValue.FindChar('|');
226  if (pos >= 0) {
227  _retval = Substring(aValue, 0, pos);
228  }
229  else {
230  _retval = aValue;
231  }
232  }
233 
234  return NS_OK;
235 }
236 
boolean isDisabled(in AString aCurrentValue)
Whether the tree cell widget representing this property should be disabled given a value (for this pr...
NS_IMETHOD Format(const nsAString &aValue, nsAString &_retval)
return NS_OK
_dialogDatepicker pos
onPageChanged aValue
Definition: FeedWriter.js:1395
The property information specific to clickable properties.
NS_IMPL_ISUPPORTS_INHERITED2(sbSimpleButtonPropertyInfo, sbImmutablePropertyInfo, sbIClickablePropertyInfo, sbITreeViewPropertyInfo) sbSimpleButtonPropertyInfo
Interface that defines a single item of media in the system.