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

📄 customdrawtableviewdemomain.cpp

📁 DevExpress ExpressQuantumGrid Suite v5.9 Full Source
💻 CPP
📖 第 1 页 / 共 3 页
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "CustomDrawTableViewDemoMain.h"
#include "CustomDrawTableViewDemoMainData.h"
#include "AboutDemoForm.h"
#include "CustomDrawTableViewDemoStylesEditor.h"
#include "shellapi.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxClasses"
#pragma link "cxControls"
#pragma link "cxCustomData"
#pragma link "cxData"
#pragma link "cxDBData"
#pragma link "cxEdit"
#pragma link "cxFilter"
#pragma link "cxGraphics"
#pragma link "cxGrid"
#pragma link "cxGridCustomTableView"
#pragma link "cxGridCustomView"
#pragma link "cxGridDBTableView"
#pragma link "cxGridLevel"
#pragma link "cxGridTableView"
#pragma link "cxStyles"
#pragma link "cxLookAndFeels"
#pragma resource "*.dfm"
TCustomDrawTableViewDemoMainForm *CustomDrawTableViewDemoMainForm;
//---------------------------------------------------------------------------
__fastcall TCustomDrawTableViewDemoMainForm::TCustomDrawTableViewDemoMainForm(TComponent* Owner)
  : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TCustomDrawTableViewDemoMainForm::miAboutClick(TObject *Sender)
{
  ShowAboutDemoForm();
}
//---------------------------------------------------------------------------

void __fastcall TCustomDrawTableViewDemoMainForm::miExitClick(TObject *Sender)
{
  Close();  
}
//---------------------------------------------------------------------------

void __fastcall TCustomDrawTableViewDemoMainForm::FormShow(TObject *Sender)
{
  CustomDrawTableViewDemoStylesEditorForm->Show();
}
//---------------------------------------------------------------------------

void __fastcall TCustomDrawTableViewDemoMainForm::miCustomDrawEditorClick(
      TObject *Sender)
{
  CustomDrawTableViewDemoStylesEditorForm->Show();
}
//---------------------------------------------------------------------------

void __fastcall TCustomDrawTableViewDemoMainForm::SetCustomDrawingStyle(TViewType AViewType, TCustomDrawArea ACustomDrawArea, const TCustomDrawingStyle Value)
{
  if (FCustomDrawingStyle[(int)AViewType][(int)ACustomDrawArea] != Value) {
    FCustomDrawingStyle[(int)AViewType][(int)ACustomDrawArea] = Value;
    switch (AViewType) {
      case vtMaster: {
        tvCars->LayoutChanged(false);
        tvCars->Painter->Invalidate();
      }; break;
      case vtDetail: {
        tvOrders->LayoutChanged(false);
        tvOrders->Painter->Invalidate();
      }; break;
    };
  };
}
//---------------------------------------------------------------------------

TCustomDrawingStyle __fastcall TCustomDrawTableViewDemoMainForm::GetCustomDrawingStyle(TViewType AViewType, TCustomDrawArea ACustomDrawArea)
{
  return(FCustomDrawingStyle[(int)AViewType][(int)ACustomDrawArea]);
}
//---------------------------------------------------------------------------

void __fastcall TCustomDrawTableViewDemoMainForm::SetCustomDrawingStyles()
{
  FGridBrushMasterCell = new TBrush();
  FGridBrushMasterGroupCell = new TBrush();
  FGridBrushMasterFooterCell = new TBrush();
  FGridBrushMasterColumnHeader = new TBrush();
  FGridBrushMasterPartBackground = new TBrush();
  FGridBrushMasterIndicatorCell = new TBrush();

  FGridBrushDetailCell = new TBrush();
  FGridBrushDetailGroupCell = new TBrush();
  FGridBrushDetailFooterCell = new TBrush();
  FGridBrushDetailColumnHeader = new TBrush();
  FGridBrushDetailPartBackground = new TBrush();
  FGridBrushDetailIndicatorCell = new TBrush();

  FIndicatorImageIndex[(int)vtMaster] = 0;
  FIndicatorImageIndex[(int)vtDetail] = 0;

  for (int i=0; i<2; i++)
    for (int j=0; j<6; j++)
      FBkImages[i][j] = bkiTile;

  FGridBrushMasterCell->Bitmap = FTileBitmap;
  FGridBrushMasterGroupCell->Bitmap = FTileBitmap;
  FGridBrushMasterColumnHeader->Bitmap = FTileBitmap;
  FGridBrushMasterFooterCell->Bitmap = FTileBitmap;
  FGridBrushMasterPartBackground->Bitmap = FTileBitmap;
  FGridBrushMasterIndicatorCell->Bitmap = FTileBitmap;

  FGridBrushDetailCell->Bitmap = FTileBitmap;
  FGridBrushDetailGroupCell->Bitmap = FTileBitmap;
  FGridBrushDetailColumnHeader->Bitmap = FTileBitmap;
  FGridBrushDetailFooterCell->Bitmap = FTileBitmap;
  FGridBrushDetailPartBackground->Bitmap = FTileBitmap;
  FGridBrushDetailIndicatorCell->Bitmap = FTileBitmap;

  FColorScheme[(int)vtMaster][0] = csBlue;
  FColorScheme[(int)vtDetail][1] = csBlue;
  for (int i=0; i<2; i++)
    for (int j=0; j<6; j++)
      FCustomDrawingStyle[i][j] = cdsBkImage;
}
//---------------------------------------------------------------------------

