ImagePrint/ImagePrintUI/imageprintapp/src/cimageprintsettingscontainer.cpp
branchGCC_SURGE
changeset 25 59ea2209bb67
parent 23 08cc4cc059d4
parent 15 a92d00fca574
equal deleted inserted replaced
23:08cc4cc059d4 25:59ea2209bb67
     1 /*
       
     2 * Copyright (c) 2004-2007 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32keys.h>
       
    20 #include <aknViewAppUi.h>
       
    21 #include <coemop.h>
       
    22 #include <aknnavi.h>
       
    23 #include <aknstaticnotedialog.h>
       
    24 #include <AknQueryDialog.h>
       
    25 #include <aknnotewrappers.h>
       
    26 #include <AknDef.h>
       
    27 #include <imageprintapp.rsg>
       
    28 
       
    29 #include "cimageprintsettingscontainer.h"
       
    30 #include "imageprintapp.hrh"
       
    31 #include "cpropertiesboxmodel.h"
       
    32 #include "cimageprintappui.h"
       
    33 #include "imageprint.h"
       
    34 #include "cimageprintdoc.h"
       
    35 #include "cdiscoverydlgmanager.h"
       
    36 #include "cimageprintengine.h"
       
    37 #include "ciffactory.h"
       
    38 #include "clog.h"
       
    39 #include "printapputil.h"
       
    40 #include "midleprinteventregisterif.h"
       
    41 #include "cimgpprintutils.h"
       
    42 #include "muimode.h"
       
    43 
       
    44 //  CONSTRUCTION
       
    45 CImagePrintSettingsContainer* CImagePrintSettingsContainer::NewL(
       
    46     MPrintSettings* aSettings,
       
    47     MObjectProvider* aProvider,
       
    48     TRect aClientRect,
       
    49     CImagePrintAppUi* aAppUi,
       
    50     MUIMode* aUIMode )
       
    51     {
       
    52     CImagePrintSettingsContainer* self =
       
    53         new ( ELeave ) CImagePrintSettingsContainer( aSettings, aAppUi, aUIMode );
       
    54     CleanupStack::PushL( self );
       
    55     self->ConstructL( aProvider, aClientRect );
       
    56     CleanupStack::Pop( self );
       
    57 
       
    58     return self;
       
    59     }
       
    60 
       
    61 // Default constructor
       
    62 CImagePrintSettingsContainer::CImagePrintSettingsContainer(
       
    63     MPrintSettings* aSettings,
       
    64     CImagePrintAppUi* aAppUi,
       
    65     MUIMode* aUIMode ) :
       
    66     iPrintSettings( aSettings ),
       
    67     iAppUi( aAppUi ),
       
    68     iUIMode( aUIMode )
       
    69     {
       
    70     }
       
    71 
       
    72 // 2nd phase constructor
       
    73 void CImagePrintSettingsContainer::ConstructL(
       
    74     MObjectProvider* aProvider,
       
    75     const TRect& aRect )
       
    76     {
       
    77     // Create a window for this application view
       
    78     SetMopParent( aProvider );
       
    79     CreateWindowL();
       
    80     CImagePrintDoc* doc = static_cast<CImagePrintDoc*>( iAppUi->Document() );
       
    81     iModel = CPropertiesBoxModel::NewL( *( doc->Engine() ), iPrintSettings, this );
       
    82 
       
    83     // Initialize list box outlook
       
    84     iListBox = new ( ELeave ) CAknSettingStyleListBox;
       
    85     iListBox->SetContainerWindowL( *this );
       
    86     iListBox->ConstructL( this, EAknListBoxSelectionList );
       
    87     iListBox->CreateScrollBarFrameL( ETrue );
       
    88     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
    89         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
    90     iEikonEnv->EikAppUi()->AddToStackL( iListBox );
       
    91 
       
    92     // Set the model & observer
       
    93     iListBox->SetListBoxObserver( iModel );
       
    94     iListBox->Model()->SetItemTextArray( iModel );
       
    95     // List box won't delete model, the Controller object will take care of it
       
    96     iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
    97 
       
    98     // Set the windows size
       
    99     SetRect( aRect );
       
   100     iListBox->SetSize( iListBox->MinimumSize() );
       
   101 
       
   102     // Activate the window, which makes it ready to be drawn
       
   103     ActivateL();
       
   104 	}
       
   105 
       
   106 // Destructor
       
   107 CImagePrintSettingsContainer::~CImagePrintSettingsContainer()
       
   108     {
       
   109 	if ( iUSBConnectionWaitNote )
       
   110 		{
       
   111 		delete iUSBConnectionWaitNote;
       
   112 		}
       
   113     iEikonEnv->EikAppUi()->RemoveFromStack( iListBox );
       
   114     delete iListBox;
       
   115     delete iModel;
       
   116     }
       
   117 
       
   118 
       
   119 // Return the amount of compound controls
       
   120 TInt CImagePrintSettingsContainer::CountComponentControls() const
       
   121     {
       
   122     return 1;
       
   123 	}
       
   124 
       
   125 // Gets the specified component of a compound control.
       
   126 CCoeControl* CImagePrintSettingsContainer::ComponentControl(
       
   127     TInt aIndex ) const
       
   128     {
       
   129     CCoeControl* cntrl = 0;
       
   130 
       
   131     if ( aIndex == 0 )
       
   132         {
       
   133         cntrl = iListBox;
       
   134         }
       
   135 
       
   136     return cntrl;
       
   137     }
       
   138 
       
   139 // Draws the empty view
       
   140 void CImagePrintSettingsContainer::Draw(
       
   141     const TRect& /*aRect*/ ) const
       
   142     {
       
   143     CWindowGc& gc = SystemGc();
       
   144     gc.Clear();
       
   145     }
       
   146 
       
   147 // Starts editing the active item
       
   148 void CImagePrintSettingsContainer::EditItemL()
       
   149     {
       
   150     iModel->HandleListBoxEventL( iListBox,
       
   151                                  MEikListBoxObserver::EEventEnterKeyPressed );
       
   152                                  
       
   153     ChangeStatusPaneTextL( iModel->NumberOfCopies() );
       
   154     }
       
   155 
       
   156 void CImagePrintSettingsContainer::DoDiscoveryL( TInt aProtocol, TBool /*aHidden*/ )
       
   157 	{
       
   158 	TBool ret = iUIMode->ChangeDefaultPrinterL( aProtocol );
       
   159 	}
       
   160 
       
   161 void CImagePrintSettingsContainer::ChangeStatusPaneTextL( const TInt aCopiesOfImage )
       
   162     {    
       
   163      iAppUi->SetNavipaneTextL( aCopiesOfImage );
       
   164    }
       
   165 
       
   166 void CImagePrintSettingsContainer::UpdateListBox()
       
   167 	{
       
   168 	iListBox->SizeChanged();
       
   169 	}
       
   170 
       
   171 void CImagePrintSettingsContainer::UpdateListSize( TRect /*aRect*/ )
       
   172     {
       
   173     iListBox->SetSize( iListBox->MinimumSize() );
       
   174     }
       
   175 
       
   176 void CImagePrintSettingsContainer::SizeChanged()
       
   177 	{
       
   178 	iListBox->SetSize( iListBox->MinimumSize() );
       
   179 	}
       
   180 
       
   181 void CImagePrintSettingsContainer::HandleResourceChange( TInt aType )
       
   182     {
       
   183     CCoeControl::HandleResourceChange( aType );
       
   184     if( aType == KEikDynamicLayoutVariantSwitch )
       
   185         {
       
   186         TRect rect = iAppUi->ClientRect();
       
   187         SetRect( rect );
       
   188         UpdateListSize( rect );
       
   189         DrawNow();
       
   190         }
       
   191     }
       
   192 
       
   193 //  End of File