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

📄 icontact.cpp

📁 This code is Address book code for Windows Mobile. This source code support windows mobile 5.0 over.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    // "About" at bottom of screen
    SelectObject(hdc, SecondaryListFont);
    SetTextAlign(hdc, TA_LEFT | TA_BOTTOM);
    SetTextColor(hdc, pSettings->rgbListItemSelectedShadow);
    ExtTextOut(hdc, rList.left + 2, rList.bottom - 2, 
        NULL, NULL, SZ_ABOUT, ABOUT_LENGTH, 0);

    if (count == 0) {
        //TODO: maybe indicate empty list?
        return;
    }

    // ******* DRAW LIST ITEMS
	while (nItem < count && rItem.bottom < rList.bottom) {
		dItemTmp = pListData->GetItem(nItem);

        rItem.top = rItem.bottom;
        rItem.bottom = rItem.top + StartPosition[nItem+1] 
            - StartPosition[nItem];
        
        if (nItem == pListData->GetCurrentItemIndex() 
            && stScreenType == stList) {
            DrawItemSelectedOn(hdc, dItemTmp, rItem);
		}
        else {
            DrawItemOn(hdc, dItemTmp, rItem);
		}

        // ****** Group Header
		if (stScreenType == stList
			&& pListData->IsItemNewGroup(nItem)
            && dItemTmp.wcGroup && rItem.top >= rList.top) {

            DrawGroupHeaderOn(hdc, nItem, rItem);
		} 

        // Next nItem
        nItem++;
	}

    // Special: Draw the group of the list nItem that's at the top of the list
    dItemTmp = pListData->GetItem(nFirstItem);
    if (dItemTmp.wcGroup && yOffset >= 0) {
        RECT rTopGroup = {rList.left, 0, rList.right, DefaultGroupHeight};
        DrawGroupHeaderOn(hdcTmp, nFirstItem, rTopGroup);

        int nHeight = DefaultGroupHeight;
        int nBottom = nHeight;

        if (pListData->IsItemNewGroup(nFirstItem + 1)) {
            nBottom = min(nBottom, StartPosition[nFirstItem + 1] - yOffset);
        }

        // account for the fact that the list
        // doesn't start at the top of the screen
        nBottom += rList.top;

        int nLeft = rList.left;
        int nWidth = rList.right - rList.left;
        int nTop = nBottom - nHeight;

        if (bScrolling && pSettings->doFastGraphics) {
            BitBlt(hdc, nLeft, nTop, nWidth, nHeight, hdcTmp, 0, 0, SRCCOPY);
        }
        else {
            BltAlpha(hdc, nLeft, nTop, nWidth, nHeight, hdcTmp, 200);
        }
    }

    // Draw list indicator if scrolling quickly
	if (bScrolling) {
		SelectObject(hdc, ListIndicatorFont);
	    SetTextAlign(hdc, TA_CENTER);
		SetTextColor(hdc, pSettings->rgbListGroupText);
		SetBkMode(hdc, TRANSPARENT);

        pListData->GetItemGroup(nFirstItem, buffer);
        int length = _tcslen(buffer);

        ExtTextOut(hdc, (rList.right - rList.left) / 2 + rList.left, 
            rList.top + 10, NULL, NULL, buffer, length, 0);
	}
}

void DrawGroupHeaderOn(HDC hdc, int index, RECT rItem) {
    RECT rHeader = rItem;
    rHeader.bottom = rHeader.top + DefaultGroupHeight;
    TCHAR buffer[10];

    pListData->GetItemGroup(index, buffer);
    int length = _tcslen(buffer);

	// ****** GroupHeader background
	FillRect(hdc, &rHeader, pSettings->hbrListGroupBackground);

    // separator
    RECT rSep = rHeader;
    rSep.top = rHeader.bottom - ListSeparatorHeight;
    FillRect(hdc, &rSep, pSettings->hbrListItemSeparator);
	SetTextAlign(hdc, TA_LEFT);

	// ******* Draw Group Header Text
	SelectObject(hdc, GroupFont);
   	SetBkMode(hdc, TRANSPARENT);
	SetTextColor(hdc, pSettings->rgbListGroupText);
	ExtTextOut(hdc, rItem.left + ListGroupItemIndent, 
        rHeader.top - 1 + ((DefaultGroupHeight - GroupItemFontSize) / 2),
        NULL, NULL, buffer, length, 0);
}

