DirectPrint/DirectPrintApp/ui/inc/directprintpreviewcontrol.h
changeset 19 2275db202402
parent 11 613a5ff70823
equal deleted inserted replaced
2:acc370d7f2f6 19:2275db202402
       
     1 /*
       
     2 * Copyright (c) 2010 Kanrikogaku Kenkyusho, Ltd.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "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 * Kanrikogaku Kenkyusho, Ltd. - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * {Description of the file}
       
    16 *
       
    17 */
       
    18 
       
    19 // Protection against nested includes
       
    20 #ifndef __DIRECTPRINTPREVIEWCONTROL_H__
       
    21 #define __DIRECTPRINTPREVIEWCONTROL_H__
       
    22 
       
    23 // System includes
       
    24 #include <eikbctrl.h>
       
    25 #include <prnprev.h>
       
    26 
       
    27 // Forward declarations
       
    28 class CPrintSetup;
       
    29 class TPrintPreviewFormat;
       
    30 class MPageRegionPrinter;
       
    31 class MPrintProcessObserver;
       
    32 
       
    33 // Class declaration
       
    34 /**
       
    35  *  Preview control class
       
    36  *  more_complete_description
       
    37  */
       
    38 class CDirectPrintPreviewControl : public CEikBorderedControl
       
    39 								 , public MCoeControlObserver
       
    40 	{
       
    41 public:
       
    42 	// Data types
       
    43 	/** The index of zoom level */
       
    44 	enum TPreviewZoomLevel
       
    45 		{
       
    46 		EPreviewZoomLevel1, // display into view area
       
    47 		EPreviewZoomLevel2,
       
    48 		EPreviewZoomLevel3,
       
    49 		EPreviewZoomLevel4,
       
    50 		EPreviewZoomLevel5,
       
    51 		EPreviewZoomLevelMax
       
    52 		};
       
    53 
       
    54 public:
       
    55 	/** Constructors */
       
    56 	static CDirectPrintPreviewControl* NewL(const CCoeControl* aParent);
       
    57 	static CDirectPrintPreviewControl* NewLC(const CCoeControl* aParent);
       
    58 	/** Destructor */
       
    59 	virtual ~CDirectPrintPreviewControl();
       
    60 
       
    61 public:
       
    62 	/**
       
    63 	 * Set observer.
       
    64 	 *
       
    65 	 * @param aObserver Pointer to observer.
       
    66 	 */
       
    67 	void SetPreviewImageObserver(MPrintProcessObserver* aObserver);
       
    68 
       
    69 	/**
       
    70 	 * Initialize display format.
       
    71 	 *
       
    72 	 * @param aPrintSetup Setup information.
       
    73 	 * @param aBodyPrinter Body printer.
       
    74 	 * @param aFormat Display format information.
       
    75 	 * @param aNumPagesInDoc Number of all pages.
       
    76 	 * @param aFirstPageToDisplay Page number of first display.
       
    77 	 * @param aNumPagesToView Number of pages to view.
       
    78 	 * @param aMarginState Margin information.
       
    79 	 */
       
    80 	void InitializeFormat(	CPrintSetup& aPrintSetup,
       
    81 							MPageRegionPrinter& aBodyPrinter,
       
    82 							TPrintPreviewFormat& aFormat,
       
    83 							TInt& aNumPagesInDoc,
       
    84 							TInt& aFirstPageToDisplay,
       
    85 							TInt aNumPagesToView,
       
    86 							CPrintPreviewImage::TMarginState& aMarginState);
       
    87 	/**
       
    88 	 * Set display format.
       
    89 	 *
       
    90 	 * @param aFirstPageToDisplay Page number of first display.
       
    91 	 * @param aNumPagesToView Count of pages to view.
       
    92 	 */
       
    93 	void SetFormatAndDrawL(TInt& aFirstPageToDisplay,TInt& aNumPagesToView);
       
    94 	/**
       
    95 	 * Set margin.
       
    96 	 *
       
    97 	 * @param aMarginState Margin information.
       
    98 	 */
       
    99 	void SetMarginAndDrawL(CPrintPreviewImage::TMarginState aMarginState);
       
   100 	/**
       
   101 	 * Set number of bands.
       
   102 	 *
       
   103 	 * @param aNumBands Number of bands.
       
   104 	 */
       
   105 	void SetNumBands(TInt aNumBands);
       
   106 	/**
       
   107 	 * Set page number.
       
   108 	 *
       
   109 	 * @param aNumPagesInDoc Number of all pages.
       
   110 	 * @param aFirstPageToDisplay Page number of first display.
       
   111 	 * @param aNumPagesToView Number of pages to view.
       
   112 	 */
       
   113 	void SetNumPagesInDoc(TInt aNumPagesInDoc,TInt aFirstPageToDisplay,TInt aNumPagesToView);
       
   114 
       
   115 public: // from CCoeControl
       
   116 	/**
       
   117 	 * From CCoeControl.
       
   118 	 * Activate.
       
   119 	 */
       
   120 	void ActivateL();
       
   121 	/**
       
   122 	 * From CCoeControl.
       
   123 	 * Draw display.
       
   124 	 *
       
   125 	 * @param aRect Rect to draw.
       
   126 	 */
       
   127 	void Draw(const TRect& aRect) const;
       
   128 
       
   129 	/**
       
   130 	 * From CCoeControl.
       
   131 	 * Handles key events.
       
   132 	 *
       
   133 	 * @param aKeyEvent The code of key event.
       
   134 	 * @param aType The code of event.
       
   135 	 * @return The code of key response.
       
   136 	 */
       
   137 	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
       
   138 	/**
       
   139 	 * From CCoeControl.
       
   140 	 * Constructor.
       
   141 	 *
       
   142 	 * @param aReader ResourceReader.
       
   143 	 */
       
   144 //	void ConstructFromResourceL(TResourceReader& aReader);
       
   145 	/**
       
   146 	 * Set flag.
       
   147 	 *
       
   148 	 * @param aDraw Draw flag.
       
   149 	 */
       
   150 	void SetDrawFlag(TBool aDraw);
       
   151 	/**
       
   152 	 * Get flag.
       
   153 	 *
       
   154 	 * @return Draw flag.
       
   155 	 */
       
   156 	TBool DrawFlag();
       
   157 	/**
       
   158 	 * From CCoeControl.
       
   159 	 * Get input capabilities.
       
   160 	 *
       
   161 	 * @return Input capabilities.
       
   162 	 */
       
   163 	TCoeInputCapabilities InputCapabilities() const;
       
   164 
       
   165 	// for zoom
       
   166 	/**
       
   167 	 * Set zoom level.
       
   168 	 *
       
   169 	 * @param aZoomLevel Zoom level.
       
   170 	 */
       
   171 	void SetZoomLevel(TInt aZoomLevel);
       
   172 	/**
       
   173 	 * Get zoom level.
       
   174 	 *
       
   175 	 * @return Zoom level.
       
   176 	 */
       
   177 	TInt GetZoomLebel();
       
   178 	/**
       
   179 	 * Increment zoom level.
       
   180 	 */
       
   181 	void IncrementZoomLevel();
       
   182 	/**
       
   183 	 * Decrement zoom level.
       
   184 	 */
       
   185 	void DecrementZoomLevel();
       
   186 
       
   187 protected: // from CCoeControl
       
   188 	void SizeChanged();
       
   189 	TInt CountComponentControls() const;
       
   190 	CCoeControl* ComponentControl(TInt aIndex) const;
       
   191 
       
   192 	void WriteInternalStateL(RWriteStream& aWriteStream) const;
       
   193 
       
   194 	/**
       
   195 	 * From CoeControl, HandlePointerEventL.
       
   196 	 * Called by framework when a pointer touch event occurs.
       
   197 	 * Note: although this method is compatible with earlier SDKs,
       
   198 	 * it will not be called in SDKs without Touch support.
       
   199 	 * @param aPointerEvent the information about this event
       
   200 	 */
       
   201 	virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   202 
       
   203 private: // from CCoeControl
       
   204 //	void SetContainerWindowL(const CCoeControl& aParent);
       
   205 
       
   206 private: // from MCoeControlObserver
       
   207 	void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEvent);
       
   208 
       
   209 private:
       
   210 	CDirectPrintPreviewControl();
       
   211 	void ConstructL(const CCoeControl* aParent);
       
   212 
       
   213 private:
       
   214 	void CreateScrollButtonsL();
       
   215 	void DrawPreview(const TRect& aRect);
       
   216 	void SwitchFirstPageToDisplayL(TInt& aNewFirstPageToDisplay);
       
   217 	void DrawButtons() const;
       
   218 	void SetZoomLevelAndDispalyRect(TInt aZoomLevel);
       
   219 	void CreatePreviewImageL();
       
   220 
       
   221 private:
       
   222 	/** Pointer to button controls. */
       
   223 //	CEikScrollButton* iButton[2];
       
   224 	/** Pointer to image. */
       
   225 	CPrintPreviewImage* iPreview;
       
   226 	/** Pointer to setup information. */
       
   227 	CPrintSetup* iPrintSetup;
       
   228 	/** Pointer to body printer. */
       
   229 	MPageRegionPrinter* iBodyPrinter;
       
   230 	/** Pointer to format information. */
       
   231 	TPrintPreviewFormat* iPrintPreviewFormat;
       
   232 	/** Pointer to page number. */
       
   233 	TInt* iFirstPageToDisplay;
       
   234 	/** Number of all pages. */
       
   235 	TInt iNumPagesInDoc;
       
   236 	/** Number of pages to view. */
       
   237 	TInt iNumPagesToView;
       
   238 	/** Number of bands. */
       
   239 	TInt iNumBands;
       
   240 	/** Margin information. */
       
   241 	CPrintPreviewImage::TMarginState iMarginState;
       
   242 	/** Display rect. */
       
   243 	TRect iDisplayRect;
       
   244 	/** Draw flag. */
       
   245 	TBool iPreviewDraw;
       
   246 	/** Display point. */
       
   247 	TPoint iDisplayPoint;
       
   248 	/** Position of pointer. */
       
   249 	TPoint iPointerDownPos;
       
   250 	/** Zoom level. */
       
   251 	TInt  iZoomLevel;			// set TPreviewZoomLevel
       
   252 	};
       
   253 
       
   254 #endif // __DIRECTPRINTPREVIEWCONTROL_H__