WindowMinMax.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 
32  // Yet another shameful hack from lone
33 #include "WindowMinMax.h"
34 #include "WindowMinMaxSubclass.h"
35 #include "../NativeWindowFromNode.h"
36 
37 // CLASSES ====================================================================
38 //=============================================================================
39 // CWindowMinMax Class
40 //=============================================================================
41 
42 // This implements a callback into js so that script code may dynamically limit
43 // the position and size of a window
44 
45 //-----------------------------------------------------------------------------
46 /* Implementation file */
48 
49 //-----------------------------------------------------------------------------
51 {
52 } // ctor
53 
54 //-----------------------------------------------------------------------------
56 {
57 } // dtor
58 
59 //-----------------------------------------------------------------------------
60 NS_IMETHODIMP CWindowMinMax::SetCallback(nsISupports *window, sbIWindowMinMaxCallback *cb)
61 {
62  if (NativeWindowFromNode::get(window) == NULL) return NS_ERROR_FAILURE;
63  m_subclasses.push_back(new CWindowMinMaxSubclass(window, cb));
64  return NS_OK;
65 } // SetCallback
66 
67 //-----------------------------------------------------------------------------
68 NS_IMETHODIMP CWindowMinMax::ResetCallback(nsISupports *window )
69 {
70  CWindowMinMaxSubclass *subclass = findSubclassByWindow(window);
71  if (!subclass) return NS_ERROR_FAILURE;
72  m_subclasses.remove(subclass);
73  delete subclass;
74  return NS_OK;
75 } // ResetCallback
76 
77 //-----------------------------------------------------------------------------
79 {
80  std::list<CWindowMinMaxSubclass*>::iterator iter;
81  for (iter = m_subclasses.begin(); iter != m_subclasses.end(); iter++)
82  {
83  CWindowMinMaxSubclass *subclass = *iter;
84  if (subclass->getWindow()) return subclass;
85  }
86  return NULL;
87 } // findSubclassByWindow
88 
WindowMinMax service interface This is an interface to the WindowMinMax service, used to set and rese...
std::list< CWindowMinMaxSubclass * > m_subclasses
Definition: WindowMinMax.h:77
Service for setting min/max limit callbacks to a window position and size - Prototypes.
return NS_OK
CWindowMinMaxSubclass * findSubclassByWindow(nsISupports *window)
NS_IMPL_ISUPPORTS1(sbDeviceCapabilitiesUtils, sbIDeviceCapabilitiesUtils) sbDeviceCapabilitiesUtils
let window
Window subclasser object for WindowMinMax service - Prototypes.
virtual ~CWindowMinMax()
WindowMinMax callback interface This interface describes a callback for the WindowMinMax service...
static void * get(nsISupports *window)