Back to index

lightning-sunbird  0.9+nobinonly
nsIViewManager.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nsIViewManager_h___
00039 #define nsIViewManager_h___
00040 
00041 #include "nscore.h"
00042 #include "nsIView.h"
00043 #include "nsColor.h"
00044 #include "nsEvent.h"
00045 
00046 class nsIScrollableView;
00047 class nsIWidget;
00048 class nsICompositeListener;
00049 struct nsRect;
00050 class nsRegion;
00051 class nsIDeviceContext;
00052 class nsIViewObserver;
00053 
00054 enum nsRectVisibility { 
00055   nsRectVisibility_kVisible, 
00056   nsRectVisibility_kAboveViewport, 
00057   nsRectVisibility_kBelowViewport, 
00058   nsRectVisibility_kLeftOfViewport, 
00059   nsRectVisibility_kRightOfViewport, 
00060   nsRectVisibility_kZeroAreaRect
00061 }; 
00062 
00063 
00064 #define NS_IVIEWMANAGER_IID   \
00065 { 0xd9af8f22, 0xc64d, 0x4036, \
00066   { 0x9e, 0x8b, 0x69, 0x5a, 0x63, 0x69, 0x3f, 0xd3 } }
00067 
00068 class nsIViewManager : public nsISupports
00069 {
00070 public:
00071 
00072   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID)
00079   NS_IMETHOD  Init(nsIDeviceContext* aContext) = 0;
00080 
00093   NS_IMETHOD_(nsIView*) CreateView(const nsRect& aBounds,
00094                                    const nsIView* aParent,
00095                                    nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow) = 0;
00096 
00107   NS_IMETHOD_(nsIScrollableView*) CreateScrollableView(const nsRect& aBounds,
00108                                                        const nsIView* aParent) = 0;
00109 
00114   NS_IMETHOD  GetRootView(nsIView *&aView) = 0;
00115 
00122   NS_IMETHOD  SetRootView(nsIView *aView) = 0;
00123 
00130   NS_IMETHOD  GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) = 0;
00131 
00139   NS_IMETHOD  SetWindowDimensions(nscoord aWidth, nscoord aHeight) = 0;
00140 
00144   // XXXbz why is this exposed?  Shouldn't update view batches handle this?
00145   // It's not like Composite() does what's expected inside a view update batch
00146   // anyway, since dirty areas may not have been invalidated on the widget yet
00147   // and widget changes may not have been propagated yet.  Maybe this should
00148   // call FlushPendingInvalidates()?
00149   NS_IMETHOD  Composite(void) = 0;
00150 
00157   NS_IMETHOD  UpdateView(nsIView *aView, PRUint32 aUpdateFlags) = 0;
00158 
00167   NS_IMETHOD  UpdateView(nsIView *aView, const nsRect &aRect, PRUint32 aUpdateFlags) = 0;
00168 
00174   NS_IMETHOD  UpdateAllViews(PRUint32 aUpdateFlags) = 0;
00175 
00183   NS_IMETHOD  DispatchEvent(nsGUIEvent *aEvent, nsEventStatus* aStatus) = 0;
00184 
00192   NS_IMETHOD  GrabMouseEvents(nsIView *aView, PRBool& aResult) = 0;
00193 
00201   NS_IMETHOD  GrabKeyEvents(nsIView *aView, PRBool& aResult) = 0;
00202 
00207   NS_IMETHOD  GetMouseEventGrabber(nsIView *&aView) = 0;
00208 
00213   NS_IMETHOD  GetKeyEventGrabber(nsIView *&aView) = 0;
00214 
00230   NS_IMETHOD  InsertChild(nsIView *aParent, nsIView *aChild, nsIView *aSibling,
00231                           PRBool aAfter) = 0;
00232 
00242   NS_IMETHOD  InsertZPlaceholder(nsIView *aParent, nsIView *aChild, nsIView *aSibling,
00243                                  PRBool aAfter) = 0;
00244 
00252   NS_IMETHOD  RemoveChild(nsIView *aChild) = 0;
00253 
00263   NS_IMETHOD  MoveViewTo(nsIView *aView, nscoord aX, nscoord aY) = 0;
00264 
00277   NS_IMETHOD  ResizeView(nsIView *aView, const nsRect &aRect,
00278                          PRBool aRepaintExposedAreaOnly = PR_FALSE) = 0;
00279 
00300   NS_IMETHOD  SetViewChildClipRegion(nsIView *aView, const nsRegion *aRegion) = 0;
00301 
00308   NS_IMETHOD  SetViewVisibility(nsIView *aView, nsViewVisibility aVisible) = 0;
00309 
00326   NS_IMETHOD  SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, PRInt32 aZindex, PRBool aTopMost = PR_FALSE) = 0;
00327 
00335   NS_IMETHOD  SetViewFloating(nsIView *aView, PRBool aFloatingView) = 0;
00336 
00340   NS_IMETHOD  SetViewBitBltEnabled(nsIView *aView, PRBool aEnable) = 0;
00341 
00345   NS_IMETHOD  SetViewCheckChildEvents(nsIView *aView, PRBool aEnable) = 0;
00346 
00352   NS_IMETHOD  SetViewContentTransparency(nsIView *aView, PRBool aTransparent) = 0;
00353 
00360   NS_IMETHOD  SetViewOpacity(nsIView *aView, float aOpacity) = 0;
00361 
00367   NS_IMETHOD SetViewObserver(nsIViewObserver *aObserver) = 0;
00368 
00374   NS_IMETHOD GetViewObserver(nsIViewObserver *&aObserver) = 0;
00375 
00380   NS_IMETHOD  GetDeviceContext(nsIDeviceContext *&aContext) = 0;
00381 
00386   // XXXbz callers of this function don't seem to realize that it disables
00387   // refresh for the entire view manager hierarchy.... Maybe it shouldn't do
00388   // that?
00389   NS_IMETHOD DisableRefresh(void) = 0;
00390 
00397   NS_IMETHOD EnableRefresh(PRUint32 aUpdateFlags) = 0;
00398 
00405   NS_IMETHOD BeginUpdateViewBatch(void) = 0;
00406 
00429   NS_IMETHOD EndUpdateViewBatch(PRUint32 aUpdateFlags) = 0;
00430 
00437   NS_IMETHOD SetRootScrollableView(nsIScrollableView *aScrollable) = 0;
00438 
00445   NS_IMETHOD GetRootScrollableView(nsIScrollableView **aScrollable) = 0;
00446 
00450    //XXXbz how is this different from UpdateView(NS_VMREFRESH_IMMEDIATE)?
00451   NS_IMETHOD Display(nsIView *aView, nscoord aX, nscoord aY, const nsRect& aClipRect) = 0;
00452 
00469   NS_IMETHOD RenderOffscreen(nsIView* aView, nsRect aRect, PRBool aUntrusted,
00470                              PRBool aIgnoreViewportScrolling,
00471                              nscolor aBackgroundColor,
00472                              nsIRenderingContext** aRenderedContext) = 0;
00473 
00479   NS_IMETHOD AddCompositeListener(nsICompositeListener *aListener) = 0;
00480 
00486   NS_IMETHOD RemoveCompositeListener(nsICompositeListener *aListener) = 0;
00487 
00493   NS_IMETHOD GetWidget(nsIWidget **aWidget) = 0;
00494 
00500   // XXXbz Callers seem to be confused about this one... and it doesn't play
00501   // right with view update batching at all (will miss updates).  Maybe this
00502   // should call FlushPendingInvalidates()?
00503   NS_IMETHOD ForceUpdate() = 0;
00504   
00514   NS_IMETHOD AllowDoubleBuffering(PRBool aDoubleBuffer)=0;
00515 
00522   NS_IMETHOD IsPainting(PRBool& aIsPainting)=0;
00523 
00531   NS_IMETHOD SetDefaultBackgroundColor(nscolor aColor)=0;
00532 
00538   NS_IMETHOD GetDefaultBackgroundColor(nscolor* aColor)=0;
00539 
00547   NS_IMETHOD GetLastUserEventTime(PRUint32& aTime)=0;
00548 
00559   NS_IMETHOD GetRectVisibility(nsIView *aView, const nsRect &aRect, 
00560                                PRUint16 aMinTwips, 
00561                                nsRectVisibility *aRectVisibility)=0;
00562 
00568   NS_IMETHOD SynthesizeMouseMove(PRBool aFromScroll)=0;
00569 };
00570 
00571 // Paint timing mode flags
00572 
00573 // intermediate: do no special timing processing; repaint when the
00574 // toolkit issues an expose event (which will happen *before* PLEvent
00575 // processing). This is essentially the default.
00576 #define NS_VMREFRESH_NO_SYNC            0
00577 
00578 // least immediate: we suppress invalidation, storing dirty areas in
00579 // views, and post an Invalidate PLEvent. The Invalidate event gets
00580 // processed after toolkit events such as window resize events!
00581 // This is only usable with EndUpdateViewBatch and EnableRefresh.
00582 #define NS_VMREFRESH_DEFERRED           0x0001
00583 
00584 // most immediate: force a call to nsViewManager::Composite, which
00585 // synchronously updates the window(s) right away before returning
00586 #define NS_VMREFRESH_IMMEDIATE          0x0002
00587 
00588 //animate scroll operation
00589 #define NS_VMREFRESH_SMOOTHSCROLL       0x0008
00590 
00591 #endif  // nsIViewManager_h___