uifw/uiklaf/src/laflbx.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 1997-1999 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 <w32std.h>
       
    20 #include <gulutil.h>
       
    21 #include <gulcolor.h>
       
    22 #include <coeinput.h>
       
    23 
       
    24 #include "LAFSTD.H"
       
    25 #include "lafpublc.h"
       
    26 #include "laflbx.h"
       
    27 #include "lafcommn.h"
       
    28 
       
    29 const TInt KLafListBoxBackgroundColor			=15;	// later, this will be a data member of the listbox  
       
    30 const TInt KLafListBoxItemVGap					=6;		// to allow a box to be drawn around each item
       
    31 const TInt KLafListBoxPointerRepeatInterval		=100;	// in micro seconds
       
    32 
       
    33 /*The decision on whether or not to use the following 6 laf values is not 
       
    34 made here.  Values >= 0 are appropriate (but obviously not too large, such as to
       
    35 cause overlapping margins in the listbox).*/
       
    36 const TInt KLafListBoxTopMargin					=0;
       
    37 const TInt KLafListBoxBottomMargin				=0;
       
    38 const TInt KLafListBoxLeftMargin				=0;
       
    39 const TInt KLafListBoxRightMargin				=0;
       
    40 const TInt KInnerGutter							=0;		// gutter at the left of textual list items, >= 0 is sensible, 0 turns it off
       
    41 const TInt KInterItemVGap						=6;
       
    42 
       
    43 /*Important display parameters (only) for popout listboxes*/
       
    44 const TInt KLafListBoxMaxHeightInNumOfItems		=KLafListBoxNoMaxCellWidth;				// >= 1 is sensible, KLafListBoxNoMaxCellWidth value turns it off
       
    45 const TInt KLafListBoxMaxCellWidthInNumOfPixels =KLafListBoxNoMaxHeightInNumOfItems;	// >= 20 is sensible, KLafListBoxNoMaxHeightInNumOfItems value turns it off
       
    46 
       
    47 EXPORT_C TBool LafListBox::FadeBehind()
       
    48 	{
       
    49 	return EFalse;
       
    50 	}
       
    51 
       
    52 /**
       
    53  * Gets the default border for the matched control in aBorder. Called from the constructor of the matched control.
       
    54  */
       
    55 EXPORT_C void LafListBox::GetDefaultBorder(TGulBorder& aBorder)
       
    56 	{
       
    57 	aBorder=TGulBorder(TGulBorder::ENone);
       
    58 	}
       
    59 
       
    60 /**
       
    61  * Gets the set of border colors for the matched control in aBorderColors. The RGB values of the colors obtained
       
    62  * may depend on the the display mode, the environment color list and the instance of the
       
    63  * matched control aMatchedControl. Called by the matched control from its Draw() method and passed on to the
       
    64  * Draw() method of TGulBorder. 
       
    65  */
       
    66 EXPORT_C void LafListBox::GetBorderColors(TGulBorder::TColors& aBorderColors, const MLafEnv& aLafEnv, const CCoeControl& aMatchedControl)
       
    67 	{
       
    68 	LafCommonUtils::GetRgbDerivedBorderColors( aBorderColors,
       
    69 			EColorControlSurroundBackground, aLafEnv,aMatchedControl );
       
    70 	}
       
    71 
       
    72 /**
       
    73  * Gets the default border for the matched control in aBorder. Called from the constructor of the matched control.
       
    74  */
       
    75 EXPORT_C void LafListBox::GetDefaultPopoutBorder(TGulBorder& aBorder)
       
    76 	{
       
    77 	aBorder=TGulBorder(TGulBorder::EThickDeepRaisedWithOutline);
       
    78 	}
       
    79 
       
    80 /**
       
    81  * Gets the set of border colors for the matched control in aBorderColors. The RGB values of the colors obtained
       
    82  * may depend on the the display mode, the environment color list and the instance of the
       
    83  * matched control aMatchedControl. Called by the matched control from its Draw() method and passed on to the
       
    84  * Draw() method of TGulBorder. 
       
    85  */
       
    86 EXPORT_C void LafListBox::GetPopoutBorderColors(TGulBorder::TColors& aBorderColors, const MLafEnv& aLafEnv, const CCoeControl& aMatchedControl)
       
    87 	{
       
    88 	LafCommonUtils::GetRgbDerivedBorderColors( aBorderColors,
       
    89 			EColorControlBackground, aLafEnv,aMatchedControl );
       
    90 	}
       
    91 
       
    92 
       
    93 EXPORT_C TMargins8 LafListBox::Margins()
       
    94  	{
       
    95  	TMargins8 margins;
       
    96  	margins.iLeft = KLafListBoxLeftMargin;
       
    97  	margins.iRight = KLafListBoxRightMargin;
       
    98  	margins.iTop = KLafListBoxTopMargin;
       
    99  	margins.iBottom = KLafListBoxBottomMargin;
       
   100  	return margins;
       
   101  	}
       
   102 
       
   103 
       
   104 EXPORT_C TInt LafListBox::Constant(TConstantType aType)
       
   105 	{ // static
       
   106 	switch (aType)
       
   107 		{
       
   108 	case EBackgroundColor:
       
   109 		return KLafListBoxBackgroundColor;
       
   110 	case EItemVGap:
       
   111 		return KLafListBoxItemVGap;
       
   112 	case EPointerRepeatInterval:
       
   113 		return KLafListBoxPointerRepeatInterval;
       
   114 	case EMaxHeightInNumOfItems:
       
   115 		return KLafListBoxMaxHeightInNumOfItems;
       
   116 	case EMaxCellWidthInNumOfPixels:
       
   117 		return KLafListBoxMaxCellWidthInNumOfPixels;
       
   118 	case EInnerGutter:
       
   119 		return KInnerGutter;
       
   120 	case EInterItemVGap:
       
   121 		return KInterItemVGap;
       
   122 	default:
       
   123 		__ASSERT_DEBUG(EFalse,Panic(ELafPanicConstantNotKnown));
       
   124 		}
       
   125 	return 0; // will never reach here	
       
   126 	}
       
   127 
       
   128 /**
       
   129  * Returns the default flags for the scroll bar for orientation aOrientation.
       
   130  * Called when the matched control creates its scroll bar frame..
       
   131  */
       
   132 EXPORT_C TInt LafListBox::DefaultScrollBarFlags(TInt /*aOrientation*/)
       
   133 	{
       
   134 	return 0;
       
   135 	}
       
   136 
       
   137 /**
       
   138  * Gets the default attributes for the scroll bar for orientation aOrientation in aAttributes.
       
   139  * Called when the matched control creates its scroll bar frame..
       
   140  */
       
   141 EXPORT_C void LafListBox::GetDefaultScrollBarAttributes(TInt /*aOrientation*/, LafScrollBarFrame::TScrollBarAttributes& aAttributes)
       
   142 	{
       
   143 	aAttributes = LafScrollBarFrame::TScrollBarAttributes();
       
   144 	}
       
   145 
       
   146 /**
       
   147  * Returns the key types a listbox expects to receive from a FEP
       
   148  */
       
   149 EXPORT_C TInt LafListBox::InputCapabilities(TInt aFlags)
       
   150 	{ // static
       
   151 	if (aFlags&SLafListBox::EIncrementalMatching)
       
   152 		return TCoeInputCapabilities::ENavigation|TCoeInputCapabilities::EAllText;
       
   153 	if (aFlags&SLafListBox::ENoFirstLetterMatching)
       
   154 		return TCoeInputCapabilities::ENavigation;
       
   155 	return TCoeInputCapabilities::ENavigation|TCoeInputCapabilities::EAllText;
       
   156 	}
       
   157 
       
   158 EXPORT_C void LafListBox::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList)
       
   159 	{ // static
       
   160 	TInt commonAttributes = TCoeColorUse::ENormal|TCoeColorUse::ENeutral;
       
   161 	TCoeColorUse colorUse;
       
   162 
       
   163 	colorUse.SetLogicalColor(EColorControlText);
       
   164 	colorUse.SetUse(TCoeColorUse::EFore|TCoeColorUse::EContents|TCoeColorUse::EActive|commonAttributes);
       
   165 	aColorUseList.AppendL(colorUse);
       
   166 
       
   167 	colorUse.SetLogicalColor(EColorControlDimmedText);
       
   168 	colorUse.SetUse(TCoeColorUse::EFore|TCoeColorUse::EContents|TCoeColorUse::EDimmed|commonAttributes);
       
   169 	aColorUseList.AppendL(colorUse);
       
   170 
       
   171 	colorUse.SetLogicalColor(EColorControlBackground);
       
   172 	colorUse.SetUse(TCoeColorUse::EBack|TCoeColorUse::EContents|TCoeColorUse::EActive|commonAttributes);
       
   173 	aColorUseList.AppendL(colorUse);
       
   174 
       
   175 	colorUse.SetLogicalColor(EColorControlHighlightText);
       
   176 	colorUse.SetUse(TCoeColorUse::EFore|TCoeColorUse::EHighlights|TCoeColorUse::EActive|commonAttributes);
       
   177 	aColorUseList.AppendL(colorUse);
       
   178 
       
   179 	colorUse.SetLogicalColor(EColorControlHighlightBackground);
       
   180 	colorUse.SetUse(TCoeColorUse::EBack|TCoeColorUse::EHighlights|TCoeColorUse::EActive|commonAttributes);
       
   181 	aColorUseList.AppendL(colorUse);
       
   182 	}
       
   183 
       
   184 /**
       
   185  * Returns the keycode to use with listboxes for the given event.  Intended primarily to allow custom
       
   186  * device hardware keys to map to standard Epoc functions.
       
   187  *
       
   188  * @since App-Framework_6.1
       
   189  */ 
       
   190 EXPORT_C TUint LafListBox::MapKeyCode(const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
       
   191 	{ // static
       
   192 	return aKeyEvent.iCode;
       
   193 	}