void DrawItemSelectedOn(HDC hdc, Data dItem, RECT rItem) {
	// ******* DRAW ITEM BACKGROUND
	DrawGradientGDI(hdc, rItem,
        pSettings->rgbListItemSelectedBackground1,
        pSettings->rgbListItemSelectedBackground2);

	// ****** Draw Item Text
	SelectObject(hdc, PrimaryListFont);
	SetTextAlign(hdc, TA_LEFT);

    // Item Shadow Text
	SetTextColor(hdc, pSettings->rgbListItemSelectedShadow);
	ExtTextOut(hdc, rItem.left + ListItemIndent,
        rItem.bottom - ((DefaultItemHeight + ItemFontSize) / 2),
        ETO_OPAQUE, NULL, dItem.szPrimaryText, dItem.nPrimaryTextLength, 0);

    // Item Text
	SetTextColor(hdc, pSettings->rgbListItemSelectedText);
	ExtTextOut(hdc, rItem.left + ListItemIndent, 
        rItem.bottom - 2 - ((DefaultItemHeight + ItemFontSize) / 2),
        ETO_OPAQUE, NULL, dItem.szPrimaryText, dItem.nPrimaryTextLength, 0);
}

void DrawItemOn(HDC hdc, Data dItem, RECT rItem) {
    // Item Background
    FillRect(hdc, &rItem, pSettings->hbrListItemBackground);

    // separator
    RECT rSep = rItem;
    rSep.top = rItem.bottom - ListSeparatorHeight;
    FillRect(hdc, &rSep, pSettings->hbrListItemSeparator);
	SetTextAlign(hdc, TA_LEFT);

    // Item Primary Text
	SelectObject(hdc, PrimaryListFont);
	SetTextColor(hdc, dItem.rgbPrimaryText);
	ExtTextOut(hdc, rItem.left + ListItemIndent,
        rItem.bottom - 2 - ((DefaultItemHeight + ItemFontSize) / 2),
        ETO_OPAQUE, NULL, dItem.szPrimaryText, dItem.nPrimaryTextLength, 0);

	// Item Secondary Text
    if (dItem.nSecondaryTextLength == 0)
        return;
    SelectObject(hdc, SecondaryListFont);
    SetTextAlign(hdc, TA_RIGHT);
    SetTextColor(hdc, pSettings->rgbListItemText);
    ExtTextOut(hdc, rItem.right - ListItemIndent,
        rItem.bottom - 2 - ((DefaultItemHeight + ItemSecondaryFontSize) / 2),
	    ETO_OPAQUE, NULL, dItem.szSecondaryText, dItem.nSecondaryTextLength, 0);

}

