📄 coldesignations.h
字号:
setDesignation(nRow, nOldDesignation, false);
return false;
}
}
return true;
}
int getColDesignation(int nRow)
{
if(nRow < m_flx.FixedRows)
return -1;
int nDesig = m_flx.RowData(nRow);
return nDesig;
}
// assume vnColDesignations and vnPositions empty on entering function
bool getColDesignations(vector<uint>& vnColDesignations, vector<uint>& vnPositions)
{
int nR1 = m_flx.FixedRows;
int nR2 = m_flx.Rows;
for(int nRow = nR1; nRow < nR2; nRow++)
{
int nDesig = getColDesignation(nRow);//m_flx.RowData(nRow);
vnColDesignations.Add(nDesig);
vnPositions.Add(atoi(GetCell(nRow, m_nIndexCol)));// grid might have been sorted
}
return true;
}
int countDesignations(int nDesig)
{
int nR1 = m_flx.FixedRows;
int nR2 = m_flx.Rows;
int nCount = 0;
for(int nRow = nR1; nRow < nR2; nRow++)
{
if(getColDesignation(nRow) == nDesig)
nCount++;
}
return nCount;
}
int countModifiers()
{
int nR1 = m_flx.FixedRows;
int nR2 = m_flx.Rows;
int nCount = 0;
int nDesig;
for(int nRow = nR1; nRow < nR2; nRow++)
{
nDesig = getColDesignation(nRow);
if(nDesig >= COLDESIG_SIZE)
nCount++;
}
return nCount;
}
void prepareGridColumns()
{
string str = " ";// begin 1st Col with a blank for disregarded col designation
for(int ii = 0; ii < m_vnColDesignations.GetSize(); ii++)
{
str += "|";
str += getColDesignationName(m_vnColDesignations[ii]);
}
m_nRadioColBegin = 0;
m_nRadioColEnd = ii;
int nInfoCol = 1; // offset from current
m_nNameCol = ii + addColHeading(str, nInfoCol++);// there is still that 1st col with disregard
m_nLabelCol = ii + addColHeading(str, nInfoCol++);
m_n1stDataValCol = ii + addColHeading(str, nInfoCol++);
//--CPY 8/6/03 ADD_COL_POSITION_IN_WKS
m_nIndexCol = ii + addColHeading(str, nInfoCol++);
//--
m_flx.FormatString = str;
m_flx.Cols = ii + nInfoCol;
int nCol;
for(nCol = m_nRadioColBegin; nCol <= m_nRadioColEnd; nCol++)
{
m_flx.ColDataType(nCol) = flexDTBoolean;
m_flx.ColAlignment(nCol) = flexAlignCenterCenter;
}
//for(nCol = m_nRadioColEnd+1; nCol <= m_nLabelCol; nCol++)
for(nCol = m_nRadioColEnd+1; nCol <m_flx.Cols; nCol++)
{
m_flx.ColDataType(nCol) = flexDTString;
m_flx.ColAlignment(nCol) = flexAlignLeftCenter;
}
m_flx.ColHidden(m_nRadioColBegin) = true; // Joe etc suggested that disregard radio col can be left out
updateColNameColHeading();
}
//return nTypeEnum
int addColHeading(string& strFormat, int nTypeEnum) // starting from 1
{
strFormat += "|";
switch(nTypeEnum)
{
case INFO_COL_NAME:
strFormat += STR_HEADING_COL;
break;
case INFO_COL_LABEL:
strFormat += _LC("Label", _CAT);
break;
case INFO_COL_INDEX:
strFormat += _LC("Position", _CAT);
break;
case INFO_COL_1ST_DATA:
strFormat += _LC("1st Data Value", _CAT);
break;
default:
ASSERT(FALSE);
break;
}
return nTypeEnum;
}
string getColHeadingTooltips(int nCol);
bool isRowNumber(LPCSTR lpcszColName)
{
return lstrcmpi(lpcszColName, STR_ROW_NUMBER) == 0? true:false;
}
string getColPositionInWks(int nIndex, LPCSTR lpcszColName)
{
string str = nIndex + 1;// 1 offset
//printf("1st wks is %s\n", m_vsPageNames[0]);
Worksheet wks(m_vsPageNames[0]);
if(wks)
{
Column cc = wks.Columns(lpcszColName);
if(cc)
str = cc.GetIndex() + 1; // 1 offset
else if(isRowNumber(lpcszColName))
str = 0;
}
return str;
}
string get1stDataVal(LPCSTR lpcszColName)
{
string str;
Worksheet wks(m_vsPageNames[0]);
if(wks)
{
Column cc = wks.Columns(lpcszColName);
if(cc)
{
int nRow = cc.GetLowerBound();
int nCol = cc.GetIndex();
wks.GetCell(nRow, nCol, str);
}
else if(isRowNumber(lpcszColName))
str = getXFromStepStr();
}
return str;
}
bool isWksColHiddenOrDisregard(LPCSTR lpcszColName)
{
Worksheet wks(m_vsPageNames[0]);
if(wks)
{
Column cc = wks.Columns(lpcszColName);
if(cc)
{
if(cc.Show==0 || cc.GetType() == OKDATAOBJ_DESIGNATION_NONE)
return true;
}
}
return false;
}
//protected:
public:
virtual string GetRuntimeClass()
{
return "ColListControl";
}
virtual int GetDefaultSize(){return 178;}
////------------------ vsFlex events
void OnAfterEdit(Control flxControl, int nRow, int nCol)
{
OnAfterEdit(nRow, nCol);
}
//virtual
void OnAfterEdit(int nRow, int nCol)
{
GridListControl::OnAfterEdit(nRow, nCol);
bool bSetOK = true;
int nVal = m_flx.Cell(flexcpText, nRow, nCol);
if(nVal)
bSetOK = setDesignationRadioChoice(nRow, nCol - m_nRadioColBegin);
else
setDesignationRadioChoice(nRow, 0);// always OK to clear
updateDesigationRadio(nRow);
if(bSetOK)
notifyDlgOnDesignationChanges();
}
void OnBeforeEdit(Control cntrl, long nRow, long nCol, BOOL* pCancel)
{
if(nRow > 0 && nRow == getRowNumberRow())
{
if(nCol == getFromStepColIndex())
{
m_flx.ComboList = "...";
return;
}
//----- CPY 8/17/03 ROW_NUMBER_ROW_IMPROVEMENT CPY 8/17/03 ROW_NUMBER_ROW_ONLY_X_ALLOWED
else if(!isXCol(nCol))// for Row number col, only X is allowed
{
*pCancel = true;
return;
}
//----- end
}
string str = m_flx.ComboList;
if(!str.Empty())
{
str.Empty();
m_flx.ComboList = str;
}
if(nCol < m_nRadioColBegin || nCol > m_nRadioColEnd)
*pCancel = TRUE;
}
void OnButtonClick(Control flxControl, int nRow, int nCol)
{
if(nRow > 0 && nRow == getRowNumberRow() && nCol == getFromStepColIndex())
{
RECT r1;
GetCellRect(nRow, nCol, r1, true, true);
s_nLeft = r1.left + RECT_WIDTH(r1)/2;
s_nTop = r1.top + RECT_HEIGHT(r1)/2;
GETN_BOX(trTemp)
GETN_NUM(xFrom, _LC("X From", _CAT), m_RowNumberXFrom)
GETN_NUM(xStep, _LC("X Step", _CAT), m_RowNumberXStep)
if(GetNBox(trTemp, SCP_DLG_X_ROW_NUM_TITLE, SCP_DLG_X_ROW_NUM_LABEL, NULL, get_n_box_event, GetDlgSafeHwnd()))
{
m_RowNumberXFrom = trTemp.xFrom.dVal;
m_RowNumberXStep = trTemp.xStep.dVal;
updateRowNumberXFromAndStep();
updateColWidths();
}
}
}
// nButton = MK_LBUTTON etc
// nShift = 1 if shift, 0 if not
void OnBeforeMouseDown(Control cntrl, short nButton, short nShift, float X, float Y, BOOL* pCancel);
void OnMouseMove(Control cntrl, short nButton, short nShift, float X, float Y)
{
string strTooltips;
int nRow, nCol;
if(!GetMouseCell(nRow, nCol))
return;
if(!IsColHeadingRow(nRow))
return;
strTooltips = getColHeadingTooltips(nCol);
SetToolTipsText(strTooltips);
}
////------------------
private:
//
void notifyDlgOnDesignationChanges()
{
PostDlgMessage(WM_USER_ON_CONTROL_CHANGE, ON_CONTROL_CHANGE_COL_DESIGNATIONS, 0);
}
void updateWksPageNames(const vector<string>& vsWksPageNames, int nPageType)
{
m_bIsWksPages = m_bIsMatrixPage = m_bIsFunctionPlots = false;
if(EXIST_WKS == nPageType || EXIST_EXTERN_WKS == nPageType)
m_bIsWksPages = true;
else if(EXIST_MATRIX == nPageType)
m_bIsMatrixPage = true;
else if(EXIST_FUNC_PLOT == nPageType)
m_bIsFunctionPlots = true;
// ignore Excel for now, so only one pages
m_vsPageNames = vsWksPageNames;
m_vsLayerNames.SetSize(m_vsPageNames.GetSize());
for(int ii = 0; ii < m_vsLayerNames.GetSize(); ii++)
m_vsLayerNames[ii].Empty();
// only wks page we will remember the page name, all others we will use full dataset names so keep page name empty to indicate such
if(!m_bIsWksPages)
{
for(int ii = 0; ii < m_vsPageNames.GetSize(); ii++)
m_vsPageNames[ii].Empty();
//CPY 8/5/03, we also need to make sure only one, otherwise internal code will generate multiple plots
m_vsPageNames.SetSize(1);
m_vsLayerNames.SetSize(1);
}
updateColNameColHeading();
}
void updateColNameColHeading()
{
if(m_bIsWksPages)
SetColHeading(m_nNameCol, STR_HEADING_COL);
else
SetColHeading(m_nNameCol, STR_HEADING_DATASET);
}
void updateShowWksNames()
{
string str;
for(int ii = 0; ii < m_vsPageNames.GetSize(); ii++)
{
if(ii > 0)
str += " ";
str += m_vsPageNames[ii];
}
m_staticCntrlPageNames.Text = str;
}
bool isKeepColOrder() { return false;} // should be reading from m_dwAuxTypeInfo
string getColDesignationName(int nColDesignation)
{
string str;
char szTemp[50];
if(get_plot_designation_str(nColDesignation, szTemp, 50))
str = szTemp;
return str;
}
int colTypeToColDesignation(int nType) // OKDATAOBJ_DESIGNATION_Y --> COLDESIG_Y
{
int nColDesignation = cvt_col_type_to_designation(nType);
if(isColDesignationInList(nColDesignation))
return nColDesignation;
return COLDESIG_NONE;
}
bool isColDesignationInList(int nColDesignation)
{
for(int ii = 0; ii < m_vnColDesignations.GetSize(); ii++)
{
if(m_vnColDesignations[ii] == nColDesignation)
return true;
}
return false;
}
private:
int m_nRadioColBegin;
int m_nRadioColEnd;
int m_nNameCol;
int m_nLabelCol;
int m_nIndexCol; //CPY 8/6/03 ADD_COL_POSITION_IN_WKS
int m_n1stDataValCol;
DWORD m_dwAuxTypeInfo;
DWORD m_dwAuxPlotInfo;
string m_strColPattern;// "XYY" type of pattern
int m_nYs;// from m_strColPattern, as a cache value, must calll countYs everytime m_strColPattern is changed
int m_nModifiers; // number of needed modifiers
int m_nPlotType;
int m_nMakePlotExVal;
vector<uint> m_vnColDesignations;
vector<string> m_vsLayerNames; // save a local copy
vector<string> m_vsPageNames; // wks pages,
vector<string> m_vsColNames;
vector<string> m_vsColLabels;
double m_RowNumberXFrom;
double m_RowNumberXStep;
bool m_bIsWksPages;
bool m_bIsMatrixPage;
bool m_bIsFunctionPlots;
bool m_bEditMode;
public:
/// main dialog controls that we need to make use for this control
Button m_chkXErrBars;
Button m_chkPosNegErrBars;
Button m_chkAddRowNumX;
Button m_chkShowAllCols;
private:
Control m_staticCntrlPageNames;
//////////////////////////////////////
Dialog* m_pOwner;
};
class ColListControlMenu : public Menu
{
public:
ColListControlMenu(ColListControl* pCLcntrl, int nRow, int nCol);
void OnMenuItem(UINT nPos)
{
m_nChoice = nPos;
}
bool GetCommand(int& nChoice);
private:
int m_nChoice;
};
#endif //_COL_DESIGNATIONS_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -