javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/control/VideoItem.java
changeset 23 98ccebc37403
child 26 dc7c549001d5
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Item for VideoControl.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 package com.nokia.microedition.media.control;
       
    20 
       
    21 import javax.microedition.lcdui.CustomItem;
       
    22 import javax.microedition.lcdui.Graphics;
       
    23 import javax.microedition.media.PlayerListener;
       
    24 import javax.microedition.media.Player;
       
    25 import javax.microedition.lcdui.*;
       
    26 
       
    27 /**
       
    28  * Item for VideoControl.
       
    29  * This class native equivalent is CMIDItemDisplay.
       
    30  * All drawing is done in native.
       
    31  * CustomItem has its native bitmap after it is layouted to
       
    32  * the form and then SizeChanged method is called and native side
       
    33  * gets the bitmap for item.
       
    34  *
       
    35  */
       
    36 public class VideoItem extends CustomItem implements PlayerListener
       
    37 {
       
    38     int iNativeHandle;
       
    39 
       
    40     private int iEventSourceHandle;
       
    41 
       
    42     public VideoItem(int aEventSourceHandle)
       
    43     {
       
    44         super("");   // we don't have title
       
    45         iEventSourceHandle = aEventSourceHandle;
       
    46     }
       
    47 
       
    48     // from PlayerListener
       
    49     public void playerUpdate(Player aPlayer, String aEvent, Object aEventData)
       
    50     {
       
    51         if (aEvent == SIZE_CHANGED)
       
    52         {
       
    53             invalidate();
       
    54         }
       
    55     }
       
    56 
       
    57     /**
       
    58      * From class CustomItem
       
    59      *
       
    60      */
       
    61     protected int getMinContentHeight()
       
    62     {
       
    63         int minHeight = 0;
       
    64         if (iNativeHandle != 0)
       
    65         {
       
    66             minHeight = _getMinContentHeight(iEventSourceHandle,
       
    67                                              iNativeHandle);
       
    68         }
       
    69         return minHeight;
       
    70     }
       
    71 
       
    72     /**
       
    73      * From class CustomItem
       
    74      *
       
    75      */
       
    76     protected int getMinContentWidth()
       
    77     {
       
    78         int minWidth = 0;
       
    79         if (iNativeHandle != 0)
       
    80         {
       
    81             minWidth = _getMinContentWidth(iEventSourceHandle,
       
    82                                            iNativeHandle);
       
    83         }
       
    84         return minWidth;
       
    85     }
       
    86 
       
    87     /**
       
    88      * From class CustomItem
       
    89      *
       
    90      */
       
    91     protected int getPrefContentHeight(int aWidth)
       
    92     {
       
    93         int prefHeight = 0;
       
    94         if (iNativeHandle != 0)
       
    95         {
       
    96             prefHeight = _getPrefContentHeight(iEventSourceHandle,
       
    97                                                iNativeHandle,
       
    98                                                aWidth);
       
    99         }
       
   100         return prefHeight;
       
   101     }
       
   102 
       
   103     /**
       
   104      * From class CustomItem
       
   105      *
       
   106      */
       
   107     protected int getPrefContentWidth(int aHeight)
       
   108     {
       
   109         int prefWidth = 0;
       
   110         if (iNativeHandle != 0)
       
   111         {
       
   112             prefWidth = _getPrefContentWidth(iEventSourceHandle,
       
   113                                              iNativeHandle,
       
   114                                              aHeight);
       
   115         }
       
   116         return prefWidth;
       
   117     }
       
   118 
       
   119     /**
       
   120      * From class CustomItem
       
   121      *
       
   122      * Empty implementation because drawing is done in native side.
       
   123      * Must be implemented because this method is abstract.
       
   124      *
       
   125      */
       
   126     protected void paint(Graphics aGrapchics, int aWidth, int aHeight)
       
   127     {
       
   128     }
       
   129 
       
   130     /**
       
   131      * From class CustomItem
       
   132      *
       
   133      */
       
   134     protected void sizeChanged(int aWidth, int aHeight)
       
   135     {
       
   136         if (iNativeHandle != 0)
       
   137         {
       
   138             _sizeChanged(iEventSourceHandle,
       
   139                          iNativeHandle,
       
   140                          aWidth,
       
   141                          aHeight);
       
   142         }
       
   143     }
       
   144 
       
   145     /**
       
   146      * Package private method for invalidating the Form owning this item.
       
   147      */
       
   148     void privateInvalidate()
       
   149     {
       
   150         invalidate();
       
   151     }
       
   152 
       
   153     /**
       
   154      * Sets native CMIDItemDisplay handle.
       
   155      */
       
   156     void setNativeHandle(int aHandle)
       
   157     {
       
   158         iNativeHandle = aHandle;
       
   159     }
       
   160 
       
   161     // Native methods
       
   162 
       
   163     /**
       
   164      * Informs got size to native side.
       
   165      */
       
   166     private native int _sizeChanged(int aEventSourceHandle,
       
   167                                     int aNativeHandle,
       
   168                                     int aWidth,
       
   169                                     int aHeight);
       
   170 
       
   171     // Getters for layout.
       
   172     private native int _getMinContentWidth(int aEventSourceHandle,
       
   173                                            int aNativeHandle);
       
   174     private native int _getMinContentHeight(int aEventSourceHandle,
       
   175                                             int aNativeHandle);
       
   176     private native int _getPrefContentWidth(int aEventSourceHandle,
       
   177                                             int aNativeHandle,
       
   178                                             int aTentativeWidth);
       
   179     private native int _getPrefContentHeight(int aEventSourceHandle,
       
   180             int aNativeHandle,
       
   181             int aTentativeHeigth);
       
   182 }