void DrawItemDetailsOn(HDC hdc, Data dItem, int yOffset) {
    int nameHeight = 0;
    int nPictureSize = 0;
    DataDetail dd = {0};
    RECT rRow, rClip;

    SelectObject(hdc, PrimaryListFont);
    SetTextAlign(hdc, TA_LEFT);
    SetBkMode(hdc, TRANSPARENT);

    int iItemCount = pListData->GetItemDetailCount();
    int iCurrentIndex = pListData->GetCurrentDetailIndex();
    int iBitmapHeight = 0;
    int iBitmapWidth = 0;

	// ******* DRAW ITEM BACKGROUND
	DrawGradientGDI(hdc, rContent,
        pSettings->rgbListItemSelectedBackground1,
        pSettings->rgbListItemSelectedBackground2);

    // ******* Draw the current item's picture, if it exists
    HBITMAP hBitmap = pListData->GetHBitmap(ItemDetailsPictureSize);
    if (NULL != hBitmap) {
        iBitmapHeight = pListData->GetHBitmapHeight();
        iBitmapWidth = pListData->GetHBitmapWidth();

        int left = ItemDetailsPadding;
        int top = (DefaultItemHeight * 2 - iBitmapHeight) / 2 + rContent.top - yOffset;
        int right = left + iBitmapWidth;
        int bottom = top + iBitmapHeight;

        // draw black square with a black border of 1
        RECT rcBitmap = { left - 1, top - 1, right + 1, bottom + 1};
        DrawRect(hdc, &rcBitmap, (COLORREF)0);

        // paint the bitmap on the DC
        TransparentImage(hdc, left, top, iBitmapWidth, iBitmapHeight, 
            hBitmap, 0, 0, iBitmapWidth, iBitmapHeight, (COLORREF)0);
    }

    // ******* Now, draw the item data
	for (int c = 0; c < iItemCount; c++) {
        dd = pListData->GetItemDetail(c);

        if (dd.type == diNothing)
            continue;

        rRow.top = c * DefaultItemHeight + rContent.top - yOffset;
        rRow.bottom = rRow.top + DefaultItemHeight;
        if (dd.type == diName)
            rRow.bottom += DefaultItemHeight;

        rRow.left = rContent.left;

        if (rRow.top + yOffset 
            < iBitmapHeight + rContent.top + ItemDetailsPadding / 2 
            && iBitmapWidth > 0)

            rRow.left += iBitmapWidth + ItemDetailsPadding;

        rRow.right = rContent.right;

        rClip.left = rRow.left + ItemDetailsPadding / 2 + 1;
        rClip.right = rRow.right - ItemDetailsPadding / 2 - 1;
        rClip.top = rRow.top + ItemDetailsPadding / 2 + 1;
        rClip.bottom = rRow.bottom - ItemDetailsPadding / 2 - 1;

        // If this is the first item of a new group of items, draw a rectangle
        // around the group
        if ((dd.type == diPhone 
            || dd.type == diEmail 
            || dd.type == diUrl
            || dd.type == diDetailsButton 
            || dd.type == diCallButton
            || dd.type == diSmsButton
            || dd.type == diEditButton
            || dd.type == diSaveContactButton) 
            && c > 0 
            && pListData->GetItemDetail(c-1).type != dd.type) {

            int nRows = 1;
            while (c + nRows < iItemCount 
                && pListData->GetItemDetail(c + nRows).type == dd.type)
                nRows++;

            SelectObject(hdc, pSettings->hbrListItemBackground);
            SetTextColor(hdc, pSettings->rgbListItemText);
            RoundRect(hdc, 
                rRow.left + ItemDetailsPadding / 2, 
                rRow.top + ItemDetailsPadding / 3, 
                rRow.right - ItemDetailsPadding / 2, 
                rRow.bottom - ItemDetailsPadding / 3 + DefaultItemHeight * (nRows - 1),
                ItemDetailsPadding, ItemDetailsPadding);
        }

        if (rRow.bottom < 0)
            continue;

        // Indicate the currently selected item
	    if (c == iCurrentIndex) {
            SelectObject(hdc, pSettings->hbrListItemSelectedBackground);
            RoundRect(hdc, 
                rRow.left + ItemDetailsPadding / 2, 
                rRow.top + ItemDetailsPadding / 3, 
                rRow.right - ItemDetailsPadding / 2, 
                rRow.bottom - ItemDetailsPadding / 3,
                ItemDetailsPadding, ItemDetailsPadding);
            SetTextColor(hdc, pSettings->rgbListItemSelectedText);
	    }
        else {
            SelectObject(hdc, GetStockObject(NULL_BRUSH));
    	    SetTextColor(hdc, pSettings->rgbListItemText);
        }

        if (dd.type == diName) {
            SelectObject(hdc, PrimaryListFont);
            SetTextAlign(hdc, TA_LEFT | TA_TOP);

            // Display the shadow
            SetTextColor(hdc, pSettings->rgbListItemSelectedShadow);
		    ExtTextOut(hdc, rRow.left + ItemDetailsPadding + 1, 
                rRow.top + ItemDetailsPadding + 1,
                ETO_CLIPPED, &rClip, dd.text, _tcslen(dd.text), NULL);

            // Display the name
            SetTextColor(hdc, pSettings->rgbListItemSelectedText);
		    ExtTextOut(hdc, rRow.left + ItemDetailsPadding, 
                rRow.top + ItemDetailsPadding,
                ETO_CLIPPED, &rClip, dd.text, _tcslen(dd.text), NULL);
        }

        else if (dd.type == diCompany) {
            SelectObject(hdc, SecondaryListFont);
            SetTextColor(hdc, pSettings->rgbListItemSelectedText);
		    ExtTextOut(hdc, rRow.left + ItemDetailsPadding, rRow.top,
                NULL, NULL, dd.text, _tcslen(dd.text), NULL);
        }

        else if (dd.type == diDetailsButton 
            || dd.type == diEditButton
            || dd.type == diCallButton
            || dd.type == diSmsButton
            || dd.type == diSaveContactButton) {
		    
            SelectObject(hdc, PrimaryListFont);
            SetTextAlign(hdc, TA_CENTER);

            ExtTextOut(hdc, (rRow.right - rRow.left) / 2 + rRow.left,
                (rRow.bottom - rRow.top - ItemFontSize) / 2 + rRow.top,
                ETO_CLIPPED, &rClip, dd.text,
                _tcslen(dd.text), 0);

        }

        else if (dd.type == diEmail
                || dd.type == diUrl) {
            SelectObject(hdc, PrimaryListFont);
            SetTextAlign(hdc, TA_CENTER);

            ExtTextOut(hdc, (rRow.right - rRow.left) / 2 + rRow.left,
                (rRow.bottom - rRow.top - ItemFontSize) / 2 + rRow.top,
                ETO_CLIPPED, &rClip, dd.text, _tcslen(dd.text), 0);
        }

        else {
		    SelectObject(hdc, ItemDetailsFont);
            SetTextAlign(hdc, TA_RIGHT | TA_BOTTOM);
            int y = (rRow.bottom - rRow.top) / 2 + rRow.top;

            // Draw the label: "Home", "Work", etc.
            rClip.right = rRow.left + ItemDetailsPadding * 5;
            ExtTextOut(hdc, rClip.right, 
                y + (ItemDetailsFontSize / 2),
                ETO_CLIPPED, &rClip, dd.label, _tcslen(dd.label), NULL);

            rClip.left = rClip.right + 3;
            rClip.right = rRow.right - ItemDetailsPadding;

            // Draw the right label: "SMS"
            if (dd.type == diPhone) {
                rClip.right -= ItemDetailsPadding * 2;
                ExtTextOut(hdc, rRow.right - ItemDetailsPadding, 
                    y + (ItemDetailsFontSize / 2),
                    NULL, NULL, pSettings->sms_string, 
                    _tcslen(pSettings->sms_string), NULL);
            }

            SetTextAlign(hdc, TA_LEFT | TA_BOTTOM);
            SelectObject(hdc, PrimaryListFont);

		    ExtTextOut(hdc, rClip.left + ItemDetailsPadding / 3, y + (ItemFontSize / 2),
                ETO_CLIPPED, &rClip, dd.text, _tcslen(dd.text), NULL);
        }
	}
}

