Пример #1
0
 void ColorMapGridControl::OnPopupCommand(UINT nMenuID)
 {
     switch (nMenuID) {
     case WM_INSERT_ROW_BEFORE: {
         InsertRow(m_nCurrRow);
         break;
     }
     case WM_INSERT_ROW_AFTER: {
         InsertRow(m_nCurrRow + 1);
         break;
     }
     case WM_DELETE_ROW: {
         DeleteRow(m_nCurrRow);
         break;
     }
     case WM_COPYFROMCLIPBOARD: {
         CopyFromClipboardTable(m_nCurrRow);
         break;
     }
     default:
         ASSERT(0);
         break;
     }
     UpdateModifiedRows();
 }
void
nsTreeContentView::InsertRowFor(nsIContent* aParent, nsIContent* aChild)
{
  int32_t grandParentIndex = -1;
  bool insertRow = false;

  nsCOMPtr<nsIContent> grandParent = aParent->GetParent();
  nsIAtom* grandParentTag = grandParent->Tag();

  if (grandParent->IsXUL() && grandParentTag == nsGkAtoms::tree) {
    // Allow insertion to the outermost container.
    insertRow = true;
  }
  else {
    // Test insertion to an inner container.

    // First try to find this parent in our array of rows, if we find one
    // we can be sure that all other parents are open too.
    grandParentIndex = FindContent(grandParent);
    if (grandParentIndex >= 0) {
      // Got it, now test if it is open.
      if (mRows[grandParentIndex]->IsOpen())
        insertRow = true;
    }
  }

  if (insertRow) {
    int32_t index = 0;
    GetIndexInSubtree(aParent, aChild, &index);

    int32_t count = InsertRow(grandParentIndex, index, aChild);
    if (mBoxObject)
      mBoxObject->RowCountChanged(grandParentIndex + index + 1, count);
  }
}
Пример #3
0
    void ColorMapGridControl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
    {
        m_nCurrRow = m_cellActive.m_nRow - 1;
        if (m_nCurrRow >= 0)
            {
                bool bOpDone = false;
                switch (nChar)
                    {
                    case VK_DELETE: {
                        DeleteRow(m_nCurrRow);
                        bOpDone = true;
                        break;
                    }
                    case VK_INSERT: {
                        InsertRow(m_nCurrRow);
                        bOpDone = true;
                        break;
                    }
                    default: {
                        break;
                    }
                    }

                if (bOpDone)
                    {
                        UpdateModifiedRows();
                        return;
                    }
            }

        CGridCtrlCell::OnKeyDown(nChar, nRepCnt, nFlags);
    }
