예제 #1
0
//-----------------------------------------------------------------------------
void ObjDetailPGView::OnObjPropBeforeRemove(const IModel& vec, const std::vector<SptrIModel>& remVec)
{
	auto obj_prop_array = mObj->GetObjPropArray();

	auto propCategory = GetProperty("user_obj_prop");
	if (obj_prop_array->GetChildQty() == remVec.size())
	{
		propCategory->DeleteChildren();
	}
	else
	{
		size_t pos = 0;
		for (const auto& remItem : remVec)
		{
			if (vec.GetItemPosition(remItem, pos))
			{
				DeleteProperty(pos);
			}

		}
	}
	if (!propCategory->GetChildCount())
		propCategory->Hide(true);
	else
		propCategory->Hide(false);

}
예제 #2
0
파일: VTable.cpp 프로젝트: alex3696/wh3
//-----------------------------------------------------------------------------
void VTable::OnFieldBeforeRemove(const IModel& vec, const std::vector<SptrIModel>& remVec)
{
	if (!mModel)
		return;
	wxWindowUpdateLocker	wndLockUpdater(this);
	for (const auto& field : remVec)
	{
		size_t model_idx = 0;
		if (vec.GetItemPosition(field, model_idx))
		{
			auto col_idx = GetModelColumnIndex(model_idx);
			auto col = GetColumn(col_idx);
			if (col)
				this->DeleteColumn(col);
		}
	}
}
예제 #3
0
파일: VTable.cpp 프로젝트: alex3696/wh3
//-----------------------------------------------------------------------------
void VTable::OnRowBeforeRemove(const IModel& vec, const std::vector<SptrIModel>& remVec)
{
	wxBusyCursor			busyCursor;
	wxWindowUpdateLocker	wndLockUpdater(this);
	
	if (vec.size() != remVec.size() )
	{
		size_t pos;
		wxArrayInt	itemsArray;
		for (const auto& remItem : remVec)
		{
			if (vec.GetItemPosition(remItem, pos))
				itemsArray.push_back(pos);
		}
		mDataViewModel->RowsDeleted(itemsArray);
	}
	else
		mDataViewModel->Reset(0);
}//OnRemove
예제 #4
0
파일: VTable.cpp 프로젝트: alex3696/wh3
//-----------------------------------------------------------------------------
void VTable::OnRowAfterInsert(const IModel& vec, const std::vector<SptrIModel>& newItems
	, const SptrIModel& itemBefore)
{
	wxBusyCursor			busyCursor;
	wxWindowUpdateLocker	wndLockUpdater(this);

	if (itemBefore)
	{
		size_t pos;
		if (vec.GetItemPosition(itemBefore, pos))
		{
			for (const auto& curr : newItems)
				mDataViewModel->RowInserted(pos++);
		}
	}
	else
	{
		for (const auto& curr : newItems)
			mDataViewModel->RowAppended();
	}
	OnChangeVecState(vec.GetState());
}//OnAppend
예제 #5
0
파일: VTable.cpp 프로젝트: alex3696/wh3
//-----------------------------------------------------------------------------
void VTable::OnFieldAfterInsert(const IModel& vec, const std::vector<SptrIModel>& newItems
	, const SptrIModel& itemBefore)
{
	if (!mModel)
		return;
	wxWindowUpdateLocker	wndLockUpdater(this);
	const auto& fvec = mModel->mFieldVec;
	for (const auto& new_item : newItems)
	{
		size_t model_idx = -1;
		if (vec.GetItemPosition(new_item, model_idx))
		{
			const auto& field = fvec->at(model_idx)->GetData();
			if (field.mGuiShow)
			{
				wxString name = field.mTitle;
				auto width = GetColumnWidthBy(field.mType);

				//auto col = AppendTextColumn(name, model_idx, wxDATAVIEW_CELL_INERT, width,
				//	wxALIGN_NOT, /*wxDATAVIEW_COL_SORTABLE | */wxDATAVIEW_COL_RESIZABLE);

				class wxDataViewMLTextRenderer : public wxDataViewTextRenderer
				{
				public:
					wxDataViewMLTextRenderer(const wxString &  varianttype = wxT("string"), //GetDefaultType(),
						wxDataViewCellMode  mode = wxDATAVIEW_CELL_INERT,
						int  align = wxDVR_DEFAULT_ALIGNMENT )
						:wxDataViewTextRenderer(varianttype, mode, align)
					{}
					void RenderText(const wxString& text,
						int xoffset,
						wxRect rect,
						wxDC *dc,
						int state) override
					{
						wxCoord widthText, heightText, heightLine;
						dc->GetMultiLineTextExtent(text, &widthText, &heightText, &heightLine); 

						if (heightLine && heightText > heightLine)
						{
							int qty = heightText / heightLine -1;
							int rh = GetView()->GetCharHeight() * 2 + 2;
							int max_offset = (rh - heightLine) / 2;
							int calc_offset = qty* (heightLine / 2);
							int curr_offset = (calc_offset > max_offset) ? max_offset : calc_offset;
							rect.y = rect.y - curr_offset;
							rect.height = heightText;
							rect.width = widthText;
						}
						wxDataViewTextRenderer::RenderText(text, xoffset, rect, dc, state);
						/*
						wxRect rectText = rect;
						rectText.x += xoffset;
						rectText.width -= xoffset;

						// check if we want to ellipsize the text if it doesn't fit
						wxString ellipsizedText;
						if (GetEllipsizeMode() != wxELLIPSIZE_NONE)
						{
							ellipsizedText = wxControl::Ellipsize
								(
								text,
								*dc,
								GetEllipsizeMode(),
								rectText.width,
								wxELLIPSIZE_FLAGS_NONE
								);
						}

						// get the alignment to use
						dc->DrawLabel(ellipsizedText.empty() ? text : ellipsizedText,
							rectText, GetEffectiveAlignment());
						*/
					}
					
				};

				auto renderer = new wxDataViewMLTextRenderer();
				if(FieldType::ftText == field.mType)
					renderer->EnableEllipsize(wxELLIPSIZE_START);

				wxDataViewColumn * col = new wxDataViewColumn(name
					, renderer
					, model_idx
					, width
					, wxALIGN_NOT
					, wxDATAVIEW_COL_RESIZABLE);
				this->AppendColumn(col);

				auto col_idx = GetColumnIndex(col);

				if (ftText == field.mType)
					EnableAutosizeColumn(col_idx);

				SetGuiColumnSort(field, col);
			}//if (field.mGuiShow)

		}
	}
}