|
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Shells for window server bitmap class |
|
15 // Note: Note: A pointer to CWsBitmap must have the same pointer value as a pointer |
|
16 // to the associated CFbsBitmap, otherwise code in BitGdi component will be |
|
17 // Broken. |
|
18 // |
|
19 // |
|
20 |
|
21 #include <e32std.h> |
|
22 #include "../SERVER/w32cmd.h" |
|
23 #include "CLIENT.H" |
|
24 |
|
25 |
|
26 EXPORT_C CWsBitmap::CWsBitmap() |
|
27 /** Default constructor. Developers should use the other constructor overload. */ |
|
28 { |
|
29 } |
|
30 |
|
31 EXPORT_C CWsBitmap::CWsBitmap(RWsSession &aWs) : MWsClientClass(aWs.iBuffer) |
|
32 /** Constructor which takes a window server session as an argument. |
|
33 |
|
34 @param aWs Handle to window server session. */ |
|
35 { |
|
36 } |
|
37 |
|
38 EXPORT_C CWsBitmap::~CWsBitmap() |
|
39 /** Destructor. */ |
|
40 { |
|
41 Reset(); |
|
42 } |
|
43 |
|
44 EXPORT_C void CWsBitmap::Reset() |
|
45 /** Releases the bitmap's handle from the font and bitmap server. |
|
46 |
|
47 The function also decrements the bitmap's access count in the font and bitmap |
|
48 server. The server-side bitmap is deleted only if the access count for the |
|
49 bitmap decrements to zero. */ |
|
50 { |
|
51 if (iBuffer && iWsHandle) |
|
52 Write(EWsBitmapOpFree); |
|
53 iWsHandle=NULL; |
|
54 CFbsBitmap::Reset(); |
|
55 } |
|
56 |
|
57 TInt CWsBitmap::createWsBitmap(TInt aErr) |
|
58 { |
|
59 if (aErr==KErrNone) |
|
60 { |
|
61 TWsClCmdCreateBitmap createBitmap; |
|
62 createBitmap.handle=Handle(); |
|
63 TInt ret; |
|
64 if ((ret=iBuffer->WriteReplyWs(&createBitmap,sizeof(createBitmap),EWsClOpCreateBitmap))<0) |
|
65 { |
|
66 CFbsBitmap::Reset(); |
|
67 aErr=ret; |
|
68 } |
|
69 else |
|
70 iWsHandle=ret; |
|
71 } |
|
72 return(aErr); |
|
73 } |
|
74 |
|
75 EXPORT_C TInt CWsBitmap::Create(const TSize& aSizeInPixels,TDisplayMode aDispMode) |
|
76 /** Creates a bitmap, specifying the size and display mode. |
|
77 |
|
78 This function, if successful, always causes a flush of the window server buffer. |
|
79 |
|
80 @param aSizeInPixels The size of the bitmap to be created. |
|
81 @param aDispMode The display-mode of the bitmap to be created. |
|
82 @return KErrNone if successful, KErrCouldNotConnect if no connection to the |
|
83 font and bitmap server could be made, KErrArgument if aSizeInPixels is illegal. |
|
84 @see CFbsBitmap::Create() */ |
|
85 { |
|
86 Reset(); |
|
87 return(createWsBitmap(CFbsBitmap::Create(aSizeInPixels,aDispMode))); |
|
88 } |
|
89 |
|
90 EXPORT_C TInt CWsBitmap::Duplicate(TInt aHandle) |
|
91 /** Makes this bitmap a duplicate of the specified bitmap. |
|
92 |
|
93 This function, if successful, always causes a flush of the window server buffer. |
|
94 |
|
95 @param aHandle The handle of the bitmap to be duplicated. |
|
96 @return KErrNone if successful, KErrCouldNotConnect if no connection to the |
|
97 font and bitmap server could be made, or KErrUnknown if no bitmap could be |
|
98 found whose handle is aHandle. |
|
99 @see CFbsBitmap::Duplicate() */ |
|
100 { |
|
101 Reset(); |
|
102 return(createWsBitmap(CFbsBitmap::Duplicate(aHandle))); |
|
103 } |
|
104 |
|
105 EXPORT_C TInt CWsBitmap::Load(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded) |
|
106 /** Loads a bitmap from a file. |
|
107 |
|
108 If aShareIfLoaded is ETrue the bitmap will be allowed to be shared by a number |
|
109 of font and bitmap server clients. |
|
110 |
|
111 This function, if successful, always causes a flush of the window server buffer. |
|
112 |
|
113 @param aFileName The filename of the multibitmap (.mbm) file containing the |
|
114 bitmap to be loaded. |
|
115 @param aId The identifier of the bitmap in the .mbm file which should be loaded. |
|
116 @param aShareIfLoaded Specifies whether or not the loaded bitmap will be made |
|
117 available for sharing between font and bitmap server clients. |
|
118 @return KErrNone if successful, otherwise KErrCouldNotConnect, KErrEof, or |
|
119 an error specific to the font and bitmap server. |
|
120 @see CFbsBitmap::Load() */ |
|
121 { |
|
122 Reset(); |
|
123 return(createWsBitmap(CFbsBitmap::Load(aFileName,aId,aShareIfLoaded))); |
|
124 } |
|
125 |
|
126 EXPORT_C void CWsBitmap::InternalizeL(RReadStream& aStream) |
|
127 /** Internalises a CWsBitmap from the read stream. |
|
128 |
|
129 The presence of this function means that the standard templated operator>>() |
|
130 can be used to internalise objects of this class. |
|
131 |
|
132 This function always causes a flush of the window server buffer. |
|
133 |
|
134 @param aStream The stream from which to internalise the bitmap. */ |
|
135 { |
|
136 Reset(); |
|
137 CFbsBitmap::InternalizeL(aStream); |
|
138 User::LeaveIfError(createWsBitmap(KErrNone)); |
|
139 } |
|
140 |