Home | History | Annotate | Download | only in view
      1 /*
      2  * Copyright (C) 2006 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.view;
     18 
     19 /**
     20  * Provides low-level communication with the system window manager for
     21  * operations that are bound to a particular context, display or parent window.
     22  * Instances of this object are sensitive to the compatibility info associated
     23  * with the running application.
     24  *
     25  * This object implements the {@link ViewManager} interface,
     26  * allowing you to add any View subclass as a top-level window on the screen.
     27  * Additional window manager specific layout parameters are defined for
     28  * control over how windows are displayed.  It also implements the {@link WindowManager}
     29  * interface, allowing you to control the displays attached to the device.
     30  *
     31  * <p>Applications will not normally use WindowManager directly, instead relying
     32  * on the higher-level facilities in {@link android.app.Activity} and
     33  * {@link android.app.Dialog}.
     34  *
     35  * <p>Even for low-level window manager access, it is almost never correct to use
     36  * this class.  For example, {@link android.app.Activity#getWindowManager}
     37  * provides a window manager for adding windows that are associated with that
     38  * activity -- the window manager will not normally allow you to add arbitrary
     39  * windows that are not associated with an activity.
     40  *
     41  * @see WindowManager
     42  * @see WindowManagerGlobal
     43  * @hide
     44  */
     45 public final class WindowManagerImpl implements WindowManager {
     46     private final WindowManagerGlobal mGlobal = WindowManagerGlobal.getInstance();
     47     private final Display mDisplay;
     48     private final Window mParentWindow;
     49 
     50     public WindowManagerImpl(Display display) {
     51         this(display, null);
     52     }
     53 
     54     private WindowManagerImpl(Display display, Window parentWindow) {
     55         mDisplay = display;
     56         mParentWindow = parentWindow;
     57     }
     58 
     59     public WindowManagerImpl createLocalWindowManager(Window parentWindow) {
     60         return new WindowManagerImpl(mDisplay, parentWindow);
     61     }
     62 
     63     public WindowManagerImpl createPresentationWindowManager(Display display) {
     64         return new WindowManagerImpl(display, mParentWindow);
     65     }
     66 
     67     @Override
     68     public void addView(View view, ViewGroup.LayoutParams params) {
     69         mGlobal.addView(view, params, mDisplay, mParentWindow);
     70     }
     71 
     72     @Override
     73     public void updateViewLayout(View view, ViewGroup.LayoutParams params) {
     74         mGlobal.updateViewLayout(view, params);
     75     }
     76 
     77     @Override
     78     public void removeView(View view) {
     79         mGlobal.removeView(view, false);
     80     }
     81 
     82     @Override
     83     public void removeViewImmediate(View view) {
     84         mGlobal.removeView(view, true);
     85     }
     86 
     87     @Override
     88     public Display getDefaultDisplay() {
     89         return mDisplay;
     90     }
     91 }
     92