コード例 #1
0
ファイル: ColumnListView.cpp プロジェクト: mariuz/haiku
bool ColumnListView::RemoveColumn(CLVColumn* Column)
//Removes a CLVColumn from the ColumnListView.  Returns true if successful.
{
	if(!fColumnList.HasItem(Column))
		return false;
	int32 ColumnIndex = fSortKeyList.IndexOf(Column);
	if(ColumnIndex >= 0)
		fSortKeyList.RemoveItem(ColumnIndex);
		
	if(Column->fFlags & CLV_EXPANDER)
		fExpanderColumn = -1;

	BWindow* ParentWindow = Window();
	if(ParentWindow)
		ParentWindow->Lock();
	//Remove Column from the column and display lists
	fColumnDisplayList.RemoveItem(Column);
	fColumnList.RemoveItem(Column);

	//Tell the column it has been removed
	Column->fParent = NULL;

	//Set the scroll bars and tell views to update
	ColumnsChanged();
	if(ParentWindow)
		ParentWindow->Unlock();
	return true;
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: Zanet/GameOfLife
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QFont f("Helvetica",10);
    this->setFont(f);

    LifeField = 0;
    OptionGroup = 0;
    GroupLayout = 0;
    isSimulationOn = false;
    LifeCount = 0;
    IterationCount = 0;


    WindowLayout= new QHBoxLayout;

    QWidget * mycentralwidget = new QWidget;
    mycentralwidget->setLayout(WindowLayout);

    this->setCentralWidget(mycentralwidget);
    this->setWindowTitle("Gra w Życie");

    connect(this, SIGNAL(CellsChanged(int,int)), &Algorithm, SLOT(NewDimension(int,int)));
    connect(&Algorithm, SIGNAL(CellChanged(int,int,bool)),this, SLOT(FeedCell(int,int,bool)));
    connect(&Algorithm, SIGNAL(ChangeStatus(int,int)), this, SLOT(StatusUpdate(int,int)));
    connect(this, SIGNAL(CellsChanged(int,int,bool)), &Algorithm, SLOT(CellModified(int,int,bool)));
    connect(this, SIGNAL(FeedsChanger(int)), &Algorithm, SLOT(FeedsStatus(int)));
    //connect(&Algorithm, SIGNAL(Clear()),this, SLOT(CleanNow()));

    InitLifeField();
    InitGroupBox();
    RowsChanged();
    ColumnsChanged();


this->setMinimumSize(700, 480);

    connect(ColumnChanger, SIGNAL(valueChanged(int)), this, SLOT(ColumnsChanged()));
    connect(RowChanger, SIGNAL(valueChanged(int)), this, SLOT(RowsChanged()));
    connect(Quiter, SIGNAL(clicked()), qApp, SLOT(quit()));
    connect(Generator, SIGNAL(clicked()),this, SLOT(GenerateField()) );
    connect(Cleaner, SIGNAL(clicked()),this, SLOT(CleanNow()));
    connect(LifeField, SIGNAL(cellClicked(int, int)), this, SLOT(FeedCell(int, int)));
    connect(Starter,SIGNAL(clicked()),this ,SLOT(SimulationTrigger()));
    connect(OneMove,SIGNAL(clicked()),&Algorithm ,SLOT(SingleStep()));
    connect(comboBox, SIGNAL(activated(QString)), this, SLOT(Prepared(QString)));

    connect(this,SIGNAL(StartSimulation()), &Algorithm, SLOT(SetTimer()));
    connect(this, SIGNAL(StopSimulation()),&Algorithm, SLOT(StopTimer()));


    qsrand(QTime::currentTime().msecsTo(QTime(0,0,0,0)));

}
コード例 #3
0
ファイル: ColumnListView.cpp プロジェクト: mariuz/haiku
bool ColumnListView::RemoveColumns(CLVColumn* Column, int32 Count)
//Finds Column in ColumnList and removes Count columns and their data from the view and its items
{
	BWindow* ParentWindow = Window();
	if(ParentWindow)
		ParentWindow->Lock();
	int32 ColumnIndex = fColumnList.IndexOf(Column);
	if(ColumnIndex < 0)
	{
		if(ParentWindow)
			ParentWindow->Unlock();
		return false;
	}
	if(ColumnIndex + Count >= fColumnList.CountItems())
	{
		if(ParentWindow)
			ParentWindow->Unlock();
		return false;
	}

	//Remove columns from the column and display lists
	for(int32 Counter = ColumnIndex; Counter < ColumnIndex+Count; Counter++)
	{
		CLVColumn* ThisColumn = (CLVColumn*)fColumnList.ItemAt(Counter);
		fColumnDisplayList.RemoveItem(ThisColumn);

		int32 SortIndex = fSortKeyList.IndexOf(Column);
		if(SortIndex >= 0)
			fSortKeyList.RemoveItem(SortIndex);

		if(ThisColumn->fFlags & CLV_EXPANDER)
			fExpanderColumn = -1;

		//Tell the column it has been removed
		ThisColumn->fParent = NULL;
	}
	fColumnList.RemoveItems(ColumnIndex,Count);

	//Set the scroll bars and tell views to update
	ColumnsChanged();
	if(ParentWindow)
		ParentWindow->Unlock();
	return true;
}
コード例 #4
0
ファイル: ColumnTree.cpp プロジェクト: mikekov/ExifPro
void ColumnTree::TreeDoDataExchange(CDataExchange* DX, UINT id)
{
	DDX_Control(DX, id, tree_wnd_);

	if (columns_ == 0)
		return;

	if (DX->m_bSaveAndValidate)
	{
		selected_.clear();
		selected_.reserve(10);

		// store selected columns

		for (Map::const_iterator it= leaves_.begin(); it != leaves_.end(); ++it)
			if (tree_wnd_.GetCheck(it->second) != 0)
				selected_.push_back(it->first);

		changed_ = ColumnsChanged();
	}
}
コード例 #5
0
ファイル: ColumnListView.cpp プロジェクト: mariuz/haiku
bool ColumnListView::SetDisplayOrder(const int32* ColumnOrder)
//Sets the display order using a BList of CLVColumn's
{
	BWindow* ParentWindow = Window();
	if(ParentWindow)
		ParentWindow->Lock();
	//Add the items to the display list in order
	fColumnDisplayList.MakeEmpty();
	int32 ColumnsToSet = fColumnList.CountItems();
	for(int32 Counter = 0; Counter < ColumnsToSet; Counter++)
	{
		if(ColumnOrder[Counter] >= ColumnsToSet)
		{
			if(ParentWindow)
				ParentWindow->Unlock();
			return false;
		}
		for(int32 Counter2 = 0; Counter2 < Counter; Counter2++)
			if(ColumnOrder[Counter] == ColumnOrder[Counter2])
			{
				if(ParentWindow)
					ParentWindow->Unlock();
				return false;
			}
		fColumnDisplayList.AddItem(fColumnList.ItemAt(ColumnOrder[Counter]));
	}

	//Update everything about the columns
	ColumnsChanged();

	//Let the program know that the display order changed.
	if(ParentWindow)
		ParentWindow->Unlock();
	DisplayOrderChanged(ColumnOrder);
	return true;
}
コード例 #6
0
ファイル: ColumnListView.cpp プロジェクト: mariuz/haiku
bool ColumnListView::AddColumnList(BList* NewColumns)
//Adds a BList of CLVColumn's to the ColumnListView at the position specified, or at the end of the list
//if AtIndex == -1.  Returns true if successful.
{
	int32 NumberOfColumns = int32(fColumnList.CountItems());
	int32 NumberOfColumnsToAdd = int32(NewColumns->CountItems());

	//Make sure a second CLVExpander is not being added
	int32 Counter;
	int32 NumberOfExpanders = 0;
	for(Counter = 0; Counter < NumberOfColumns; Counter++)
		if(((CLVColumn*)fColumnList.ItemAt(Counter))->fFlags & CLV_EXPANDER)
			NumberOfExpanders++;
	int32 SetfExpanderColumnTo = -1;
	for(Counter = 0; Counter < NumberOfColumnsToAdd; Counter++)
	{
		CLVColumn* ThisColumn = (CLVColumn*)NewColumns->ItemAt(Counter);
		if(ThisColumn->fFlags & CLV_EXPANDER)
		{
			NumberOfExpanders++;
			if(ThisColumn->IsShown())
				SetfExpanderColumnTo = NumberOfColumns + Counter;
		}
	}
	if(NumberOfExpanders != 0 && !fHierarchical)
		return false;
	if(NumberOfExpanders > 1)
		return false;
	if(SetfExpanderColumnTo != -1)
		fExpanderColumn = SetfExpanderColumnTo;

	//Make sure none of these columns have already been added to a ColumnListView
	for(Counter = 0; Counter < NumberOfColumnsToAdd; Counter++)
		if(((CLVColumn*)NewColumns->ItemAt(Counter))->fParent != NULL)
			return false;
	//Make sure none of these columns are being added twice
	for(Counter = 0; Counter < NumberOfColumnsToAdd-1; Counter++)
		for(int32 Counter2 = Counter+1; Counter2 < NumberOfColumnsToAdd; Counter2++)
			if(NewColumns->ItemAt(Counter) == NewColumns->ItemAt(Counter2))
				return false;

	BWindow* ParentWindow = Window();
	if(ParentWindow)
		ParentWindow->Lock();
	for(Counter = 0; Counter < NumberOfColumnsToAdd; Counter++)
	{
		CLVColumn* Column = (CLVColumn*)NewColumns->ItemAt(Counter);
		//Check if this should be locked at the beginning or end, and adjust its position if necessary
		int32 DisplayIndex = NumberOfColumns;
		if(!Column->Flags() & CLV_LOCK_AT_END)
		{
			bool Repeat;
			if(Column->Flags() & CLV_LOCK_AT_BEGINNING)
			{
				//Move it to the beginning, after the last CLV_LOCK_AT_BEGINNING item
				DisplayIndex = 0;
				Repeat = true;
				while(Repeat && DisplayIndex < NumberOfColumns)
				{
					Repeat = false;
					CLVColumn* LastColumn = (CLVColumn*)fColumnDisplayList.ItemAt(DisplayIndex);
					if(LastColumn->Flags() & CLV_LOCK_AT_BEGINNING)
					{
						DisplayIndex++;
						Repeat = true;
					}
				}
			}
			else
			{
				//Make sure it isn't after a CLV_LOCK_AT_END item
				Repeat = true;
				while(Repeat && DisplayIndex > 0)
				{
					Repeat = false;
					CLVColumn* LastColumn = (CLVColumn*)fColumnDisplayList.ItemAt(DisplayIndex-1);
					if(LastColumn->Flags() & CLV_LOCK_AT_END)
					{
						DisplayIndex--;
						Repeat = true;
					}
				}
			}
		}

		//Add the column to the display list in the appropriate position
		fColumnDisplayList.AddItem(Column, DisplayIndex);

		//Tell the column it belongs to me now
		Column->fParent = this;

		NumberOfColumns++;
	}

	//Add the columns to the end of the column list
	fColumnList.AddList(NewColumns);

	//Set the scroll bars and tell views to update
	ColumnsChanged();
	if(ParentWindow)
		ParentWindow->Unlock();
	return true;
}
コード例 #7
0
ファイル: ColumnListView.cpp プロジェクト: mariuz/haiku
bool ColumnListView::AddColumn(CLVColumn* Column)
//Adds a column to the ColumnListView at the end of the list.  Returns true if successful.
{
	int32 NumberOfColumns = fColumnList.CountItems();
	int32 DisplayIndex = NumberOfColumns;

	//Make sure a second Expander is not being added
	if(Column->fFlags & CLV_EXPANDER)
	{
		if(!fHierarchical)
			return false;
		for(int32 Counter = 0; Counter < NumberOfColumns; Counter++)
			if(((CLVColumn*)fColumnList.ItemAt(Counter))->fFlags & CLV_EXPANDER)
				return false;
		if(Column->IsShown())
			fExpanderColumn = NumberOfColumns;
	}

	//Make sure this column hasn't already been added to another ColumnListView
	if(Column->fParent != NULL)
		return false;

	BWindow* ParentWindow = Window();
	if(ParentWindow)
		ParentWindow->Lock();
	//Check if this should be locked at the beginning or end, and adjust its position if necessary
	if(!Column->Flags() & CLV_LOCK_AT_END)
	{
		bool Repeat;
		if(Column->Flags() & CLV_LOCK_AT_BEGINNING)
		{
			//Move it to the beginning, after the last CLV_LOCK_AT_BEGINNING item
			DisplayIndex = 0;
			Repeat = true;
			while(Repeat && DisplayIndex < NumberOfColumns)
			{
				Repeat = false;
				CLVColumn* LastColumn = (CLVColumn*)fColumnDisplayList.ItemAt(DisplayIndex);
				if(LastColumn->Flags() & CLV_LOCK_AT_BEGINNING)
				{
					DisplayIndex++;
					Repeat = true;
				}
			}
		}
		else
		{
			//Make sure it isn't after a CLV_LOCK_AT_END item
			Repeat = true;
			while(Repeat && DisplayIndex > 0)
			{
				Repeat = false;
				CLVColumn* LastColumn = (CLVColumn*)fColumnDisplayList.ItemAt(DisplayIndex-1);
				if(LastColumn->Flags() & CLV_LOCK_AT_END)
				{
					DisplayIndex--;
					Repeat = true;
				}
			}
		}
	}

	//Add the column to the display list in the appropriate position
	fColumnDisplayList.AddItem(Column, DisplayIndex);

	//Add the column to the end of the column list
	fColumnList.AddItem(Column);

	//Tell the column it belongs to me now
	Column->fParent = this;

	//Set the scroll bars and tell views to update
	ColumnsChanged();
	if(ParentWindow)
		ParentWindow->Unlock();
	return true;
}