⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mygrid.cpp

📁 《基于Symbian OS的手机开发与应用实践》这本书的配套源码。
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CMyGrid from MyGrid.h
*  Part of  : AllPopuplists
*  Created  : 23.03.2006 by ToBeReplacedByAuthor
*  Implementation notes:
*     Initial content was generated by Series 60 Application Wizard.
*  Version  :
*  Copyright: ToBeReplacedByCopyright
* ============================================================================
*/

// INCLUDE FILES
#include <aknlists.h> // for AknListBoxLayouts

#include "MyGrid.h"

const TInt KIconHeight = 24;
const TInt KMarkWidth = 13;
const TInt KMarkHeight = 13;
const TInt KItemWidth = 56;
const TInt KItemHeight = 40;

// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CMyGrid::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CMyGrid::SizeChanged()
    {
    CAknGrid::SizeChanged();
    
    // Setup default layout
    SetLayoutL(EFalse, ETrue, ETrue, 3, 3, TSize(KItemWidth,KItemHeight));

    // Setup default foreground color and background color
    AknListBoxLayouts::SetupStandardGrid(*this);

    // Layout cells
    CFormattedCellListBoxItemDrawer* itemDrawer = this->ItemDrawer();

    // Layout icon cell
    AknListBoxLayouts::SetupFormGfxCell
        (
        *this,
        itemDrawer,
        0,                          // The position of the icon in the item string
        0,                          // left position
        0,                          // top position
        0,                          // right position, not used
        0,                          // bottom position, not used
        KItemWidth,                 // width of graphic
        KIconHeight,                // height of the icon
        TPoint(0,0),                // top-left position
        TPoint(KItemWidth, KIconHeight)  // bottom-right position
        );

    // Layout text cell
    const CFont* font = CCoeEnv::Static()->NormalFont();
    TInt baseline = KItemHeight - font->DescentInPixels() - 1;
    
    AknListBoxLayouts::SetupFormTextCell
        (
        *this,
        itemDrawer,
        1,                          // The position of text in item strings
        font,                       // The text font
        215,                        // the color of the text
        0,                          // left margin
        0,                          // right margin, not used
        baseline,                   // Baseline
        KItemWidth,                 // text width
        CGraphicsContext::ECenter,  // Alignment
        TPoint(0, KIconHeight),     // top-left position
        TPoint(KItemWidth, KItemHeight)  // end position
        );
    
    // Layout mark cell
    AknListBoxLayouts::SetupFormGfxCell
        (
        *this,
        itemDrawer,
        2,                          // The position of the mark in the item string
        KItemWidth-KMarkWidth,      // left position
        0,                          // top position
        0,                          // right position, not used
        0,                          // bottom position, not used
        KMarkWidth,                 // width of the mark
        KMarkHeight,                // height of the mark
        TPoint(KItemWidth-KMarkWidth,0), // start position
        TPoint(KItemWidth, KMarkHeight)  // end position
        );

    itemDrawer->SetItemMarkPosition(2); // The position of the mark icon in the item string 
    _LIT(KMarkReplacement, "0");        // The index of the mark icon in the icon array
    itemDrawer->SetItemMarkReplacement(KMarkReplacement());
    itemDrawer->SetItemMarkReverse(ETrue); // Unmarkall by default
    }

TSize CMyGrid::MinimumSize()
    {
    return CAknGrid::MinimumSize();
    }

// End of File  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -