|
1 /* |
|
2 * Copyright (c) 2003-2004 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 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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: gdi interface |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _GDIDEVICECONTEXT_H |
|
20 #define _GDIDEVICECONTEXT_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <AknUtils.h> |
|
24 #include "nw_object_dynamic.h" |
|
25 #include "GDIFont.h" |
|
26 #include "BrsrTypes.h" |
|
27 #include "BrsrStatusCodes.h" |
|
28 |
|
29 // CONSTANTS |
|
30 enum TGDIDeviceContextFontSizeLevel |
|
31 { |
|
32 EGDIDeviceContextFontSizeLevelAllSmall, |
|
33 EGDIDeviceContextFontSizeLevelSmaller, |
|
34 EGDIDeviceContextFontSizeLevelNormal, |
|
35 EGDIDeviceContextFontSizeLevelLarger, |
|
36 EGDIDeviceContextFontSizeLevelAllLarge |
|
37 }; |
|
38 |
|
39 // fonts to be created : italic12, bold-italic12, plain13, italic13, |
|
40 // bold-italic13, plain17, italic17, bold-italic17 |
|
41 const TInt8 KNumberOfFonts = 8; |
|
42 |
|
43 // Browser specific font types |
|
44 // |
|
45 enum TGDIDeviceContextFontNames |
|
46 { |
|
47 ELatinItalic12, |
|
48 ELatinBoldItalic12, |
|
49 ELatinPlain13, |
|
50 ELatinItalic13, |
|
51 ELatinBoldItalic13, |
|
52 ELatinPlain17, |
|
53 ELatinItalic17, |
|
54 ELatinBoldItalic17 |
|
55 }; |
|
56 |
|
57 enum TGDISupportedLanguage |
|
58 { |
|
59 EElafLanguage, |
|
60 EThaiLanguage, |
|
61 EJapaneseLanguage, |
|
62 EChinesePRCLanguage, |
|
63 EChinaHKTWLanguage |
|
64 }; |
|
65 |
|
66 // MACROS |
|
67 |
|
68 // DATA TYPES |
|
69 |
|
70 // FUNCTION PROTOTYPES |
|
71 |
|
72 // FORWARD DECLARATIONS |
|
73 |
|
74 // CLASS DECLARATION |
|
75 |
|
76 /** |
|
77 * CGDIDeviceContext |
|
78 * |
|
79 * @lib BrowserEngine.dll |
|
80 * @since 2.1 |
|
81 */ |
|
82 class CGDIDeviceContext : public CBase |
|
83 { |
|
84 public: // Constructors and destructor |
|
85 |
|
86 /** |
|
87 * Two-phased constructor. |
|
88 * @return CGDIDeviceContext* |
|
89 */ |
|
90 static CGDIDeviceContext* NewL( void* aGraphicsContext, CView* aOocEpoc32View ); |
|
91 |
|
92 /** |
|
93 * Destructor. |
|
94 */ |
|
95 virtual ~CGDIDeviceContext(); |
|
96 |
|
97 public: // New functions |
|
98 |
|
99 /** |
|
100 * This method |
|
101 * @since 2.1 |
|
102 * @param |
|
103 * @return |
|
104 */ |
|
105 void DrawImage( const NW_GDI_Point2D_t* aLocation, |
|
106 const NW_GDI_Rectangle_t* aRectangle, |
|
107 NW_GDI_ImageBlock_t* aImageBlock ); |
|
108 |
|
109 /** |
|
110 * This method |
|
111 * @since 2.1 |
|
112 * @param |
|
113 * @return |
|
114 */ |
|
115 TBrowserStatusCode ScaleImage( const NW_GDI_Dimension3D_t* aSize, |
|
116 const NW_GDI_ImageBlock_t* aImageBlock, |
|
117 NW_GDI_ImageBlock_t* aScaledImageBlock ); |
|
118 |
|
119 /** |
|
120 * This method |
|
121 * @since 2.1 |
|
122 * @param |
|
123 * @return |
|
124 */ |
|
125 void DrawPixel( const NW_GDI_Point2D_t* aLocation ); |
|
126 |
|
127 /** |
|
128 * This method |
|
129 * @since 2.1 |
|
130 * @param |
|
131 * @return |
|
132 */ |
|
133 TBrowserStatusCode DrawPolyline( NW_GDI_Metric_t aNumPoints, |
|
134 const NW_GDI_Point2D_t* aPoints, |
|
135 TBool aClosed ); |
|
136 |
|
137 /** |
|
138 * This method |
|
139 * @since 2.1 |
|
140 * @param |
|
141 * @return |
|
142 */ |
|
143 void DrawRectangle( const NW_GDI_Rectangle_t* aRectangle ); |
|
144 |
|
145 /** |
|
146 * This method |
|
147 * @since 2.1 |
|
148 * @param |
|
149 * @return |
|
150 */ |
|
151 |
|
152 TBrowserStatusCode DrawText( const NW_GDI_Point2D_t* aLocation, |
|
153 const NW_Text_t* aText, |
|
154 CGDIFont* aGDIFont, |
|
155 NW_GDI_Metric_t aSpacing, |
|
156 NW_GDI_TextDecoration_t aDecoration, |
|
157 NW_GDI_FlowDirection_t aDir, |
|
158 NW_GDI_Metric_t aWidth ); |
|
159 |
|
160 /** |
|
161 * This method |
|
162 * @since 2.1 |
|
163 * @param |
|
164 * @return |
|
165 */ |
|
166 void FillRectangle( const NW_GDI_Rectangle_t* aRectangle ); |
|
167 |
|
168 /** |
|
169 * This method |
|
170 * @since 2.1 |
|
171 * @param |
|
172 * @return |
|
173 */ |
|
174 TBrowserStatusCode GetColorPalette( NW_GDI_ColorPalette_t* aColPalette ); |
|
175 |
|
176 /** |
|
177 * This method |
|
178 * @since 2.1 |
|
179 * @param |
|
180 * @return |
|
181 */ |
|
182 NW_GDI_Color_t BackgroundColor () const; |
|
183 |
|
184 /** |
|
185 * This method |
|
186 * @since 2.1 |
|
187 * @param |
|
188 * @return |
|
189 */ |
|
190 NW_GDI_Rectangle_t ClipRect () const; |
|
191 |
|
192 /** |
|
193 * This method |
|
194 * @since 2.1 |
|
195 * @param |
|
196 * @return |
|
197 */ |
|
198 const NW_GDI_Rectangle_t* DisplayBounds () const; |
|
199 |
|
200 /** |
|
201 * This method |
|
202 * @since 2.1 |
|
203 * @param |
|
204 * @return |
|
205 */ |
|
206 TUint8 DisplayDepth() const; |
|
207 |
|
208 /** |
|
209 * This method |
|
210 * @since 2.1 |
|
211 * @param |
|
212 * @return |
|
213 */ |
|
214 NW_GDI_Pattern_t FillPattern() const; |
|
215 |
|
216 |
|
217 /** |
|
218 * This method |
|
219 * @since 2.1 |
|
220 * @param |
|
221 * @return |
|
222 */ |
|
223 TBrowserStatusCode GetFlowDirection( NW_Text_t* aText, |
|
224 NW_GDI_FlowDirection_t* aFlowDirection) const; |
|
225 |
|
226 /** |
|
227 * This method |
|
228 * @since 2.1 |
|
229 * @param |
|
230 * @return |
|
231 */ |
|
232 NW_GDI_Color_t ForegroundColor() const; |
|
233 |
|
234 /** |
|
235 * This method |
|
236 * @since 2.1 |
|
237 * @param |
|
238 * @return |
|
239 */ |
|
240 NW_GDI_Pattern_t LinePattern() const; |
|
241 |
|
242 /** |
|
243 * This method |
|
244 * @since 2.1 |
|
245 * @param |
|
246 * @return |
|
247 */ |
|
248 NW_GDI_Metric_t LineWidth() const; |
|
249 |
|
250 /** |
|
251 * This method |
|
252 * @since 2.1 |
|
253 * @param |
|
254 * @return |
|
255 */ |
|
256 const NW_GDI_Point2D_t* Origin() const; |
|
257 |
|
258 /** |
|
259 * This method |
|
260 * @since 2.1 |
|
261 * @param |
|
262 * @return |
|
263 */ |
|
264 NW_GDI_PaintMode_t PaintMode() const; |
|
265 |
|
266 /** |
|
267 * This method |
|
268 * @since 2.1 |
|
269 * @param |
|
270 * @return |
|
271 */ |
|
272 void* GetScaledCFont( CGDIFont* aFont ) const; |
|
273 |
|
274 /** |
|
275 * This method |
|
276 * @since 2.1 |
|
277 * @param |
|
278 * @return |
|
279 */ |
|
280 NW_GDI_TextDirection_t TextDirection() const; |
|
281 |
|
282 /** |
|
283 * This method |
|
284 * @since 2.1 |
|
285 * @param |
|
286 * @return |
|
287 */ |
|
288 TBrowserStatusCode GetTextExtent( const NW_Text_t* aText, |
|
289 CGDIFont* aGDIFont, |
|
290 NW_GDI_Metric_t aSpacing, |
|
291 NW_GDI_FlowDirection_t aFlowDirection, |
|
292 NW_GDI_Dimension2D_t* aExtent) const; |
|
293 |
|
294 /** |
|
295 * This method |
|
296 * @since 2.1 |
|
297 * @param |
|
298 * @return |
|
299 */ |
|
300 void PreDraw(); |
|
301 |
|
302 /** |
|
303 * This method |
|
304 * @since 2.1 |
|
305 * @param |
|
306 * @return |
|
307 */ |
|
308 void PostDraw( TBool aDrawNow ); |
|
309 |
|
310 /** |
|
311 * This method |
|
312 * @since 2.1 |
|
313 * @param |
|
314 * @return |
|
315 */ |
|
316 void SetBackgroundColor( NW_GDI_Color_t aColor ); |
|
317 |
|
318 /** |
|
319 * This method |
|
320 * @since 2.1 |
|
321 * @param |
|
322 * @return |
|
323 */ |
|
324 void SetClipRect( const NW_GDI_Rectangle_t* aClipRect ); |
|
325 |
|
326 /** |
|
327 * This method |
|
328 * @since 2.1 |
|
329 * @param |
|
330 * @return |
|
331 */ |
|
332 void SetFillPattern( NW_GDI_Pattern_t aFillPattern ); |
|
333 |
|
334 /** |
|
335 * This method |
|
336 * @since 2.1 |
|
337 * @param |
|
338 * @return |
|
339 */ |
|
340 void SetForegroundColor( NW_GDI_Color_t aColor ); |
|
341 |
|
342 /** |
|
343 * This method |
|
344 * @since 2.1 |
|
345 * @param |
|
346 * @return |
|
347 */ |
|
348 void SetLinePattern( NW_GDI_Pattern_t aLinePattern ); |
|
349 |
|
350 /** |
|
351 * This method |
|
352 * @since 2.1 |
|
353 * @param |
|
354 * @return |
|
355 */ |
|
356 void SetLineWidth( NW_GDI_Metric_t aLineWidth ); |
|
357 |
|
358 /** |
|
359 * This method |
|
360 * @since 2.1 |
|
361 * @param |
|
362 * @return |
|
363 */ |
|
364 void SetOrigin( const NW_GDI_Point2D_t* aOrigin ); |
|
365 |
|
366 /** |
|
367 * This method |
|
368 * @since 2.1 |
|
369 * @param |
|
370 * @return |
|
371 */ |
|
372 void SetPaintMode( NW_GDI_PaintMode_t aPaintMode ); |
|
373 |
|
374 /** |
|
375 * This method |
|
376 * @since 2.1 |
|
377 * @param |
|
378 * @return |
|
379 */ |
|
380 void SetTextDirection( NW_GDI_TextDirection_t aTextDirection ); |
|
381 |
|
382 /** |
|
383 * This method |
|
384 * @since 2.1 |
|
385 * @param |
|
386 * @return |
|
387 */ |
|
388 void SetDisplayBounds( const NW_GDI_Rectangle_t* aDisplaybounds ); |
|
389 |
|
390 /** |
|
391 * This method |
|
392 * @since 2.1 |
|
393 * @param |
|
394 * @return |
|
395 */ |
|
396 CGDIFont* CreateFont( const NW_Text_t* aFamily, |
|
397 TGDIFontStyle aStyle, |
|
398 TUint8 aSizeInPixels, |
|
399 TUint16 aWeight, |
|
400 TGDIFontVariant aVariant) const; |
|
401 |
|
402 /** |
|
403 * This method |
|
404 * @since 2.1 |
|
405 * @param |
|
406 * @return |
|
407 */ |
|
408 void DrawLine( NW_GDI_Point2D_t aStartPoint, NW_GDI_Point2D_t aEndPoint ); |
|
409 |
|
410 /** |
|
411 * This method |
|
412 * @since 2.1 |
|
413 * @param |
|
414 * @return |
|
415 */ |
|
416 TBool SetFontSizeLevel(); |
|
417 |
|
418 /** |
|
419 * This method |
|
420 * @since 2.1 |
|
421 * @param |
|
422 * @return |
|
423 */ |
|
424 void ChangeFontSize( CGDIFont* aFont ); |
|
425 |
|
426 /** |
|
427 * This method |
|
428 * @since 2.1 |
|
429 * @param |
|
430 * @return |
|
431 */ |
|
432 void GetHighlightColor( NW_GDI_Color_t* aColor ); |
|
433 |
|
434 /** |
|
435 * This method |
|
436 * @since 2.1 |
|
437 * @param |
|
438 * @return |
|
439 */ |
|
440 void SwitchAgainstBG( NW_GDI_Color_t* aColor ); |
|
441 |
|
442 /** |
|
443 * This method |
|
444 * @since 2.1 |
|
445 * @param |
|
446 * @return |
|
447 */ |
|
448 TBrowserStatusCode SplitText( NW_Text_t* aText, |
|
449 CGDIFont* aGDIFont, |
|
450 NW_GDI_Metric_t aConstraint, |
|
451 NW_GDI_Metric_t aSpacing, |
|
452 NW_GDI_FlowDirection_t aFlowDirection, |
|
453 NW_Text_Length_t* aLength, |
|
454 TUint8 aMode ); |
|
455 |
|
456 /** |
|
457 * This method |
|
458 * @since 2.1 |
|
459 * @param |
|
460 * @return |
|
461 */ |
|
462 TBrowserStatusCode GetSubstringExtent( const NW_Text_t* aText, |
|
463 CGDIFont* aGDIFont, |
|
464 NW_Text_Length_t aStart, |
|
465 NW_Text_Length_t aLength, |
|
466 NW_GDI_Metric_t aSpacing, |
|
467 NW_GDI_FlowDirection_t aFlowDirection, |
|
468 NW_GDI_Dimension2D_t* aExtent ); |
|
469 |
|
470 /** |
|
471 * This method |
|
472 * @since 2.1 |
|
473 * @param TFontSpec which specifies the font family and the height of the font |
|
474 * the caller of this method wishes to find. |
|
475 * @return pointer to a CFont object which will have been found in the iFontCache |
|
476 * or have been created if the font was not already in the cache |
|
477 */ |
|
478 CFont* FindFont( TFontSpec aFontSpec ); |
|
479 |
|
480 /** |
|
481 * This method |
|
482 * @since 2.1 |
|
483 * @param |
|
484 * @return |
|
485 */ |
|
486 void SetRemoveNbsp( TBool aFlag ); |
|
487 |
|
488 /** |
|
489 * This method |
|
490 * @since 2.1 |
|
491 * @param |
|
492 * @return |
|
493 */ |
|
494 TBool RemoveNbsp(); |
|
495 |
|
496 /** |
|
497 * This method |
|
498 * @since 2.1 |
|
499 * @param |
|
500 * @return |
|
501 */ |
|
502 void SetGraphicsContext( void* aGraphicsContext ); |
|
503 |
|
504 /** |
|
505 * This method |
|
506 * @since 2.1 |
|
507 * @param |
|
508 * @return |
|
509 */ |
|
510 void SetFontSizeLevel( TGDIDeviceContextFontSizeLevel aFontSizeLevel ); |
|
511 |
|
512 /** |
|
513 * This method |
|
514 * @since 2.1 |
|
515 * @param |
|
516 * @return |
|
517 */ |
|
518 EVariantFlag VariantFlag(); |
|
519 |
|
520 /** |
|
521 * This method |
|
522 * @since 2.x |
|
523 * @param |
|
524 * @return |
|
525 */ |
|
526 inline CWsScreenDevice* WsScreenDevice() { return iWsScreenDev; }; |
|
527 |
|
528 /** |
|
529 * This method |
|
530 * @since 2.x |
|
531 * @param |
|
532 * @return |
|
533 */ |
|
534 TGDISupportedLanguage SupportedLanguage(); |
|
535 |
|
536 private: // New functions |
|
537 |
|
538 /** |
|
539 * C++ default constructor. |
|
540 */ |
|
541 CGDIDeviceContext(); |
|
542 |
|
543 /** |
|
544 * By default Symbian 2nd phase constructor is private. |
|
545 */ |
|
546 TBrowserStatusCode ConstructL( void* aGraphicsContext, CView* aOocEpoc32View ); |
|
547 |
|
548 /** |
|
549 * This method |
|
550 * @since 2.1 |
|
551 * @param |
|
552 * @return |
|
553 */ |
|
554 NW_GDI_Color_t SwapColorBytes( NW_GDI_Color_t aColor ); |
|
555 |
|
556 /** |
|
557 * This method |
|
558 * @since 2.1 |
|
559 * @param |
|
560 * @return |
|
561 */ |
|
562 CBitmapContext* Epoc32GraphicsContext(); |
|
563 |
|
564 /** |
|
565 * This method |
|
566 * @since 2.1 |
|
567 * @param |
|
568 * @return |
|
569 */ |
|
570 TBrowserStatusCode WordWrap ( NW_Text_t* aText, |
|
571 CGDIFont* aGDIFont, |
|
572 NW_GDI_Metric_t aConstraint, |
|
573 NW_GDI_Metric_t aSpacing, |
|
574 NW_GDI_FlowDirection_t aFlowDirection, |
|
575 NW_Text_Length_t* aLength ); |
|
576 |
|
577 /** |
|
578 * This method |
|
579 * @since 2.1 |
|
580 * @param |
|
581 * @return |
|
582 */ |
|
583 TBrowserStatusCode SplitAtNewline ( NW_Text_t* aText, |
|
584 CGDIFont* aGDIFont, |
|
585 NW_GDI_Metric_t aCconstraint, |
|
586 NW_GDI_Metric_t aSpacing, |
|
587 NW_GDI_FlowDirection_t aFlowDirection, |
|
588 NW_Text_Length_t* aLength ); |
|
589 |
|
590 /** |
|
591 * This method |
|
592 * @since 2.1 |
|
593 * @param |
|
594 * @return |
|
595 */ |
|
596 TBrowserStatusCode Truncate ( NW_Text_t* aText, |
|
597 CGDIFont* aGDIFont, |
|
598 NW_GDI_Metric_t aConstraint, |
|
599 NW_GDI_Metric_t aSpacing, |
|
600 NW_GDI_FlowDirection_t aFlowDirection, |
|
601 NW_Text_Length_t* aLength ); |
|
602 |
|
603 /** |
|
604 * This method |
|
605 * @since 2.1 |
|
606 * @param |
|
607 * @return |
|
608 */ |
|
609 TBrowserStatusCode ScaleBitmap( CFbsBitmap* aBitmap, |
|
610 CFbsBitmap** aScaledBitmap, |
|
611 TRect* aRect ); |
|
612 |
|
613 /** |
|
614 * This method |
|
615 * @since 2.1 |
|
616 * @param |
|
617 * @return |
|
618 */ |
|
619 void InitializeGraphicsContext(); |
|
620 |
|
621 /** |
|
622 * Checks whether or not a line split (word wrap) can occur between the two |
|
623 * characters specified. |
|
624 * @since 2.6 |
|
625 * @param aChar1 First character. |
|
626 * @param aChar2 Second character. |
|
627 * @return ETrue if split can occur between the two characters; else, EFalse. |
|
628 */ |
|
629 TBool CanSplit(TText16 aChar1, TText16 aChar2); |
|
630 |
|
631 /** |
|
632 * Checks whether or not the two consecutive characters are within a single |
|
633 * Thai script "cell". |
|
634 * @since 2.6 |
|
635 * @param aChar1 First character. |
|
636 * @param aChar2 Second character. |
|
637 * @return ETrue if is in a single Thai script "cell"; else, EFalse. |
|
638 */ |
|
639 TBool |
|
640 IsThaiCell( TText16 aChar1, TText16 aChar2 ); |
|
641 |
|
642 |
|
643 private: // Data |
|
644 |
|
645 // |
|
646 EVariantFlag iVariantFlag; |
|
647 // |
|
648 CFontCache* iFontCache; |
|
649 // |
|
650 CWsScreenDevice* iWsScreenDev; |
|
651 // used for removing nbsp in vertical-layout mode |
|
652 TBool iRemoveNbsp; |
|
653 // is a CBitmapContext* |
|
654 void* iGraphicsContext; |
|
655 // |
|
656 NW_GDI_Point2D_t iOrigin; |
|
657 // |
|
658 TGDIDeviceContextFontSizeLevel iFontSizeLevel; |
|
659 // |
|
660 NW_GDI_Pattern_t iFillPattern; |
|
661 // |
|
662 NW_GDI_Pattern_t iLinePattern; |
|
663 // |
|
664 NW_GDI_Metric_t iLineWidth; |
|
665 // |
|
666 NW_GDI_PaintMode_t iPaintMode; |
|
667 // |
|
668 NW_GDI_TextDirection_t iTextDirection; |
|
669 // |
|
670 NW_GDI_Color_t iForegroundColor; |
|
671 // |
|
672 NW_GDI_Color_t iBackgroundColor; |
|
673 // |
|
674 NW_GDI_Rectangle_t iDisplayBounds; |
|
675 // |
|
676 NW_GDI_Rectangle_t iClipRect; |
|
677 // |
|
678 CView* iOocEpoc32View; |
|
679 // |
|
680 NW_Int32 iResourceFileOffset; |
|
681 // |
|
682 TGDISupportedLanguage iSupportedLanguage; |
|
683 }; |
|
684 |
|
685 #endif // _GDIDEVICECONTEXT_H |