void DrawKeyboardOn(HDC hdc, RECT rKeyboard) {
	SelectObject(hdc, KeyboardFont);
	SelectObject(hdc, pSettings->hpenKeyboardGrid);
    SetTextColor(hdc, pSettings->rgbKeyboardText);
	SetBkMode(hdc, TRANSPARENT);
    int x, y, g, h;

    FillRect(hdc, &rKeyboard, pSettings->hbrKeyboardBackground);

    SetTextAlign(hdc, TA_CENTER);

    // Draw the horizontal lines
    for (h = 0; h < nKeyboardRows; h++) {
        y = rKeyboard.top + h 
            * (rKeyboard.bottom - rKeyboard.top) / nKeyboardRows;
        MoveToEx(hdc, rKeyboard.left, y, (LPPOINT) NULL);
        LineTo(hdc, rKeyboard.right, y);
    }
    MoveToEx(hdc, rKeyboard.left, rKeyboard.bottom - 1, (LPPOINT) NULL);
    LineTo(hdc, rKeyboard.right, rKeyboard.bottom - 1);

    // Draw the vertical lines
    for (g = 0; g < nKeyboardCols; g++) {
        x = rKeyboard.left + g 
            * (rKeyboard.right - rKeyboard.left) / nKeyboardCols;
        MoveToEx(hdc, x, rKeyboard.top, (LPPOINT) NULL);
        LineTo(hdc, x, rKeyboard.bottom);
    }
    MoveToEx(hdc, rKeyboard.right - 1, rKeyboard.top, (LPPOINT) NULL);
    LineTo(hdc, rKeyboard.right - 1, rKeyboard.bottom);

    // Draw the letters
    int i = 0;
	for (h = 0; h <= nKeyboardRows; h++) {
        y = rKeyboard.top 
            + ((GroupHeight - KeyboardFontSize) / 2) 

⌨️ 快捷键说明

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