Exemple #1
0
//---------------------------------------------------------------------------
void __fastcall TSynchronizeChecklistDialog::ListViewWindowProc(TMessage & Message)
{
  if (Message.Msg == CN_NOTIFY)
  {
    TWMNotify & NotifyMessage = reinterpret_cast<TWMNotify &>(Message);
    if (NotifyMessage.NMHdr->code == NM_CUSTOMDRAW)
    {
      // Due to a bug in VCL, OnAdvancedCustomDrawSubItem is not called for any
      // other stage except for cdPrePaint. So we must call it ourselves.
      TNMLVCustomDraw * CustomDraw =
        reinterpret_cast<TNMLVCustomDraw *>(NotifyMessage.NMHdr);
      if (FLAGSET(CustomDraw->nmcd.dwDrawStage, CDDS_ITEM) &&
          FLAGSET(CustomDraw->nmcd.dwDrawStage, CDDS_SUBITEM) &&
          FLAGSET(CustomDraw->nmcd.dwDrawStage, CDDS_ITEMPOSTPAINT) &&
          (CustomDraw->iSubItem == 4) &&
          (ActionImages->Width <= ListView->Columns->Items[CustomDraw->iSubItem]->Width))
      {
        TListItem * Item = ListView->Items->Item[CustomDraw->nmcd.dwItemSpec];
        const TSynchronizeChecklist::TItem * ChecklistItem =
          static_cast<const TSynchronizeChecklist::TItem *>(Item->Data);
        TRect R = Item->DisplayRect(drBounds);
        for (int Index = 0; Index < CustomDraw->iSubItem; Index++)
        {
          R.Left += ListView->Columns->Items[Index]->Width;
        }
        R.Left +=
          (ListView->Columns->Items[CustomDraw->iSubItem]->Width - ActionImages->Width) / 2;
        // doing this from ListViewAdvancedCustomDraw corrupts list view on Windows 7
        ImageList_Draw(reinterpret_cast<HIMAGELIST>(ActionImages->Handle),
          int(ChecklistItem->Action), CustomDraw->nmcd.hdc,
          R.Left, ((R.Top + R.Bottom - ActionImages->Height) / 2), ILD_TRANSPARENT);
      }
    }
  }

  FOrigListViewWindowProc(Message);
}
Exemple #2
0
void TfrmLayer::onRegen()
{
	if(!this->Showing)
    	return;

	for(int i=0;i< _Colors.size();i++) {
		if(_Colors[i]->Showing) _Colors[i]->Hide();
		delete _Colors[i];
	}
	_Colors.clear();

	for(int i=0;i< _alphas.size();i++) {
		if(_alphas[i]->Showing) _alphas[i]->Hide();
		delete _alphas[i];
	}
	_alphas.clear();

	ListView1->Clear();

	ListView1->Visible = false;

	if(_fview==NULL) {
		this->Caption = "Layers < Nothing >";
		popupMenu->AutoPopup = false;
		StatusBar1->Panels->operator [](1)->Text = "0";
		StatusBar1->Panels->operator [](3)->Text = "0";
	}

	else {
		popupMenu->AutoPopup = true;
		this->Caption = _fview->Caption ;
		NewLayer1->Enabled = true;

		_layers = _fview->view()->layers();

		for(int i=0 ; i < _layers->size() ;i++) {
			TListItem *item;
			item = ListView1->Items->Add();

			TCHAR* str = _layers->at(i)->getName();

			item->Caption = str;
			item->Checked = _layers->at(i)->visible();

			RGBA color;
            color.r = color.g = color.b = 0;
			color.a = 255;

			TRect rect = item->DisplayRect(drSelectBounds);

			////--
			TColorBox *lc = new TColorBox(this);
			lc->Top = rect.top;
			lc->Left = 100; // 102;
			lc->Width = 100;
			lc->ItemHeight = 11;

			lc->BevelOuter = bvNone;

			lc->Selected = clWindow;
			char name[255];
			sprintf(name,"N%05d%d",i,1);
			lc->Name = name;
			if(_layers->at(i)->getLineColor(color))
				lc->Selected = (TColor)RGB(color.r,color.g,color.b);

			lc->OnSelect = ColorBox1Select;
			lc->OnDropDown = ColorBox1DropDown;

			lc->Parent = ListView1;

			TColorBoxStyle style;
			//style << cbStandardColors << cbIncludeNone << cbIncludeDefault << cbPrettyNames << cbSystemColors << cbCustomColor;
			style << cbIncludeDefault << cbPrettyNames << cbCustomColor;
			lc->Style = style ;

			for(int i=0 ; i<256; i++) {
				char str[255];
				sprintf(str,"%d",i);
				lc->AddItem(str,(TObject*)(TColor)RGB(dxfColors[i][0]*255,dxfColors[i][1]*255,dxfColors[i][2]*255));
			}

			_Colors.push_back(lc);

			//
			TTrackBar *la = new TTrackBar(this);
			la->Top = rect.top;
			la->Left = 160;
			la->Width = 60;
			la->Height = 16;
			la->Max = 255;
			la->ShowSelRange = false;
 			la->TabOrder = 1;
 			la->TabStop = false;
			la->ThumbLength = 14;

			la->Parent = ListView1;

			la->TickMarks = tmBoth;
			la->TickStyle = tsNone;
			sprintf(name,"T%05d%d",i,1);
			la->Name = name;
			la->Position = 255;
			la->Brush->Color = clWhite;
			if(_layers->at(i)->getLineColor(color)) la->Position = color.a;

			la->OnChange = TrackBar1Change;
			_alphas.push_back(la);


			////
			TColorBox *fc = new TColorBox(this);
			fc->Top = rect.top;
			fc->Left = 200;
			fc->Width = 100;
			fc->ItemHeight = 11;
			fc->BevelOuter = bvNone;
			fc->Selected = clBackground;
			sprintf(name,"N%05d%d",i,2);
			fc->Name = name;
			if(_layers->at(i)->getFillColor(color))
				fc->Selected = (TColor)RGB(color.r,color.g,color.b);

			fc->OnSelect = ColorBox1Select;
			fc->OnDropDown = ColorBox1DropDown;

			fc->Parent = ListView1;
			fc->Style = style;

			for(int i=0 ; i<256; i++) {
				char str[255];
				sprintf(str,"%d",i);
				fc->AddItem(str,(TObject*)(TColor)RGB(dxfColors[i][0]*255,dxfColors[i][1]*255,dxfColors[i][2]*255));
			}


			_Colors.push_back(fc);

			//
			TTrackBar *fa = new TTrackBar(this);

			fa->Top = rect.top;
			fa->Left = 260;
			fa->Width = 60;
			fa->Height = 16;
			fa->Max = 255;
			fa->ShowSelRange = false;
			fa->TabOrder = 1;
			fa->TabStop = false;
			fa->ThumbLength = 14;

			fa->Parent = ListView1;

			fa->TickMarks = tmBoth;
			fa->TickStyle = tsNone;
			sprintf(name,"T%05d%d",i,2);
			fa->Name = name;
			fa->Position = 255;
			fa->Brush->Color = clWhite;
			if(_layers->at(i)->getFillColor(color)) fa->Position = color.a;

			fa->OnChange = TrackBar1Change;


			_alphas.push_back(fa);

            ////--

		}

		char str[MAX_PATH];
		sprintf(str,"%d",_layers->size());
		StatusBar1->Panels->operator [](1)->Text = str;
	}
	ListView1->Visible = true;



}