?? rddraw.c
字號:
/*____________________________________________________________________________
Copyright (C) 1997 Network Associates Inc. and affiliated companies.
All rights reserved.
$Id: RDdraw.c,v 1.12 1999/03/31 23:22:46 wjb Exp $
____________________________________________________________________________*/
#include "RDprecmp.h"
/*
* OwnDraw.c ListView draw routines to accommidate italics/strikeout
*
* These routines use the ownerdraw characteristic of the standard
* listview to provide custom drawing routines.
*
* Copyright (C) 1996 Network Associates Inc. and affiliated companies.
* All rights reserved.
*/
void CreateDrawElements(PGPContextRef context,DRAWSTRUCT *ds)
{
LOGFONT lf;
ds->DisplayMarginal=FALSE;
ds->stdbarbrush =
CreateSolidBrush (GetSysColor (COLOR_3DSHADOW));
ds->spcbarbrush =
CreateHatchBrush(HS_BDIAGONAL, GetSysColor (COLOR_WINDOW));
ds->g_seltextpen =
CreatePen (PS_SOLID, 0, GetSysColor (COLOR_WINDOWTEXT));
ds->g_unseltextpen =
CreatePen (PS_SOLID, 0, GetSysColor (COLOR_WINDOW));
ds->barcolor = GetSysColor (COLOR_3DSHADOW);
ds->buttonpen = CreatePen(PS_SOLID, 0, GetSysColor (COLOR_3DSHADOW));
ds->hilightpen = CreatePen (PS_SOLID, 0,
GetSysColor (COLOR_3DHILIGHT));
ds->shadowpen = CreatePen (PS_SOLID, 0,
GetSysColor (COLOR_3DDKSHADOW));
ds->barbgbrush = CreateSolidBrush (GetSysColor (COLOR_3DFACE));
ds->HighBrush=CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
ds->BackBrush=CreateSolidBrush(GetSysColor(COLOR_WINDOW));
SystemParametersInfo (SPI_GETICONTITLELOGFONT,
sizeof(LOGFONT), &lf, 0);
ds->hFont=CreateFontIndirect (&lf);
lf.lfItalic = !lf.lfItalic;
ds->hItalic=CreateFontIndirect (&lf);
lf.lfItalic = !lf.lfItalic;
lf.lfStrikeOut=TRUE;
ds->hStrikeOut = CreateFontIndirect (&lf);
// ImageList Init
PGPsdkUICreateImageList(&(ds->hIml));
}
void DeleteDrawElements(DRAWSTRUCT *ds)
{
DeleteObject(ds->stdbarbrush);
DeleteObject(ds->spcbarbrush);
DeleteObject(ds->g_seltextpen);
DeleteObject(ds->g_unseltextpen);
DeleteObject(ds->hilightpen);
DeleteObject(ds->shadowpen);
DeleteObject(ds->buttonpen);
DeleteObject(ds->barbgbrush);
DeleteObject(ds->HighBrush);
DeleteObject(ds->BackBrush);
DeleteObject(ds->hFont);
DeleteObject(ds->hItalic);
DeleteObject(ds->hStrikeOut);
ImageList_Destroy(ds->hIml);
}
void DrawBar(DRAWSTRUCT *ds,HDC hdc,RECT *ptrBarRect,
int DataValue,int MaxValue,BOOL Selected)
{
RECT rc;
HBRUSH oldbrush,barbrush;
HPEN oldpen;
COLORREF oldbkcolor;
int cx;
CopyRect(&rc,ptrBarRect);
if(Selected)
{
FillRect (hdc, &rc, ds->HighBrush);
oldpen = SelectObject (hdc, ds->g_unseltextpen);
}
else
{
FillRect (hdc, &rc, ds->BackBrush);
oldpen = SelectObject (hdc, ds->g_seltextpen);
}
rc.top+=5;
rc.left+=5;
rc.bottom-=5;
rc.right-=5;
if(rc.right<=rc.left)
return;
cx=rc.right-rc.left;
oldbrush = SelectObject (hdc, ds->barbgbrush);
SelectObject (hdc, ds->buttonpen);
Rectangle (hdc, rc.left - 1, rc.top - 1,
rc.right + 2, rc.bottom + 2);
SelectObject (hdc, ds->shadowpen);
MoveToEx (hdc, rc.left, rc.bottom, NULL);
LineTo (hdc, rc.left, rc.top);
LineTo (hdc, rc.right, rc.top);
SelectObject (hdc, ds->hilightpen);
LineTo (hdc, rc.right, rc.bottom);
LineTo (hdc, rc.left, rc.bottom);
if (MaxValue != 0)
{
if (DataValue > MaxValue)
{
barbrush = ds->spcbarbrush;
rc.right = rc.left + cx;
}
else
{
barbrush = ds->stdbarbrush;
rc.right = rc.left +
(int)(((float)DataValue /
(float)MaxValue)
* (float)cx);
}
}
else
rc.right = rc.left;
rc.top++;
rc.left++;
if (rc.right > rc.left)
{
oldbkcolor=SetBkColor (hdc, ds->barcolor);
FillRect (hdc, &rc, barbrush);
rc.top--;
rc.left--;
// hilight pen already selected
MoveToEx (hdc, rc.right, rc.top, NULL);
LineTo (hdc, rc.left, rc.top);
LineTo (hdc, rc.left,rc.bottom);
SelectObject (hdc, ds->shadowpen);
LineTo (hdc, rc.right, rc.bottom);
LineTo (hdc, rc.right, rc.top);
SetBkColor(hdc,oldbkcolor);
}
SelectObject (hdc, oldbrush);
SelectObject (hdc, oldpen);
}
void DrawNoviceButton(DRAWSTRUCT *ds,HDC hdc,RECT *ptrBarRect,
int DataValue,int MaxValue,BOOL Selected)
{
DWORD NoviceIcon;
// HICON hIcon;
if(Selected)
{
FillRect (hdc, ptrBarRect, ds->HighBrush);
}
else
{
FillRect (hdc, ptrBarRect, ds->BackBrush);
}
if((ptrBarRect->right-ptrBarRect->left)>=CX_SMICON)
{
NoviceIcon=IDX_INVALID;
if(DataValue>2)
NoviceIcon=IDX_AXIOMATIC;
if(DataValue==2)
NoviceIcon=IDX_VALID;
if((!ds->MarginalInvalid)&&(DataValue==1))
NoviceIcon=IDX_VALID;
#ifdef _WIN32
ImageList_Draw(ds->hIml,NoviceIcon,
hdc,
ptrBarRect->left+((ptrBarRect->right-ptrBarRect->left-16)/2),
ptrBarRect->top+((ptrBarRect->bottom-ptrBarRect->top-16)/2),
ILD_TRANSPARENT);
#else
hIcon=LoadIcon(gPGPsdkUILibInst,MAKEINTRESOURCE(NoviceIcon));
DrawIcon(hdc,
ptrBarRect->left+((ptrBarRect->right-ptrBarRect->left-32)/2),
ptrBarRect->top+((ptrBarRect->bottom-ptrBarRect->top-32)/2),
hIcon);
DeleteObject(hIcon);
#endif
}
}
LISTSTRUCT *GetListStruct(HWND hwndList)
{
LISTSTRUCT *lsRet;
PRECGBL prg;
prg=(PRECGBL)GetWindowLong(GetParent(hwndList),GWL_USERDATA);
lsRet=&(prg->lsUser);
if(lsRet->hwndlist==hwndList)
return lsRet;
lsRet=&(prg->lsRec);
if(lsRet->hwndlist==hwndList)
return lsRet;
MessageBox(NULL,"Something's fishy","Ooops",MB_OK);
return 0;
}
DRAWSTRUCT *GetDrawStruct(HWND hDlg)
{
PRECGBL prg;
prg=(PRECGBL)GetWindowLong(hDlg,GWL_USERDATA);
return &(prg->ds);
}
void DrawStuff(LPDRAWITEMSTRUCT lpDrawItem)
{
PUSERKEYINFO pui;
DRAWSTRUCT *ds;
LISTSTRUCT *ls;
int index;
RECT rc;
//HICON hIcon;
HWND hDlg,hwndList;
int max;
BOOL focused;
focused=TRUE;
if(lpDrawItem->hwndItem!=0)
{
if(GetFocus()!=lpDrawItem->hwndItem)
focused=FALSE;
}
hwndList=lpDrawItem->hwndItem;
hDlg=GetParent(hwndList);
ls=GetListStruct(hwndList);
ds=GetDrawStruct(hDlg);
pui=(PUSERKEYINFO)(lpDrawItem->itemData);
CopyRect(&rc,&(lpDrawItem->rcItem));
#ifdef _WIN32
ImageList_Draw(ds->hIml,pui->icon,
lpDrawItem->hDC,
rc.left+((CX_SMICON-16)/2),
rc.top+((CY_SMICON-16)/2),
ILD_TRANSPARENT);
#else
hIcon=LoadIcon(gPGPsdkUILibInst,MAKEINTRESOURCE(pui->icon));
DrawIcon(lpDrawItem->hDC,
rc.left+((CX_SMICON-32)/2),
rc.top+((CY_SMICON-32)/2),
hIcon);
DeleteObject(hIcon);
#endif
rc.right=rc.left;
rc.left=rc.left+16;
max=0;
for(index=0;index<NUMCOLUMNS;index++)
{
#if LISTBOX
max=max+ls->colwidth[index];
#else
max=max+
ListView_GetColumnWidth(lpDrawItem->hwndItem,index);
#endif
}
for(index=0;index<NUMCOLUMNS;index++)
{
#if LISTBOX
rc.right=rc.right+ls->colwidth[index];
#else
rc.right=rc.right+
ListView_GetColumnWidth(lpDrawItem->hwndItem,index);
#endif
switch(index)
{
case 0:
{
HFONT oldFont;
RECT origrc;
// Save original rect
CopyRect(&origrc,&rc);
oldFont=SelectObject(lpDrawItem->hDC,
ds->hFont);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -