예제 #1
0
파일: THelp.cpp 프로젝트: perracolabs/MXPad
void __fastcall TfrmHelp::tvHelpExplorerCustomDrawItem(TCustomTreeView *Sender, TTreeNode *Node, TCustomDrawState State, bool &DefaultDraw)
{
	TCanvas *oCanvas;
    TRect   oNodeRect;

    //---------------------------------------------------------------------------
    // Initialize resources
    oCanvas   = Sender->Canvas;
    oNodeRect = Node->DisplayRect(false);
    //---------------------------------------------------------------------------

    //---------------------------------------------------------------------------
    // Set the node font settings
    oCanvas->Font->Color = (TColor)DEFAULT_NODE_FONT_COLOR;

    if (Node->HasChildren == false)
        oCanvas->Font->Style = TFontStyles();
    else
    	oCanvas->Font->Style = TFontStyles() << Graphics::fsItalic;
    //---------------------------------------------------------------------------

    //---------------------------------------------------------------------------
    // Set the node background
    if (State.Contains(Comctrls::cdsSelected) == false)
        oCanvas->Brush->Color = this->tvHelpExplorer->Color;
    else
        oCanvas->Brush->Color = (TColor)DEFAULT_SELECTED_NODE_BACK_COLOR;
    //---------------------------------------------------------------------------

    DefaultDraw = true;

    return;
}
예제 #2
0
//---------------------------------------------------------------------------
void __fastcall TForm1::lvListAdvancedCustomDrawItem(
      TCustomListView *Sender, TListItem *Item, TCustomDrawState State,
      TCustomDrawStage Stage, bool &DefaultDraw)
{
    TListView*View = (TListView*)Sender;
    if(Item!=NULL)
    {
        //cdsSelected, cdsGrayed, cdsDisabled, cdsChecked, cdsFocused
        int idx = Item->Index;
        if(idx%2==0)
        {
            View->Canvas->Brush->Color = clInfoBk;
            View->Canvas->Font->Color = clBlack;
        }
        else
        {
            View->Canvas->Brush->Color = clGradientActiveCaption;
            View->Canvas->Font->Color = clBlack;
        }
        TRect r=Item->DisplayRect(drBounds);
        if(State.Contains(cdsFocused))
        {
            View->Canvas->Brush->Color = clMaroon;
            View->Canvas->Font->Color = clWhite;
        }
        View->Canvas->FillRect(r);
        TRect rtText;
        rtText.left = r.left+2;
        rtText.top = r.top;
        rtText.right = r.left+View->Columns->Items[0]->Width;
        rtText.Bottom  = r.Bottom;
        if(View->SmallImages!=NULL)
        {
            if(Item->ImageIndex>=0)
                View->SmallImages->Draw(View->Canvas,rtText.left,rtText.top,Item->ImageIndex,true);
            rtText.left += View->SmallImages->Width+4;
        }
        DrawText(View->Canvas->Handle,Item->Caption.c_str(),-1,&rtText,DT_END_ELLIPSIS | DT_PATH_ELLIPSIS);
        AnsiString sSubText;
        int iWidth;
        for(int i=0;i<Item->SubItems->Count;i++)
        {
            if(i>=View->Columns->Count)
                continue;
            sSubText = Item->SubItems->Strings[i];
            iWidth = 0;
            for(int k=0;k<i+1;k++)
                iWidth += View->Columns->Items[k]->Width+2;
            iWidth-=1;
            rtText.left = r.left+4+iWidth;
            rtText.top = r.top;
            if(i+1<View->Columns->Count)
                rtText.right = rtText.left+View->Columns->Items[i+1]->Width;
            else
                rtText.right = rtText.left+View->Columns->Items[i]->Width;
            rtText.Bottom = r.Bottom;
            DrawText(View->Canvas->Handle,sSubText.c_str(),-1,&rtText,DT_END_ELLIPSIS | DT_PATH_ELLIPSIS);
        }
    }
    
}