textinput/peninputcommonctrls/src/peninputbasewindow/peninputbasewindow.cpp
changeset 27 694fa80c203c
parent 24 fc42a86c98e3
child 35 0f326f2e628e
equal deleted inserted replaced
24:fc42a86c98e3 27:694fa80c203c
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  CAknFepCtrlBaseWindow
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDES
       
    20 #include <peninputbutton.h>
       
    21 #include <peninputdragbutton.h>
       
    22 #include <peninputbasewindow.h>
       
    23 #include <peninputcommonbutton.h>
       
    24 #include <AknIconUtils.h>
       
    25 // ---------------------------------------------------------
       
    26 // Constructor
       
    27 // ---------------------------------------------------------
       
    28 //
       
    29 EXPORT_C CAknFepCtrlBaseWindow::CAknFepCtrlBaseWindow(CFepUiLayout* aFepUiLayout, 
       
    30                                           TInt aControlId)
       
    31     :CControlGroup(aFepUiLayout,aControlId)
       
    32     {
       
    33     }
       
    34 
       
    35 // ---------------------------------------------------------
       
    36 // Constructor
       
    37 // ---------------------------------------------------------
       
    38 //
       
    39 EXPORT_C void CAknFepCtrlBaseWindow::BaseConstructL()
       
    40     {
       
    41     CControlGroup::ConstructL();
       
    42     
       
    43     iTitleBar = CControlGroup::NewL(UiLayout(), 0, EFalse);
       
    44     iClientPane = CControlGroup::NewL(UiLayout(), 0, EFalse);
       
    45      
       
    46     iMoveButton = CAknFepCtrlDragButton::NewL(UiLayout(), 0);
       
    47     
       
    48     iMoveButton->SetImageFrameId(KAknsIIDQsnFrFunctionButtonNormal,
       
    49         									  KAknsIIDQsnFrFunctionButtonPressed,
       
    50         									  KAknsIIDQsnFrFunctionButtonInactive);       
       
    51     
       
    52     iCloseButton = CAknFepCtrlCommonButton::NewL(UiLayout(), 0, 
       
    53             								  KAknsIIDQsnFrFunctionButtonNormal,
       
    54         									  KAknsIIDQsnFrFunctionButtonPressed,
       
    55         									  KAknsIIDQsnFrFunctionButtonInactive);
       
    56     iHeaderPane = CControlGroup::NewL(UiLayout(), 0, EFalse);
       
    57 
       
    58     iTitleBar->AddControlL(iMoveButton);
       
    59     iTitleBar->AddControlL(iHeaderPane);
       
    60     iTitleBar->AddControlL(iCloseButton);
       
    61     iCloseButton->AddEventObserver(this);
       
    62     iMoveButton->AddPositionObserver(this);
       
    63     
       
    64     AddControlL(iTitleBar);
       
    65     AddControlL(iClientPane);
       
    66     }
       
    67     
       
    68 // ---------------------------------------------------------
       
    69 // Destructor
       
    70 // ---------------------------------------------------------
       
    71 //
       
    72 EXPORT_C CAknFepCtrlBaseWindow::~CAknFepCtrlBaseWindow()
       
    73     {
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------
       
    77 // Draw window frame and sub controls
       
    78 // ---------------------------------------------------------
       
    79 //
       
    80 EXPORT_C void CAknFepCtrlBaseWindow::Draw()
       
    81     {
       
    82 	if(!AbleToDraw())
       
    83         return;
       
    84 
       
    85     //Clear();
       
    86     DrawOpaqueMaskBackground( Rect() );
       
    87     CFbsBitGc* gc= static_cast<CFbsBitGc*> ( BitGc());
       
    88 /*
       
    89     gc->Activate( MaskBitmapDevice() );
       
    90     gc->SetBrushStyle( CGraphicsContext::ENullBrush );
       
    91     gc->SetBrushColor( MaskBkCol() );
       
    92     gc->SetPenSize( PenSize());
       
    93     gc->SetPenColor( PenColor() );
       
    94 
       
    95     gc->DrawRect( Rect());
       
    96     TRect rect = iTitleBar->Rect();
       
    97     gc->DrawRect(rect);
       
    98 */
       
    99     // ----- draw bitmaps -----
       
   100     gc->Activate( BitmapDevice() ); 
       
   101     gc->SetBrushColor( TRgb(KOpaqueColor) );
       
   102     gc->SetPenColor( TRgb(KOpaqueColor) );
       
   103     gc->DrawRect( Rect());
       
   104     if( BackgroundBmp() && BackgroundBmp()->SizeInPixels() != Rect().Size() )    
       
   105     	AknIconUtils::SetSize(BackgroundBmp(), Rect().Size(), EAspectRatioNotPreserved);
       
   106     
       
   107 	DrawBackground();
       
   108 	CControlGroup::Draw();
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------
       
   112 // Close window
       
   113 // ---------------------------------------------------------
       
   114 //
       
   115 EXPORT_C void CAknFepCtrlBaseWindow::Close()
       
   116     {
       
   117     if (DoClose())
       
   118         {
       
   119         Hide(ETrue);
       
   120         }
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------
       
   124 // Enable or disable drag window
       
   125 // ---------------------------------------------------------
       
   126 //
       
   127 EXPORT_C void CAknFepCtrlBaseWindow::SetDragEnable(TBool aEnable)
       
   128     {
       
   129     if (iMoveButton)
       
   130         {
       
   131         iMoveButton->EnableDragging(aEnable);
       
   132         }
       
   133     }
       
   134 
       
   135 // ---------------------------------------------------------
       
   136 // Handle close event
       
   137 // ---------------------------------------------------------
       
   138 //
       
   139 EXPORT_C void CAknFepCtrlBaseWindow::HandleControlEvent(TInt aEventType, 
       
   140                                              CFepUiBaseCtrl* aCtrl, 
       
   141                                              const TDesC& /*aEventData*/)
       
   142     {
       
   143     if (aEventType == EEventButtonUp)
       
   144         {
       
   145         if (aCtrl == iCloseButton)
       
   146             {
       
   147             Close();
       
   148             }
       
   149         }
       
   150     }
       
   151 
       
   152 EXPORT_C TBool CAknFepCtrlBaseWindow::DoClose()
       
   153     {
       
   154     return ETrue;
       
   155     }
       
   156     
       
   157 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlBaseWindow::Control(TInt aCtrlId)
       
   158     {
       
   159     CFepUiBaseCtrl* ctrl = NULL;
       
   160     RPointerArray<CFepUiBaseCtrl> todo;
       
   161     TInt current = 0;
       
   162     TBool notFound = ETrue;
       
   163     
       
   164     todo.Append(this);
       
   165     
       
   166     while (current < todo.Count() && notFound)
       
   167         {
       
   168         ctrl = todo[current];
       
   169         if(ctrl->ControlId() == aCtrlId)
       
   170             {
       
   171             notFound = EFalse;     
       
   172             }
       
   173         else
       
   174             {
       
   175             if(ctrl->IsKindOfControl(ECtrlControlGroup))
       
   176                 {
       
   177                 CControlGroup* temp = static_cast<CControlGroup*>(ctrl);
       
   178                 for (int i = 0; i < temp->NumOfControls(); i++)
       
   179                     {
       
   180                     todo.Append(temp->At(i));
       
   181                     }
       
   182                 }
       
   183             current++;
       
   184             }
       
   185         }
       
   186         
       
   187     todo.Close();
       
   188     
       
   189     return notFound ? NULL : ctrl;
       
   190     }    
       
   191 
       
   192 // End Of File