Пример #4
0
// 添加行
int CDuiGridCtrl::InsertRow(int nRow, CString strId, int nImageIndex, Color clrText, CString strImage,
							 int nRightImageIndex, CString strRightImage, int nCheck)
{
	GridRowInfo rowInfo;
	rowInfo.strId = strId;
	rowInfo.nCheck = nCheck;
	rowInfo.nImageIndex = nImageIndex;
	rowInfo.sizeImage.SetSize(0, 0);
	rowInfo.nRightImageIndex = nRightImageIndex;
	rowInfo.sizeRightImage.SetSize(0, 0);
	rowInfo.bRowColor = FALSE;
	rowInfo.clrText = clrText;
	rowInfo.nHoverItem = -1;
	if(clrText.GetValue() != Color(0, 0, 0, 0).GetValue())
	{
		rowInfo.bRowColor = TRUE;
	}

	// 左边图片
	if(!strImage.IsEmpty())
	{
		// 使用行数据指定的图片
		if(DuiSystem::Instance()->LoadImageFile(strImage, m_bImageUseECM, rowInfo.pImage))
		{
			rowInfo.sizeImage.SetSize(rowInfo.pImage->GetWidth() / 1, rowInfo.pImage->GetHeight());
		}
	}else
	{
		// 使用索引图片
		rowInfo.pImage = NULL;
		if((rowInfo.nImageIndex != -1) && (m_pImage != NULL) && (m_pImage->GetLastStatus() == Ok))
		{
			rowInfo.sizeImage.SetSize(m_sizeImage.cx, m_sizeImage.cy);
		}
	}

	// 右边图片
	if(!strRightImage.IsEmpty())
	{
		// 使用行数据指定的图片
		if(DuiSystem::Instance()->LoadImageFile(strRightImage, m_bImageUseECM, rowInfo.pRightImage))
		{
			rowInfo.sizeRightImage.SetSize(rowInfo.pRightImage->GetWidth() / 1, rowInfo.pRightImage->GetHeight());
		}
	}else
	{
		// 使用索引图片
		rowInfo.pRightImage = NULL;
		if((rowInfo.nRightImageIndex != -1) && (m_pImage != NULL) && (m_pImage->GetLastStatus() == Ok))
		{
			rowInfo.sizeRightImage.SetSize(m_sizeImage.cx, m_sizeImage.cy);
		}
	}

	return InsertRow(nRow, rowInfo);
}
Пример #5
0
// line 1 - TOOL (start of tool definition)
// line 2 - tool material (1-HSS, 2-CARBIDE, 3-COATED CAR, 4-CERAMIC, 5-BORZON, 10-UNKNOWN)
// line 3 - tool comment
// line 4 - tool name (geometry reference for backplot)
// line 5 - tool manufacturer
// line 6 - chuck designation
// line 7 - tool_no, tool_type, rad_type, dia, crad, thds, tip_angle,
//         dia_off, len_off, feed, plunge, retract, rpm, coolant, n_flutes
// line 8 - Drilling attributes (see tool_type in line 7 above)
// line 8 - cycle, peck1, peck2, peck_clr, chip_brk, dwell, shldr_angle, root_dia (tap), bore_shift
// line 8 - Milling attributes (see tool_type in line 7 above)
// line 8 - cut_able, rgh_x, rgh_z, fin_x, fin_z, tip_dia, root_dia (thd mill), thd_angle
// line 9 - pilot_dia, flute_len, oa_len, shldr_len, arbor_dia, hldr_dia, hldr_len, spindle_ccw, sfm, fpt, metric
HRESULT CDBStepNC::LoadMasterCAMTool(CString filename)
{
    CString contents = ReadAFile(filename);
    if(contents.GetLength()< 1)
        return E_INVALIDARG;
    CStringVector lines = CStringVector::Tokenize(contents, "\n");
    CStringVector columns;
    columns.push_back("toolid");
    columns.push_back("name");
    columns.push_back("tooltypeid");
    columns.push_back("materialid");
    columns.push_back("number_of_teeth");
    columns.push_back("hand_of_cut");
    columns.push_back("coolant_through_tool");
    columns.push_back("cutting_edge_length");
    columns.push_back("flute_length");
    columns.push_back("overall_length");
    columns.push_back("shoulder_length");
    columns.push_back("tip_diameter");
    columns.push_back("tool_tip_half_angle");
    columns.push_back("sfm");
    columns.push_back("fpt");
    columns.push_back("metric");

    CStringVector values;
    values.resize(16);
    for(int i=40, j=1; i< lines.size(); i+=10, j++)
    {
        CStringVector items1 = CStringVector::Tokenize(lines[i+1]," ");
        CStringVector items2 = CStringVector::Tokenize(lines[i+2]," ");
        CStringVector items3 = CStringVector::Tokenize(lines[i+3]," ");
        CStringVector items7 = CStringVector::Tokenize(lines[i+7]," ");
        CStringVector items8 = CStringVector::Tokenize(lines[i+8]," ");
        CStringVector items9 = CStringVector::Tokenize(lines[i+9]," ");
        values[0] =StrFormat("%d", j); //                  toolid
        values[1]=lines[i+3].Mid(lines[i+3].Find("-")+1).Trim();	// name
        values[2]=items7[3].Trim();	// tooltypeid
        values[3]=items2[2].Trim();	// materialid
        values[4]= items7[16].Trim();             //  number_of_teeth
        values[5]= (items9[9] ==1) ? "LEFT" : "RIGHT";    //  hand_of_cut
        values[6]= items7[15];             //  coolant_through_tool
        values[7]= items9[3];             //  cutting_edge_length
        values[8]= items9[3];             //  flute_length
        values[9]= items7[10];             //  overall_length
        values[10]= items9[5];             //  shoulder_length
        values[11]= items7[5];             //  tip_diameter
        values[12]= items7[8];             //  tool_tip_half_angle
        values[13]= items9[10];             //  sfm
        values[14]= items9[11];             //  fpt
        values[15]= items9[12].Trim();             //  metric
        InsertRow("milling_cutter", columns, values);
    }
    return S_OK;
}
void
GRaggedFloatTableData::InsertRows
	(
	const JIndex				index,
	const JSize 				count,
	const JOrderedSet<JFloat>*	initData
	)
{
	for (JIndex i = 0; i < count; i++)
		{
		InsertRow(i + index, initData);
		}
}
Пример #7
0
//---------------------------------------------------------------
// pt_AddPeriodic button event
//---------------------------------------------------------------
void PeriodicalTranDialog::pt_AddPeriodic_clicked(wxCommandEvent &event)
{
	ipt_dialog->ClearControl();
	ipt_dialog->CenterOnParent();
	if (ipt_dialog->ShowModal() == input_ptran_ok) {
		DB_periodical newrow = ipt_dialog->GetData_Periodical();
		newrow.SetFlag(add_mt);
		dbperiod.Add(newrow);
		//for Control
		wxString arr[5];
		//---set timing
		if (newrow.GetTiming() < 2) {
			arr[0] = GetTimingString(newrow.GetTiming()) +
				StrF(_T(": %d %s"),newrow.GetTimingDay(),_("-th day"));
		}else{
			arr[0] = GetTimingString(newrow.GetTiming());
		}
		//---set account
		arr[1] = wxGetApp().AppDB.GetAccount(newrow.GetBudget().GetHandling()).GetName();
		//---set expense and item of expense
		wxString sql = StrF(WXSQL_GET_EXPENSE_AND_ITEM,
			newrow.GetBudget().GetExpense(),newrow.GetBudget().GetItems());
		wxSQLite3ResultSet rset = wxGetApp().SQLDB().ExecuteQuery(sql);
		while (rset.NextRow()) {
			arr[2] = rset.GetString(0) + _T(", ") +
				rset.GetString(1);
		}
		//---set income or expenditure
		if (newrow.GetBudget().GetIncome() > 0) {
			arr[3] = IntToStr(newrow.GetBudget().GetIncome());
		}else if (newrow.GetBudget().GetExpenditure() > 0) {
			arr[3] = IntToStr(newrow.GetBudget().GetExpenditure());
		}else{
			arr[3] = _T("0");
		}
		//---set memo
		arr[4] = newrow.GetBudget().GetMemo();

		InsertRow(pt_PeriodicalList,arr,5);

	}
}
Пример #8
0
//---------------------------------------------------------------
// bind window data and DB data
//---------------------------------------------------------------
void PeriodicalTranDialog::BindData_Periodical(DBL_periodical &db)
{
	wxString timing_items[] = {
		_("Indicated ordered day of week"),_("Indicated ordered day of month"),
		_("last day of month")
	};
	dbperiod = db;
	//insert DB data in listctrl
	pt_PeriodicalList->DeleteAllItems();
	for (int i = 0; i < (int)dbperiod.GetCount(); i++) {
		if (dbperiod.Item(i).GetTiming() == 3) continue;
		wxString arr[5];
		//---set timing
		if (dbperiod.Item(i).GetTiming() < 2) {
			arr[0] = GetTimingString(dbperiod.Item(i).GetTiming()) +
				StrF(_T(": %d %s"),dbperiod.Item(i).GetTimingDay(),_("-th day"));
		}else{
			arr[0] = timing_items[dbperiod.Item(i).GetTiming()];
		}
		//---set account
		arr[1] = wxGetApp().AppDB.GetAccount(dbperiod.Item(i).GetBudget().GetHandling()).GetName();
		//---set expense and item of expense
		wxString sql = StrF(_T("select ex_name, it_name from db_expense, db_items where ex_id = %d and it_id = %d and ex_id = it_expense;"),
			dbperiod.Item(i).GetBudget().GetExpense(),dbperiod.Item(i).GetBudget().GetItems());
		wxSQLite3ResultSet rset = wxGetApp().SQLDB().ExecuteQuery(sql);
		while (rset.NextRow()) {
			arr[2] = rset.GetString(0) + _T(", ") +
				rset.GetString(1);
		}
		//---set income or expenditure
		if (dbperiod.Item(i).GetBudget().GetIncome() > 0) {
			arr[3] = IntToStr(dbperiod.Item(i).GetBudget().GetIncome());
		}else if (dbperiod.Item(i).GetBudget().GetExpenditure() > 0) {
			arr[3] = IntToStr(dbperiod.Item(i).GetBudget().GetExpenditure());
		}else{
			arr[3] = _T("0");
		}
		//---set memo
		arr[4] = dbperiod.Item(i).GetBudget().GetMemo();
		InsertRow(pt_PeriodicalList,arr,5);
	}
}
Пример #9
0
void GMassMobAppearGrid::LoadParse(GStageLevel* pStage)
{
	CGridCellBase* cell =  NULL;
	GtLongNumberString num;
	for( gtuint i = 0 ; i < pStage->GetMassAppearMobCount() ; i++ )
	{
		InsertRow();
		GStageLevel::MassAppearMob& mob = pStage->GetMassAppearMob( i );

		num.SetNumber( (glong)mob.mIndex );
		SetItemText( i + 1, 0, num.c_str() );

		num.SetNumber( (glong)mob.mLevel );
		SetItemText( i + 1, 1, num.c_str() );

		num.SetNumber( (glong)mob.mNumLine );
		SetItemText( i + 1, 2, num.c_str() );

		num.SetNumber( (glong)mob.mNumMobCount );
		SetItemText( i + 1, 3, num.c_str() );
	}
}
Пример #10
0
void OOPLyric::InsertBlankLines() {
    wxASSERT(IsOk());

    int shownItems = GetShownItems() - GetShownItemsAddin();
    int numBlankLinesTop = shownItems / 2;
    int numBlankLinesBottom = shownItems - numBlankLinesTop;

    int delta = m_blankLinesTop + m_blankLinesBottom -
                numBlankLinesTop - numBlankLinesBottom;

    if (delta > 0) {
        int numLinesToDelete = m_blankLinesTop - numBlankLinesTop;
        for (int i = 0; i < numLinesToDelete; i++) {
            RemoveRow(0, false, NULL);
        }

        numLinesToDelete = m_blankLinesBottom - numBlankLinesBottom;
        for (int i = 0; i < numLinesToDelete; i++) {
            RemoveRow(GetRowCount() - 1, false, NULL);
        }
    } else if (delta < 0) {
        wxString blankLine(wxEmptyString);

        int numNewLines = numBlankLinesTop - m_blankLinesTop;
        for (int i = 0; i < numNewLines; i++) {
            InsertRow(0, blankLine, false);
        }

        numNewLines = numBlankLinesBottom - m_blankLinesBottom;
        for (int i = 0; i < numNewLines; i++) {
            Append(blankLine, false);
        }
    }

    m_blankLinesTop = numBlankLinesTop;
    m_blankLinesBottom = numBlankLinesBottom;

    UpdateVirtualHeight();
}
Пример #11
0
// copy source_row to dest_row and expand grid by 1 row
void __fastcall TColourStringGrid::CopyRow(int source_row, int dest_row)
{
	   if(source_row < FixedRows || source_row >= FRowCount)
			return;

	   if(dest_row < FixedRows || dest_row >= FRowCount)
			return;

       InsertRow(dest_row);

       if(source_row < dest_row)
       {
            for(int cols = FixedCols; cols < FColCount; cols++)
            {
              Cells[cols][dest_row] = Cells[cols][source_row];

              if(theColourGrid[cols][source_row])
              {
                theColourGrid[cols][dest_row] =
                    (int)new CellProperties(*(CellProperties*)theColourGrid[cols][source_row]);

              }
            }
       }
       else
       {
            for(int cols = FixedCols; cols < FColCount; cols++)
            {
              Cells[cols][dest_row] = Cells[cols][source_row + 1];

              if(theColourGrid[cols][source_row + 1])
              {
                theColourGrid[cols][dest_row] =
                    (int)new CellProperties(*(CellProperties*)theColourGrid[cols][source_row + 1]);
              }
            }
        }
}
Пример #12
0
void ViewTable::loadData(const QString &str)
{
	Clear();

	if( str.isNull() || str.isEmpty() )
		return;

	QStringList list = str.split("\n");
	for(int i = 0; i < list.count(); i++)
	{
		QStringList t = list.at(i).split("\t");
		if( t.count() < columnCount() )
			continue;

		InsertRow(i);

		for(int j = 0; j < t.count(); j++)
		{
			bool ok = false;
			int k = 0;
			for(k = 0; k < sconvList.count(); k++)
			{
				if( sconvList.at(k).column == j )
				{
					ok = true;
					break;
				}
			}

			if( !ok )
				continue;
			t[j] = SConvert::convertString( sconvList[k].type, t[j] );
		}

		setRowText(i, t);
	}
}
Пример #13
0
// 加载XML节点,解析节点中的属性信息设置到当前控件的属性中
BOOL CDuiGridCtrl::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl)
{
	if(!__super::Load(pXmlElem))
	{
		return FALSE;
	}

    // 使用XML节点初始化div控件
	if(pXmlElem != NULL)
	{
		InitUI(m_rc, pXmlElem);
	}

	// 加载下层的cloumn节点信息
	for (DuiXmlNode pColumnElem = pXmlElem.child(_T("column")); pColumnElem; pColumnElem=pColumnElem.next_sibling(_T("column")))
	{
		CString strTitle = pColumnElem.attribute(_T("title")).value();
		CString strClrText = pColumnElem.attribute(_T("crtext")).value();
		CString strWidth = pColumnElem.attribute(_T("width")).value();
		CString strAlign = pColumnElem.attribute(_T("align")).value();
		CString strVAlign = pColumnElem.attribute(_T("valign")).value();
		DuiSystem::Instance()->ParseDuiString(strTitle);
		Color clrText = Color(0, 0, 0, 0);
		if(!strClrText.IsEmpty())
		{
			clrText = CDuiObject::StringToColor(strClrText);
		}
		int nWidth = -1;
		if(!strWidth.IsEmpty())
		{
			nWidth = _ttoi(strWidth);
		}
		UINT uAlignment = 0xFFFFUL;
		if(strAlign == _T("left"))
		{
			uAlignment = Align_Left;
		}else
		if(strAlign ==_T("center"))
		{
			uAlignment = Align_Center;
		}else
		if(strAlign == _T("right"))
		{
			uAlignment = Align_Right;
		}
		UINT uVAlignment = 0xFFFFUL;
		if(strVAlign == _T("top"))
		{
			uVAlignment = VAlign_Top;
		}else
		if(strVAlign == _T("middle"))
		{
			uVAlignment = VAlign_Middle;
		}else
		if(strVAlign == _T("bottom"))
		{
			uVAlignment = VAlign_Bottom;
		}
		InsertColumn(-1, strTitle, nWidth, clrText, uAlignment, uVAlignment);
	}

	// 加载下层的row节点信息
	for (DuiXmlNode pRowElem = pXmlElem.child(_T("row")); pRowElem; pRowElem=pRowElem.next_sibling(_T("row")))
	{
		CString strId = pRowElem.attribute(_T("id")).value();
		CString strCheck = pRowElem.attribute(_T("check")).value();
		CString strImage = pRowElem.attribute(_T("image")).value();
		CString strRightImage = pRowElem.attribute(_T("right-img")).value();
		CString strClrText = pRowElem.attribute(_T("crtext")).value();

		int nCheck = -1;
		if(!strCheck.IsEmpty())
		{
			nCheck = _ttoi(strCheck);
		}

		// 左边图片,通过Skin读取
		CString strSkin = _T("");
		if(strImage.Find(_T("skin:")) == 0)
		{
			strSkin = DuiSystem::Instance()->GetSkin(strImage);
		}else
		{
			strSkin = strImage;
		}

		int nImageIndex = -1;
		strImage = _T("");
		if(strSkin.Find(_T(".")) != -1)
		{
			// 图片文件
			strImage = strSkin;
		}else
		if(!strSkin.IsEmpty())
		{
			// 图片索引
			nImageIndex = _ttoi(strSkin);
		}

		// 右边图片,通过Skin读取
		CString strRightSkin = _T("");
		if(strRightImage.Find(_T("skin:")) == 0)
		{
			strRightSkin = DuiSystem::Instance()->GetSkin(strRightImage);
		}else
		{
			strRightSkin = strRightImage;
		}

		int nRightImageIndex = -1;
		strRightImage = _T("");
		if(strRightSkin.Find(_T(".")) != -1)
		{
			// 图片文件
			strRightImage = strRightSkin;
		}else
		if(!strRightSkin.IsEmpty())
		{
			// 图片索引
			nRightImageIndex = _ttoi(strRightSkin);
		}

		Color clrText = CDuiObject::StringToColor(strClrText);

		InsertRow(-1, strId, nImageIndex, clrText, strImage, nRightImageIndex, strRightImage, nCheck);

		int nRowIndex = m_vecRowInfo.size()-1;
		int nItemIndex = 0;
		// 加载下层的item节点信息
		for (DuiXmlNode pItemElem = pRowElem.child(_T("item")); pItemElem; pItemElem=pItemElem.next_sibling(_T("item")))
		{
			CString strTitle = pItemElem.attribute(_T("title")).value();
			CString strContent = pItemElem.attribute(_T("content")).value();
			CString strClrText = pItemElem.attribute(_T("crtext")).value();
			CString strImage = pItemElem.attribute(_T("image")).value();
			CString strLink = pItemElem.attribute(_T("link")).value();
			CString strLinkAction = pItemElem.attribute(_T("linkaction")).value();
			CString strFontTitle = pItemElem.attribute(_T("font-title")).value();
			DuiSystem::Instance()->ParseDuiString(strTitle);
			DuiSystem::Instance()->ParseDuiString(strContent);
			DuiSystem::Instance()->ParseDuiString(strLink);
			DuiSystem::Instance()->ParseDuiString(strLinkAction);
			Color clrText = CDuiObject::StringToColor(strClrText);

			// 图片,通过Skin读取
			CString strSkin = _T("");
			if(strImage.Find(_T("skin:")) == 0)
			{
				strSkin = DuiSystem::Instance()->GetSkin(strImage);
			}else
			{
				strSkin = strImage;
			}

			int nImageIndex = -1;
			strImage = _T("");
			if(strSkin.Find(_T(".")) != -1)
			{
				// 图片文件
				strImage = strSkin;
			}else
			if(!strSkin.IsEmpty())
			{
				// 图片索引
				nImageIndex = _ttoi(strSkin);
			}

			BOOL bUseTitleFont = (strFontTitle == _T("1"));

			if(!strLink.IsEmpty())
			{
				SetSubItemLink(nRowIndex, nItemIndex, strLink, strLinkAction, nImageIndex, clrText, strImage);
			}else
			{
				SetSubItem(nRowIndex, nItemIndex, strTitle, strContent, bUseTitleFont, nImageIndex, clrText, strImage);
			}

			// 加载下层的控件节点信息
			GridItemInfo* pItemInfo = GetItemInfo(nRowIndex, nItemIndex);
			for (DuiXmlNode pControlElem = pItemElem.first_child(); pControlElem; pControlElem=pControlElem.next_sibling())
			{
				if((pControlElem != NULL) && (pItemInfo != NULL))
				{
					CString strControlName = pControlElem.name();
					CControlBase* pControl = _CreateControlByName(strControlName);
					if(pControl)
					{
						pControl->Load(pControlElem);
						pControl->SetVisible(FALSE);
						// 将控件指针添加到gridctrl控件的子控件列表中
						m_vecControl.push_back(pControl);
						// 将控件指针添加到单元格的控件列表中(仅用于按照单元格查找子控件)
						pItemInfo->vecControl.push_back(pControl);
					}
				}
			}

			nItemIndex++;
		}
	}

	// 计算横向滚动条
	CalcColumnsPos();
	// 计算每一行的位置和滚动条
	CalcRowsPos();

    return TRUE;
}