diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_scroll_8cpp-source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_scroll_8cpp-source.html Tue Mar 30 11:56:28 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,301 +0,0 @@ - - -TB10.1 Example Applications: examples/Graphics/WS/Scroll/Scroll.cpp Source File - - - - -

examples/Graphics/WS/Scroll/Scroll.cpp

00001 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
-00002 // All rights reserved.
-00003 // This component and the accompanying materials are made available
-00004 // under the terms of "Eclipse Public License v1.0"
-00005 // which accompanies this distribution, and is available
-00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
-00007 //
-00008 // Initial Contributors:
-00009 // Nokia Corporation - initial contribution.
-00010 //
-00011 // Contributors:
-00012 //
-00013 // Description:
-00014 // WSSCROL1.CPP
-00015 //
-00016 
-00017 #include <w32std.h>
-00018 #include "Base.h"
-00019 #include "Scroll.h"
-00020 
-00021 _LIT(KString1,"1");
-00022 _LIT(KString2,"2");
-00023 _LIT(KString3,"3");
-00024 _LIT(KString4,"4");
-00025 _LIT(KString5,"5");
-00026 
-00028 //                                       CNumberedWindow implementation
-00030 
-00031 /****************************************************************************\
-00032 |       Function:       Constructor/Destructor for CNumberedWindow
-00033 |       Input:          aClient         Client application that owns the window
-00034 \****************************************************************************/
-00035 CNumberedWindow::CNumberedWindow (CWsClient* aClient, TInt aNum)
-00036 : CWindow (aClient), iNumber(aNum), iOldPos(0,0), iOffset(0,0), iRepeatRect(0,0,0,0)
-00037         {
-00038         }
-00039 
-00040 
-00041 CNumberedWindow::~CNumberedWindow ()
-00042         {
-00043         }
-00044 
-00045 
-00046 /****************************************************************************\
-00047 |       Function:       CNumberedWindow::Draw
-00048 |       Purpose:        Redraws the contents of CNumberedWindow within a given
-00049 |                               rectangle.  CNumberedWindow displays a number in the window.
-00050 |       Input:          aRect   Rectangle that needs redrawing
-00051 |       Output:         None
-00052 \****************************************************************************/
-00053 void CNumberedWindow::Draw(const TRect& aRect)
-00054         {
-00055         const TBufC<1> strings[5] = { *&KString1,
-00056                                                           *&KString2,
-00057                                                           *&KString3,
-00058                                                           *&KString4,
-00059                                                   *&KString5
-00060                                                         };
-00061 
-00062         CWindowGc* gc=SystemGc(); // get a graphics context
-00063         gc->SetClippingRect(aRect); // clip outside the redraw area
-00064         gc->Clear(aRect); // clear the redraw area
-00065         TSize size=iWindow.Size();
-00066         TInt height=size.iHeight; // Need window height to calculate vertical text offset
-00067         TInt ascent = Font()->AscentInPixels();
-00068         TInt descent = Font()->DescentInPixels();
-00069         TInt offset = (height + (ascent + descent)) / 2; // Calculate vertical text offset
-00070         gc->SetPenColor(TRgb(0,0,0)); // Set pen to black
-00071         gc->UseFont(Font());
-00072         gc->DrawText(strings[iNumber], TRect(TPoint(0,0) + iOffset, size), offset,
-00073                                                                                                         CGraphicsContext::ECenter);
-00074         gc->DrawLine(TPoint(0,0) + iOffset, TPoint(size.iWidth, height) + iOffset);
-00075         gc->DiscardFont();
-00076         }
-00077 
-00078 /****************************************************************************\
-00079 |       Function:       CNumberedWindow::HandlePointerEvent
-00080 |       Purpose:        Handles pointer events for CNumberedWindow.
-00081 |       Input:          aPointerEvent   The pointer event
-00082 |       Output:         None
-00083 \****************************************************************************/
-00084 void CNumberedWindow::HandlePointerEvent (TPointerEvent& aPointerEvent)
-00085         {       
-00086         switch (aPointerEvent.iType)
-00087                 {
-00088                 case TPointerEvent::EButton1Down:
-00089                         {
-00090                         Window().Scroll(TPoint(0,-2));
-00091                         iOffset += TPoint(0,-2);
-00092                         iRepeatRect.iTl = aPointerEvent.iPosition - TPoint(10,10);
-00093                         iRepeatRect.iBr = aPointerEvent.iPosition + TPoint(10,10);
-00094                         iScrollDir = Up;
-00095                         Window().RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32 (20000), iRepeatRect);
-00096                         break;
-00097                         }
-00098                 case TPointerEvent::EButtonRepeat:
-00099                         {
-00100                         if (iScrollDir == Up)
-00101                                 {
-00102                                 Window().Scroll(TPoint(0,-2));
-00103                                 iOffset += TPoint(0,-2);
-00104                                 }
-00105                         else
-00106                                 {
-00107                                 Window().Scroll(TPoint(0,2));
-00108                                 iOffset += TPoint(0,2);
-00109                                 }
-00110                         Window().RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32 (20000), iRepeatRect);
-00111                         break;
-00112                         }
-00113                 case TPointerEvent::EButton3Down:
-00114                         {
-00115                         Window().Scroll(TPoint(0,2));
-00116                         iOffset += TPoint(0,2);
-00117                         iRepeatRect.iTl = aPointerEvent.iPosition - TPoint(10,10);
-00118                         iRepeatRect.iBr = aPointerEvent.iPosition + TPoint(10,10);
-00119                         iScrollDir = Down;
-00120                         Window().RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32 (100000), iRepeatRect);
-00121                         break;
-00122                         }
-00123                 default:
-00124                         break;
-00125                 }
-00126         }
-00127 
-00128 
-00130 //                                       CMainWindow implementation
-00132 
-00133 
-00134 /****************************************************************************\
-00135 |       Function:       Constructor/Destructor for CMainWindow
-00136 |       Input:          aClient         Client application that owns the window
-00137 \****************************************************************************/
-00138 CMainWindow::CMainWindow (CWsClient* aClient)
-00139 : CWindow (aClient)
-00140         {
-00141         }
-00142 
-00143 CMainWindow::~CMainWindow ()
-00144         {
-00145         iWindow.Close();
-00146         }
-00147 
-00148 /****************************************************************************\
-00149 |       Function:       CMainWindow::Draw
-00150 |       Purpose:        Redraws the contents of CMainWindow within a given
-00151 |                               rectangle.
-00152 |       Input:          aRect   Rectangle that needs redrawing
-00153 |       Output:         None
-00154 \****************************************************************************/
-00155 
-00156 void CMainWindow::Draw(const TRect& aRect)
-00157         {
-00158         CWindowGc* gc=SystemGc(); // get a gc
-00159         gc->SetClippingRect(aRect); // clip outside this rect
-00160         gc->Clear(aRect); // clear
-00161         }
-00162 
-00163 /****************************************************************************\
-00164 |       Function:       CMainWindow::HandlePointerEvent
-00165 |       Purpose:        Handles pointer events for CMainWindow.
-00166 |       Input:          aPointerEvent   The pointer event!
-00167 |       Output:         None
-00168 \****************************************************************************/
-00169 
-00170 void CMainWindow::HandlePointerEvent (TPointerEvent& aPointerEvent)
-00171         {       
-00172         switch (aPointerEvent.iType)
-00173                 {
-00174                 case TPointerEvent::EButton1Down:
-00175                 case TPointerEvent::EButton1Up:
-00176                         break;
-00177                 default:
-00178                         break;
-00179                 }
-00180         }
-00181 
-00182 
-00184 //                                       CExampleWsClient implementation
-00186 
-00187 CExampleWsClient* CExampleWsClient::NewL(const TRect& aRect)
-00188         {
-00189         // make new client
-00190         CExampleWsClient* client=new (ELeave) CExampleWsClient(aRect); 
-00191         CleanupStack::PushL(client); // push, just in case
-00192         client->ConstructL(); // construct and run
-00193         CleanupStack::Pop();
-00194         return client;
-00195         }
-00196 
-00197 /****************************************************************************\
-00198 |       Function:       Constructor/Destructor for CExampleWsClient
-00199 |                               Destructor deletes everything that was allocated by
-00200 |                               ConstructMainWindowL()
-00201 \****************************************************************************/
-00202 
-00203 CExampleWsClient::CExampleWsClient(const TRect& aRect)
-00204 :iRect(aRect)
-00205         {
-00206         }
-00207 
-00208 CExampleWsClient::~CExampleWsClient ()
-00209         {
-00210         delete iMainWindow;
-00211         delete iWindow1;
-00212         }
-00213 
-00214 
-00215 /****************************************************************************\
-00216 |       Function:       CExampleWsClient::ConstructMainWindowL()
-00217 |                               Called by base class's ConstructL
-00218 |       Purpose:        Allocates and creates all the windows owned by this client
-00219 |                               (See list of windows in CExampleWsCLient declaration).
-00220 \****************************************************************************/
-00221 
-00222 void CExampleWsClient::ConstructMainWindowL()
-00223         {
-00224         iMainWindow=new (ELeave) CMainWindow(this);
-00225         iMainWindow->ConstructL(iRect, TRgb (255,255,255));
-00226         iWindow1  = new (ELeave) CNumberedWindow (this,1);
-00227         TRect rec(iRect);
-00228         rec.Resize(-50,-50);
-00229         iWindow1->ConstructL (rec, TRgb (200, 200, 200),iMainWindow);
-00230         }
-00231 
-00232 
-00233 /****************************************************************************\
-00234 |       Function:       CExampleWsClient::RunL()
-00235 |                               Called by active scheduler when an even occurs
-00236 |       Purpose:        Processes events according to their type
-00237 |                               For key events: calls HandleKeyEventL() (global to client)
-00238 |                               For pointer event: calls HandlePointerEvent() for window
-00239 |                                  event occurred in.
-00240 \****************************************************************************/
-00241 void CExampleWsClient::RunL()
-00242         {
-00243         // get the event
-00244         iWs.GetEvent(iWsEvent);
-00245         TInt eventType=iWsEvent.Type();
-00246         // take action on it
-00247         switch (eventType)
-00248                 {
-00249         // events global within window group
-00250         case EEventNull:
-00251                 break;
-00252         case EEventKey:
-00253                 {
-00254                 TKeyEvent& keyEvent=*iWsEvent.Key(); // get key event
-00255                 HandleKeyEventL (keyEvent);
-00256                 break;
-00257                 }
-00258         case EEventModifiersChanged:
-00259                 break;
-00260         case EEventKeyUp:
-00261         case EEventKeyDown:
-00262         case EEventFocusLost:
-00263         case EEventFocusGained:
-00264         case EEventSwitchOn:
-00265         case EEventPassword:
-00266         case EEventWindowGroupsChanged:
-00267         case EEventErrorMessage:
-00268                 break;
-00269         // events local to specific windows
-00270         case EEventPointer:
-00271                 {
-00272                 CWindow* window=(CWindow*)(iWsEvent.Handle()); // get window
-00273                 TPointerEvent& pointerEvent=*iWsEvent.Pointer();
-00274                 window->HandlePointerEvent (pointerEvent);
-00275                 break;
-00276                 }
-00277         case EEventPointerExit:
-00278         case EEventPointerEnter:
-00279         case EEventPointerBufferReady:
-00280         case EEventDragDrop:
-00281                 break;
-00282         default:
-00283                 break;
-00284                 }
-00285         IssueRequest(); // maintain outstanding request
-00286         }
-00287 
-00288 /****************************************************************************\
-00289 |       Function:       CExampleWsClient::HandleKeyEventL()
-00290 |       Purpose:        Processes key events for CExampleWsClient
-00291 \****************************************************************************/
-00292 void CExampleWsClient::HandleKeyEventL (TKeyEvent& /*aKeyEvent*/)
-00293         {
-00294         }
-00295 
-

Generated on Thu Jan 21 10:32:58 2010 for TB10.1 Example Applications by  - -doxygen 1.5.3
- -