int __fastcall TCustomDrawTableViewDemoMainForm::GetIndicatorImageIndex(TViewType AViewType)
{
  return(FIndicatorImageIndex[(int)AViewType]);
}
//---------------------------------------------------------------------------

void __fastcall TCustomDrawTableViewDemoMainForm::SetIndicatorImageIndex(TViewType AViewType, const int Value)
{
  if (FIndicatorImageIndex[(int)AViewType] != Value) {
    FIndicatorImageIndex[(int)AViewType] = Value;
    switch (AViewType) {
      case vtMaster: {
        tvCars->LayoutChanged(false);
        tvCars->Painter->Invalidate();
      }; break;
      case vtDetail: {
        tvOrders->LayoutChanged(false);
        tvOrders->Painter->Invalidate();
      }; break;
    };
  };
}
//---------------------------------------------------------------------------

TBkImage __fastcall TCustomDrawTableViewDemoMainForm::GetCustomBkImage(TViewType AViewType, TCustomDrawArea ACustomDrawArea)
{
  return(FBkImages[(int)AViewType][(int)ACustomDrawArea]);
}
//---------------------------------------------------------------------------

Graphics::TBitmap* __fastcall TCustomDrawTableViewDemoMainForm::GetImage(TBkImage AValue)
{
  switch (AValue) {
    case bkiTile: return(FTileBitmap);
    case bkiSky: return(FSkyBitmap);
    case bkiEgypt: return(FEgyptBitmap);
    case bkiMyFace: return(FMyFaceBitmap);
  };
  return (NULL);
};
//---------------------------------------------------------------------------

void __fastcall TCustomDrawTableViewDemoMainForm::SetCustomBkImage(TViewType AViewType, TCustomDrawArea ACustomDrawArea, TBkImage AValue)
{
  if(AValue != bkiUserDefined) {
    if(FBkImages[(int)AViewType][(int)ACustomDrawArea] != AValue) {
      FBkImages[(int)AViewType][(int)ACustomDrawArea] = AValue;
      switch (AViewType) {
        case vtMaster: {
          switch (ACustomDrawArea) {
            case cdaCell: FGridBrushMasterCell->Bitmap = GetImage(AValue); break;
            case cdaGroupCell: FGridBrushMasterGroupCell->Bitmap = GetImage(AValue); break;
            case cdaColumnHeader: FGridBrushMasterColumnHeader->Bitmap = GetImage(AValue); break;
            case cdaFooterCell: FGridBrushMasterFooterCell->Bitmap = GetImage(AValue); break;
            case cdaIndicatorCell: FGridBrushMasterIndicatorCell->Bitmap = GetImage(AValue); break;
            case cdaPartBackGround: FGridBrushMasterPartBackground->Bitmap = GetImage(AValue); break;
          };
          tvCars->LayoutChanged(false);
          tvCars->Painter->Invalidate();
        }; break;
        case vtDetail: {
          switch (ACustomDrawArea) {
            case cdaCell: FGridBrushDetailCell->Bitmap = GetImage(AValue); break;
            case cdaGroupCell: FGridBrushDetailGroupCell->Bitmap = GetImage(AValue); break;
            case cdaColumnHeader: FGridBrushDetailColumnHeader->Bitmap = GetImage(AValue); break;
            case cdaFooterCell: FGridBrushDetailFooterCell->Bitmap = GetImage(AValue); break;
            case cdaIndicatorCell: FGridBrushDetailIndicatorCell->Bitmap = GetImage(AValue); break;
            case cdaPartBackGround: FGridBrushDetailPartBackground->Bitmap = GetImage(AValue); break;
          };
          tvOrders->LayoutChanged(false);
          tvOrders->Painter->Invalidate();
        }; break;
      };
    };
  }
  else {
    FBkImages[(int)AViewType][(int)ACustomDrawArea] = AValue;
    switch (AViewType) {
      case vtMaster: {
        tvCars->LayoutChanged(false);
        tvCars->Painter->Invalidate();
      }; break;
      case vtDetail: {
        tvOrders->LayoutChanged(false);
        tvOrders->Painter->Invalidate();
      }; break;
    };
  };
}
//---------------------------------------------------------------------------

CustomDrawTableViewDemoTypesH::TColorScheme __fastcall TCustomDrawTableViewDemoMainForm::GetCustomColorScheme(TViewType AViewType, TCustomDrawArea ACustomDrawArea)
{
  return(FColorScheme[(int)AViewType][(int)ACustomDrawArea]);
}
//---------------------------------------------------------------------------

void __fastcall TCustomDrawTableViewDemoMainForm::SetCustomColorScheme(TViewType AViewType, TCustomDrawArea ACustomDrawArea, const CustomDrawTableViewDemoTypesH::TColorScheme Value)
{
  if(FColorScheme[(int)AViewType][(int)ACustomDrawArea] != Value) {
    FColorScheme[(int)AViewType][(int)ACustomDrawArea] = Value;
    switch (AViewType) {
      case vtMaster: {
        tvCars->LayoutChanged(false);
        tvCars->Painter->Invalidate();
      }; break;
      case vtDetail: {
        tvOrders->LayoutChanged(false);
        tvOrders->Painter->Invalidate();
      }; break;
    };
  };
}
//---------------------------------------------------------------------------

void __fastcall TCustomDrawTableViewDemoMainForm::SetUserDefineBitmap(TViewType AViewType, TCustomDrawArea ACustomDrawArea, Graphics::TBitmap* Value)
{
  switch (AViewType) {

⌨️ 快捷键说明

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