Exemplo n.º 1
0
void TableSettings::OnRemoveColumnClick(wxCommandEvent& event)
{
    Column *col = GetColumn( GetSelectedColumnName() );
    if( col ) {
		// delete associated keys
		SerializableList keys;
		GetConstraints( keys, col->GetName() );
		for(SerializableList::iterator it = keys.begin(); it != keys.end(); ++it ) {
			Constraint *key = (Constraint*) *it;
			m_lstKeys.DeleteObject( key );
			delete key;
		}
		// delete the column
        m_lstColumns.DeleteObject( col );
        delete col;
        UpdateView();
    }
}
Exemplo n.º 2
0
void wxHeaderCtrlBase::OnSeparatorDClick(wxHeaderCtrlEvent& event)
{
    const unsigned col = event.GetColumn();
    const wxHeaderColumn& column = GetColumn(col);

    if ( !column.IsResizeable() )
    {
        event.Skip();
        return;
    }

    int w = GetColumnTitleWidth(column);

    if ( !UpdateColumnWidthToFit(col, w) )
        event.Skip();
    else
        UpdateColumn(col);
}
Exemplo n.º 3
0
BOOL CSHListCtrl::AddHeaderToolTip(int nCol, LPCTSTR sTip )
{
	const int TOOLTIP_LENGTH = 80;
	char buf[TOOLTIP_LENGTH+1];

	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();
	if( nCol >= nColumnCount)
		return FALSE;

	if( (GetStyle() & LVS_TYPEMASK) != LVS_REPORT )
		return FALSE;

	// Get the header height
	RECT rect;
	pHeader->GetClientRect( &rect );
	int height = rect.bottom;

	RECT rctooltip;
	rctooltip.top = 0;
	rctooltip.bottom = rect.bottom;

	// Now get the left and right border of the column
	rctooltip.left = 0 - GetScrollPos( SB_HORZ );
	for( int i = 0; i < nCol; i++ )
		rctooltip.left += GetColumnWidth( i );
	rctooltip.right = rctooltip.left + GetColumnWidth( nCol );

	if( sTip == NULL )
	{
		// Get column heading
		LV_COLUMN lvcolumn;
		lvcolumn.mask = LVCF_TEXT;
		lvcolumn.pszText = buf;
		lvcolumn.cchTextMax = TOOLTIP_LENGTH;
		if( !GetColumn( nCol, &lvcolumn ) )
			return FALSE;
	}


	m_tooltip.AddTool( GetDlgItem(0), sTip ? sTip : buf, &rctooltip, nCol+1 );
	return TRUE;

}
bool CBOINCListCtrl::OnSaveState(wxConfigBase* pConfig) {
    wxString    strBaseConfigLocation = wxEmptyString;
    wxListItem  liColumnInfo;
    wxInt32     iIndex = 0;
    wxInt32     iColumnCount = 0;


    wxASSERT(pConfig);


    // Retrieve the base location to store configuration information
    // Should be in the following form: "/Projects/"
    strBaseConfigLocation = pConfig->GetPath() + wxT("/");

    // Convert to a zero based index
    iColumnCount = GetColumnCount() - 1;

    // Which fields are we interested in?
    liColumnInfo.SetMask(
        wxLIST_MASK_TEXT |
        wxLIST_MASK_WIDTH |
        wxLIST_MASK_FORMAT
    );

    // Cycle through the columns recording anything interesting
    for (iIndex = 0; iIndex <= iColumnCount; iIndex++) {
        GetColumn(iIndex, liColumnInfo);

        pConfig->SetPath(strBaseConfigLocation + liColumnInfo.GetText());

        pConfig->Write(wxT("Width"), liColumnInfo.GetWidth());
        
#if (defined(__WXMAC__) &&  wxCHECK_VERSION(2,8,0))
        pConfig->Write(wxT("Width"), GetColumnWidth(iIndex)); // Work around bug in wxMac-2.8.0 wxListCtrl::SetColumn()
#endif
    }

    // Save sorting column and direction
    pConfig->SetPath(strBaseConfigLocation);
    pConfig->Write(wxT("SortColumn"), m_pParentView->m_iSortColumn);
    pConfig->Write(wxT("ReverseSortOrder"), m_pParentView->m_bReverseSort);

    return true;
}
Exemplo n.º 5
0
void wxHeaderCtrlBase::OnSeparatorDClick(wxHeaderCtrlEvent& event)
{
    const unsigned col = event.GetColumn();
    const wxHeaderColumn& column = GetColumn(col);

    if ( !column.IsResizeable() )
    {
        event.Skip();
        return;
    }

    int w = wxWindowBase::GetTextExtent(column.GetTitle()).x;
    w += 4*GetCharWidth(); // add some arbitrary margins around text

    if ( !UpdateColumnWidthToFit(col, w) )
        event.Skip();
    else
        UpdateColumn(col);
}
Exemplo n.º 6
0
int wxHeaderCtrl::MSWFromNativeOrder(int order)
{
    wxASSERT_MSG( order >= 0 && order < GetShownColumnsCount(),
                  "native column position out of range" );

    unsigned pos = order;
    for ( unsigned n = 0; n < m_numColumns; n++ )
    {
        if ( n > pos )
            break;

        if ( GetColumn(m_colIndices[n]).IsHidden() )
            pos++;
    }

    wxASSERT_MSG( MSWToNativeOrder(pos) == order, "logic error" );

    return pos;
}
Exemplo n.º 7
0
void wxHeaderCtrl::DoSetColumnsOrder(const wxArrayInt& order)
{
    wxArrayInt orderShown;
    orderShown.reserve(m_numColumns);

    for ( unsigned n = 0; n < m_numColumns; n++ )
    {
        const int idx = order[n];
        if ( GetColumn(idx).IsShown() )
            orderShown.push_back(MSWToNativeIdx(idx));
    }

    if ( !Header_SetOrderArray(GetHwnd(), orderShown.size(), &orderShown[0]) )
    {
        wxLogLastError(wxT("Header_GetOrderArray"));
    }

    m_colIndices = order;
}
Exemplo n.º 8
0
int wxHeaderCtrl::MSWToNativeIdx(int idx)
{
    // don't check for GetColumn(idx).IsShown() as it could have just became
    // false and we may be called from DoUpdate() to delete the old column
    wxASSERT_MSG( !m_isHidden[idx],
                  "column must be visible to have an "
                  "index in the native control" );

    int item = idx;
    for ( int i = 0; i < idx; i++ )
    {
        if ( GetColumn(i).IsHidden() )
            item--; // one less column the native control knows about
    }

    wxASSERT_MSG( item >= 0 && item <= GetShownColumnsCount(), "logic error" );

    return item;
}
Exemplo n.º 9
0
// Compare two schemas
bool Schema::operator==(const Schema &other) const {
  if (other.GetColumnCount() != GetColumnCount() ||
      other.GetUninlinedColumnCount() != GetUninlinedColumnCount() ||
      other.IsInlined() != IsInlined()) {
    return false;
  }

  for (oid_t column_itr = 0; column_itr < other.GetColumnCount();
       column_itr++) {
    const Column &column_info = other.GetColumn(column_itr);
    const Column &other_column_info = GetColumn(column_itr);

    if (column_info != other_column_info) {
      return false;
    }
  }

  return true;
}
Exemplo n.º 10
0
LRESULT CDrawHeader::DoLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	POINT point;
	point.x = GET_X_LPARAM(lParam);
	point.y = GET_Y_LPARAM(lParam);

	m_ptLastLButtonDown = point;
	
	if (!m_bColumnResizing)
	{
		m_pAlmSum->SetCapture(TRUE, this);
		if (MouseOverColumnResizeArea(point))
		{
			SetCursor(m_hColDivCursor); 
			m_bColumnResizing = TRUE;
		}
		else
		{
			m_nColumnCatpture = GetColumn(point);

			CDCHandle dcHandle = m_pAlmSum->GetDC();
			DoDraw(dcHandle);
			m_pAlmSum->ReleaseDC(dcHandle);
		}
	}

	if (m_bColumnResizing)
	{
		if (!GetResizeColumn(point, m_nResizingColumn, m_nDragDivideOffset))
			return 1;
		
		CRect rect = m_pAlmSum->m_rect;
		CRect invertedRect(point.x - 1 - m_nDragDivideOffset, rect.top, 
			point.x - m_nDragDivideOffset, rect.bottom);
		
		CDCHandle dcHandle = m_pAlmSum->GetDC();
		dcHandle.InvertRect(&invertedRect);
		m_pAlmSum->ReleaseDC(dcHandle);
	}
		
	return 0;
}
HRESULT CADsSearch::GetColumn( UINT nIndex, CStringList &sList )
{
	CString s;

	if ( m_sColumnList.IsEmpty() )
	{
		return E_FAIL;
	}

	POSITION pos;
	pos = m_sColumnList.FindIndex( nIndex );

	if ( pos == NULL )
	{
		return E_FAIL;
	}

	s = m_sColumnList.GetAt(pos);
	return GetColumn( s, sList );

}
Exemplo n.º 12
0
int wxHeaderCtrl::MSWFromNativeIdx(int item)
{
    wxASSERT_MSG( item >= 0 && item < GetShownColumnsCount(),
                  "column index out of range" );

    // reverse the above function

    unsigned idx = item;
    for ( unsigned n = 0; n < m_numColumns; n++ )
    {
        if ( n > idx )
            break;

        if ( GetColumn(n).IsHidden() )
            idx++;
    }

    wxASSERT_MSG( MSWToNativeIdx(idx) == item, "logic error" );

    return idx;
}
Exemplo n.º 13
0
void EGridCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
	SetCapture();

	m_MouseDownCP = point;

	bool bOnHeaderRow = ( 0<=point.y && point.y<GetHeaderRowHeight() );

	if( bOnHeaderRow )
	{
		m_pDragColumn = GetColumn(point.x,true);

		if( m_pDragColumn!=NULL )
		{
			SetCursor( LoadCursor(NULL,IDC_SIZEWE) );
		}
	}
	else
	{
		int nCol=-1;
		int nRow=-1;

		EProperty* pProperty = GetProperty( point , nCol , nRow );

		m_SeletectPropertyIndex.x = nCol;
		m_SeletectPropertyIndex.y = nRow;

		SetActiveProperty(pProperty);

		if( m_pActiveProperty != NULL )
		{
			if( m_pActiveProperty->OnLButtonDown( this , point ) )
			{
				NotifyPropertyChanged();
				Invalidate();
			}
		}
	}

}
Exemplo n.º 14
0
// CTwoListCtrl 消息处理程序
void CSkinListProgressCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS )
{
    // TODO: Add your message handler code here and/or call default
    CDC   *pDC = CDC::FromHandle(lpDIS->hDC);  
    int   nRows = m_lstItemColor.GetCount();  
    COLORREF *clrCol = NULL;  
    if   (nRows && (int)lpDIS->itemID < nRows)  
    {  
        clrCol = m_lstItemColor.GetAt(m_lstItemColor.FindIndex(lpDIS->itemID));  
    }  
    CRect  rcItem(lpDIS->rcItem);  
    LVCOLUMN lvColumn;  
    ZeroMemory(&lvColumn, sizeof(LVCOLUMN));  
    lvColumn.mask = LVCF_FMT | LVCF_WIDTH;  
    for (int nCol = 0; nCol < GetHeaderCtrl()->GetItemCount(); nCol++)  
    {  
        if (clrCol)  
        {
            pDC->SetBkColor(clrCol[nCol]);
            pDC->SetTextColor(clrCol[nCol]);  
        }
        GetColumn(nCol, &lvColumn);  
        UINT   uStyle = DT_SINGLELINE | DT_END_ELLIPSIS;  
        if   (lvColumn.fmt & LVCFMT_LEFT)  
            uStyle |= DT_LEFT;  
        if   (lvColumn.fmt   &   LVCFMT_RIGHT)  
            uStyle |= DT_RIGHT;  
        if   (lvColumn.fmt & LVCFMT_CENTER)  
            uStyle |= DT_CENTER;  
        rcItem.right = rcItem.left + lvColumn.cx;  
     //   COLORREF color;
     //   GetSysColor(color);
     //   pDC->FillSolidRect(rcItem, RGB(122,122,122));//::GetSysColor(COLOR_INACTIVECAPTION));     
		 pDC->FillSolidRect(rcItem, m_listItemColor1); 
        pDC->DrawText(GetItemText(lpDIS->itemID, nCol), rcItem, uStyle);
        rcItem.left += lvColumn.cx;  
    }   
//     CListCtrl::OnDrawItem(nIDCtl, lpDIS);

}
Exemplo n.º 15
0
void SmartListCtrl::Init(DWORD dwStyle, INT nCols, INT nFormat, LPCWSTR *pHeaders, DOUBLE *pColWidth /* = NULL */) {
	this->DeleteAllItems();
	this->SetExtendedStyle(this->GetExtendedStyle() | dwStyle);
	
	int nTotalWidth;
	CRect rc;
	this->GetWindowRect(&rc);
	nTotalWidth = static_cast<int>(rc.Size().cx);
	for(int i = 0; i < nCols; i++) {
		this->InsertColumn(i, pHeaders[i], nFormat, (pColWidth) ? static_cast<int>(nTotalWidth * pColWidth[i]) : (nTotalWidth / nCols));
	}

	// 修改参数使得支持第一列标题居中显示
	if(nFormat == LVCFMT_CENTER) {
		LVCOLUMN lvc;
		lvc.mask = LVCF_FMT;
		GetColumn(0, &lvc);
		lvc.fmt &= ~LVCFMT_JUSTIFYMASK;
		lvc.fmt |= LVCFMT_CENTER;
		SetColumn(0, &lvc);
	}
}
Exemplo n.º 16
0
CEdit* CPlayerListCtrl::ShowInPlaceEdit(int nItem, int nCol)
{
	CRect rect;
	if(!PrepareInPlaceControl(nItem, nCol, rect))
		return(NULL);

	DWORD dwStyle = /*WS_BORDER|*/WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;

	LV_COLUMN lvcol;
	lvcol.mask = LVCF_FMT;
	GetColumn(nCol, &lvcol);
	dwStyle |= (lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT ? ES_LEFT
		: (lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT ? ES_RIGHT
		: ES_CENTER;

	CEdit* pEdit = new CInPlaceEdit(nItem, nCol, GetItemText(nItem, nCol));
	pEdit->Create(dwStyle, rect, this, IDC_EDIT1);

	m_fInPlaceDirty = false;

	return pEdit;
}
Exemplo n.º 17
0
int CTreeList::QuerySubItemText(int item, CHAR *Data, int length)
{
    LV_COLUMN lvc;
    LV_ITEM lvi;
    int     ncol;
    CRect   rect;

    ::ZeroMemory(&lvc, sizeof(lvc));
    lvc.mask = LVCF_WIDTH |LVCF_FMT;

    for (ncol=0; GetColumn(ncol, &lvc); ncol++) {

        if (ncol > 0) {
            GetSubItemRect(item, ncol,LVIR_BOUNDS, rect);
        } else {
            GetItemRect(item, rect, LVIR_BOUNDS);
            rect.right = GetColumnWidth(0);
            rect.left = 0;
        }

        if (rect.PtInRect(m_Point)) {

            ::ZeroMemory(Data, length);
            ::ZeroMemory(&lvi, sizeof(lvi));

            lvi.iItem = item;
            lvi.mask = LVIF_TEXT;
            lvi.iSubItem = ncol;
            lvi.pszText = Data;
            lvi.cchTextMax = length;

            return GetItem(&lvi);
            break;
        }
    }

    return FALSE;
}
Exemplo n.º 18
0
void wxHeaderCtrl::DoUpdate(unsigned int idx)
{
    // the native control does provide Header_SetItem() but it's inconvenient
    // to use it because it sends HDN_ITEMCHANGING messages and we'd have to
    // arrange not to block setting the width from there and the logic would be
    // more complicated as we'd have to reset the old values as well as setting
    // the new ones -- so instead just recreate the column

    const wxHeaderColumn& col = GetColumn(idx);
    if ( col.IsHidden() )
    {
        // column is hidden now
        if ( !m_isHidden[idx] )
        {
            // but it wasn't hidden before, so remove it
            if ( !Header_DeleteItem(GetHwnd(), MSWToNativeIdx(idx)) )
                wxLogLastError(wxS("Header_DeleteItem()"));

            m_isHidden[idx] = true;
        }
        //else: nothing to do, updating hidden column doesn't have any effect
    }
    else // column is shown now
    {
        if ( m_isHidden[idx] )
        {
            m_isHidden[idx] = false;
        }
        else // and it was shown before as well
        {
            // we need to remove the old column
            if ( !Header_DeleteItem(GetHwnd(), MSWToNativeIdx(idx)) )
                wxLogLastError(wxS("Header_DeleteItem()"));
        }

        DoInsertItem(col, idx);
    }
}
// scan for the next block element of type, returns true if no error, , bEof will be set to true if eof is hit
bool Elementizer::GetNextBlock(int type, bool& bEof)
{
    bool bFound = false;
    while(bFound == false)
    {
        if (GetNext(bEof) == false || bEof == true)
        {
            break;
        }
        if (GetType() == type_block && GetValue() == type)
        {
            if (GetColumn() != 1)
            {
                m_pCompilerData->error = true;
                m_pCompilerData->error_msg = g_pErrorStrings[error_bdmbifc];
                return false;
            }
            bFound = true;
        }
    }
    // if we found the block or we hit eof, then we got no error so return true
    return (bFound || bEof);
}
Exemplo n.º 20
0
unsigned int wxHeaderCtrl::FindColumnAtPoint(int x, bool *onSeparator) const
{
    int pos = 0;
    const unsigned count = GetColumnCount();
    for ( unsigned n = 0; n < count; n++ )
    {
        const unsigned idx = m_colIndices[n];
        const wxHeaderColumn& col = GetColumn(idx);
        if ( col.IsHidden() )
            continue;

        pos += col.GetWidth();

        // if the column is resizable, check if we're approximatively over the
        // line separating it from the next column
        //
        // TODO: don't hardcode sensitivity
        if ( col.IsResizeable() && abs(x - pos) < 8 )
        {
            if ( onSeparator )
                *onSeparator = true;
            return idx;
        }

        // inside this column?
        if ( x < pos )
        {
            if ( onSeparator )
                *onSeparator = false;
            return idx;
        }
    }

    if ( onSeparator )
        *onSeparator = false;
    return COL_NONE;
}
Exemplo n.º 21
0
CColumnData* CEnListCtrl::CreateColumnData(int nCol)
{
	CColumnData* pData = NULL;

	if (!m_mapColumnData.Lookup(nCol, pData)) // see if its already added
	{
		pData = GetNewColumnData();
		
		if (pData)
			m_mapColumnData.SetAt(nCol, pData);

		// set the column format to the most appropriate
		LV_COLUMN lvc = { 0 };
		lvc.mask = LVCF_FMT;
		
		if (GetColumn(nCol, &lvc))
		{
			if ((lvc.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT)
				pData->nFormat = ES_START;
		}
	}

	return pData;
}
Exemplo n.º 22
0
// event handling:
void wxDataViewCtrl::OnSize(wxSizeEvent& event)
{
  unsigned int const noOfColumns = GetColumnCount();


 // reset DC of all custom renderers because DC has changed:
  for (unsigned int i=0; i<noOfColumns; ++i)
  {
    wxDataViewColumn* dataViewColumnPtr(GetColumn(i));

    if (dataViewColumnPtr != NULL)
    {
      wxDataViewCustomRenderer* dataViewCustomRendererPtr(dynamic_cast<wxDataViewCustomRenderer*>(dataViewColumnPtr->GetRenderer()));

      if (dataViewCustomRendererPtr != NULL)
        dataViewCustomRendererPtr->SetDC(NULL);
    }
  }

 // update the layout of the native control after a size event:
  GetDataViewPeer()->OnSize();

  event.Skip();
}
Exemplo n.º 23
0
/*******************************************************************************
  Function Name  : GetCellRect
  Input(s)       : nIndex - Type of the entry
                   rect - Boundary of the entry
  Output         : BOOL - TRUE on Success
  Functionality  : Gets the dimensions of the colour cell given by (row,col)
  Member of      : CColourPopup
  Author(s)      : Raja N
  Date Created   : 09/12/2004
  Modifications  : 
*******************************************************************************/
BOOL CColourPopup::GetCellRect(int nIndex, const LPRECT& rect)
{
    if (nIndex == CUSTOM_BOX_VALUE)
    {
        ::SetRect(rect, 
                  m_CustomTextRect.left,  m_CustomTextRect.top,
                  m_CustomTextRect.right, m_CustomTextRect.bottom);
        return TRUE;
    }
    else if (nIndex == DEFAULT_BOX_VALUE)
    {
        ::SetRect(rect, 
                  m_DefaultTextRect.left,  m_DefaultTextRect.top,
                  m_DefaultTextRect.right, m_DefaultTextRect.bottom);
        return TRUE;
    }

    if (nIndex < 0 || nIndex >= m_nNumColours )
    {
        return FALSE;
    }

    rect->left = GetColumn(nIndex) * m_nBoxSize + m_nMargin;
    rect->top  = GetRow(nIndex) * m_nBoxSize + m_nMargin;

    // Move everything down if we are displaying a default text area
    if( m_strDefaultText.GetLength() > 0 )
    {
        rect->top += (m_nMargin + m_DefaultTextRect.Height());
    }

    rect->right = rect->left + m_nBoxSize;
    rect->bottom = rect->top + m_nBoxSize;

    return TRUE;
}
Exemplo n.º 24
0
std::string GetMoveSAN(Position &position, const Move move)
{
	const Square from = GetFrom(move);
	const Square to = GetTo(move);

	const Move moveType = GetMoveType(move);

	std::string result;
	if (moveType == MoveTypeCastle)
	{
		if (GetColumn(to) > FILE_E)
		{
			result = "O-O";
		}
		else
		{
			result = "O-O-O";
		}
	}
	else
	{
		// Piece that is moving
		const PieceType fromPieceType = GetPieceType(position.Board[from]);
		switch (fromPieceType)
		{
		case PAWN: break;
		case KNIGHT: result += "N"; break;
		case BISHOP: result += "B"; break;
		case ROOK: result += "R"; break;
		case QUEEN: result += "Q"; break;
		case KING: result += "K"; break;
		}

		Move legalMoves[256];
		int legalMoveCount = GenerateLegalMoves(position, legalMoves);

		// Do we need to disambiguate?
		bool dupe = false, rowDiff = true, columnDiff = true;
		for (int i = 0; i < legalMoveCount; i++)
		{
			if (GetFrom(legalMoves[i]) != from &&
				GetTo(legalMoves[i]) == to &&
				GetPieceType(position.Board[GetFrom(legalMoves[i])]) == fromPieceType)
			{
				dupe = true;
				if (GetRow(GetFrom(legalMoves[i])) == GetRow(from))
				{
					rowDiff = false;
				}
				if (GetColumn(GetFrom(legalMoves[i])) == GetColumn(from))
				{
					columnDiff = false;
				}
			}
		}

		if (dupe)
		{
			if (columnDiff)
			{
				result += GetSquareSAN(from)[0];
			}
			else if (rowDiff)
			{
				result += GetSquareSAN(from)[1];
			}
			else
			{
				result += GetSquareSAN(from);
			}
		}
		else if (fromPieceType == PAWN && position.Board[to] != PIECE_NONE)
		{
			// Pawn captures need a row
			result += GetSquareSAN(from)[0];
		}
		
		// Capture?
		if (position.Board[to] != PIECE_NONE ||
			moveType == MoveTypeEnPassent)
		{
			result += "x";
		}

		// Target square
		result += GetSquareSAN(to);
	}

	if (moveType == MoveTypePromotion)
	{
		switch (GetPromotionMoveType(move))
		{
		case KNIGHT: result += "=N"; break;
		case BISHOP: result += "=B"; break;
		case ROOK: result += "=R"; break;
		case QUEEN: result += "=Q"; break;
		}
	}

	MoveUndo moveUndo;
	position.MakeMove(move, moveUndo);

	if (position.IsInCheck())
	{
		Move checkEscapes[64];
		result += GenerateCheckEscapeMoves(position, checkEscapes) == 0 ? "#" : "+";
	}

	position.UnmakeMove(move, moveUndo);

	return result;
}
Exemplo n.º 25
0
	bool Parser::GetToken(token& out)
	{
		// trim leading whitespace first:
		for (; text.str < text.end; ++text.str)
		{
			char ch = *text.str;
			if (ch == ' ' || ch == '\t')  continue;
			if (ch == '\r' || ch == '\n') SkipNewLine(ch);
			else break; // not ' ' or '\t', so finish trim
		}

		out.end = out.str = text.str; // mark down start and default end
		column  = GetColumn();

		for ( ; text.str < text.end; ++text.str)
		{
			char ch = *text.str;
			if (ch == '\r' || ch == '\n') {
				SkipNewLine(ch);
				continue;
			}

			if (ch == '/') { // possible comment start?
				char c2 = text.str[1];
				if (c2 == '/' || c2 == '*') // line comment '//' or block comment '/*'
					return ParseComment(out, c2 == '*'); // parse the comment
			}
			else if (ch == '"')
				return ParseStringLiteral(out); // skip the literal
			else if (ch == '\'')
				return ParseCharLiteral(out);

			if (BreakerIndex[ch] == 1) // token starts with a breaker char
			{
				line    = cur_line;
				column  = GetColumn();

				char c2 = *++text.str;
				char c3 = text.str[1];

				if (c3 == '=' && (
					(ch == '<' && c2 == '<')|| // <<=
					(ch == '>' && c2 == '>'))) // >>=
				{
					text.str += 2; // 3 char token parsed
				}
				else if ((c2 == '=' && (
					 ch == '<' || // <=
					 ch == '>' || // >=
					 ch == '=' || // ==
					 ch == '!' || // !=
					 ch == '+' || // +=
					 ch == '-' || // -=
					 ch == '*' || // *=
					 ch == '/' || // /=
					 ch == '%' || // %=
					 ch == '&' || // &=
					 ch == '|' || // |=
					 ch == '^'    // ^=
					)) || 
					(ch == '+' && c2 == '+') || // ++
					(ch == '-' && c2 == '-') || // --
					(ch == '-' && c2 == '>') || // ->
					(ch == '?' && c2 == '?') || // ??
					(ch == '&' && c2 == '&') || // &&
					(ch == '|' && c2 == '|') || // ||
					(ch == '<' && c2 == '<') || // <<
					(ch == '>' && c2 == '>') || // >>
					(ch == ':' && c2 == ':'))   // ::
				{
					++text.str;  // 2 char token parsed
				}
				out.end = text.str;
				return true; // 1 char token parsed
			}

			// so this is a literal or a statement?
			return ParseStatement(out);
		}
		return false; // end of buffer
	}
Exemplo n.º 26
0
// **************************************************************************
// EditSubLabel ()
//
// Description:
//	Edit the subitem value.  Creates a CEdit object sized and placed to cover
//	list control cell.  This edit box is needed to receive user input, and
//	will delete itself when its parent window is destroyed.
//
// Parameters:
//  int			nItem	Index of item
//	int			nCol	Column of item
//
// Returns:
//  CEdit* - Pointer to a CEdit object to be used to edit cell.
// **************************************************************************
CEdit* CKListEditCtrl::EditSubLabel (int nItem, int nCol)
	{
	int cnColumns = 0;
	int nColOffset = 0;

	// Make sure that the item is visible:
	if (!EnsureVisible (nItem, TRUE)) 
		return (NULL);

	// Get the number of columns:
	CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem (0);
	cnColumns = pHeader->GetItemCount ();

	// Make sure that column is valid:
	if (nCol >= cnColumns || GetColumnWidth (nCol) < 5)
		return (NULL);

	// Get the column offset (from left boundary):
	nColOffset = 0;
	for (int i = 0; i < nCol; i++)
		nColOffset += GetColumnWidth (i);

	// Get selected item's rectangle:
	CRect rect;
	GetItemRect (nItem, &rect, LVIR_BOUNDS);

	// Scroll if we need to expose the column:
	CRect rcClient;
	GetClientRect (&rcClient);
	
	if (nColOffset + rect.left < 0 || nColOffset + rect.left > rcClient.right)
		{
		CSize size;
		size.cx = nColOffset + rect.left;
		size.cy = 0;
		Scroll (size);
		rect.left -= size.cx;
		}

	// Get column alignment:
	LV_COLUMN lvcol;
	lvcol.mask = LVCF_FMT;
	GetColumn (nCol, &lvcol);
	DWORD dwStyle;

	switch (lvcol.fmt & LVCFMT_JUSTIFYMASK)
		{
		case LVCFMT_LEFT:
			dwStyle = ES_LEFT;
			break;

		case LVCFMT_RIGHT:
			dwStyle = ES_RIGHT;
			break;

		default:
			dwStyle = ES_CENTER;
			break;
		}

	rect.left += (nColOffset + 4);
	rect.right = rect.left + GetColumnWidth (nCol) - 10;

	if (rect.right > rcClient.right) 
		rect.right = rcClient.right;

	// Defile edit control (base class) style:
	dwStyle |= WS_BORDER | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL;

	// Create a new CKListEdit box (not to be confused with CKListEditCtrl):
	CEdit *pEdit = new CKListEdit (nItem, nCol, GetItemText (nItem, nCol));

	// Set style, size and position using base class:
	pEdit->Create (dwStyle, rect, this, IDC_LISTEDIT);

	// Update currently selected item:
	m_nSelItem = nItem;

	// Return pointer to new CKListEdit control:
	return (pEdit);
	}
TEST_F(ProjectionTests, BasicTargetTest) {
  MockExecutor child_executor;
  EXPECT_CALL(child_executor, DInit()).WillOnce(Return(true));

  EXPECT_CALL(child_executor, DExecute())
      .WillOnce(Return(true))
      .WillOnce(Return(false));

  size_t tile_size = 5;

  // Create a table and wrap it in logical tile
  auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
  auto txn = txn_manager.BeginTransaction();
  std::unique_ptr<storage::DataTable> data_table(
      TestingExecutorUtil::CreateTable(tile_size));
  TestingExecutorUtil::PopulateTable(data_table.get(), tile_size, false, false,
                                   false, txn);
  txn_manager.CommitTransaction(txn);

  std::unique_ptr<executor::LogicalTile> source_logical_tile1(
      executor::LogicalTileFactory::WrapTileGroup(data_table->GetTileGroup(0)));

  EXPECT_CALL(child_executor, GetOutput())
      .WillOnce(Return(source_logical_tile1.release()));

  // Create the plan node
  TargetList target_list;
  DirectMapList direct_map_list;

  /////////////////////////////////////////////////////////
  // PROJECTION 0, TARGET 0 + 20
  /////////////////////////////////////////////////////////

  // construct schema
  std::vector<catalog::Column> columns;
  auto orig_schema = data_table.get()->GetSchema();
  columns.push_back(orig_schema->GetColumn(0));
  columns.push_back(orig_schema->GetColumn(0));
  std::shared_ptr<const catalog::Schema> schema(new catalog::Schema(columns));

  // direct map
  DirectMap direct_map = std::make_pair(0, std::make_pair(0, 0));
  direct_map_list.push_back(direct_map);

  // target list
  auto const_val = new expression::ConstantValueExpression(
      type::ValueFactory::GetIntegerValue(20));
  auto tuple_value_expr =
      expression::ExpressionUtil::TupleValueFactory(type::Type::INTEGER, 0, 0);
  expression::AbstractExpression *expr =
      expression::ExpressionUtil::OperatorFactory(ExpressionType::OPERATOR_PLUS,
                                                  type::Type::INTEGER,
                                                  tuple_value_expr, const_val);

  Target target = std::make_pair(1, expr);
  target_list.push_back(target);

  std::unique_ptr<const planner::ProjectInfo> project_info(
      new planner::ProjectInfo(std::move(target_list),
                               std::move(direct_map_list)));

  planner::ProjectionPlan node(std::move(project_info), schema);

  // Create and set up executor
  executor::ProjectionExecutor executor(&node, nullptr);
  executor.AddChild(&child_executor);

  RunTest(executor, 1);
}
TEST_F(ProjectionTests, TwoColumnTest) {
  MockExecutor child_executor;
  EXPECT_CALL(child_executor, DInit()).WillOnce(Return(true));

  EXPECT_CALL(child_executor, DExecute())
      .WillOnce(Return(true))
      .WillOnce(Return(false));

  size_t tile_size = 5;

  // Create a table and wrap it in logical tile
  auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
  auto txn = txn_manager.BeginTransaction();
  std::unique_ptr<storage::DataTable> data_table(
      TestingExecutorUtil::CreateTable(tile_size));
  TestingExecutorUtil::PopulateTable(data_table.get(), tile_size, false, false,
                                   false, txn);
  txn_manager.CommitTransaction(txn);

  std::unique_ptr<executor::LogicalTile> source_logical_tile1(
      executor::LogicalTileFactory::WrapTileGroup(data_table->GetTileGroup(0)));

  EXPECT_CALL(child_executor, GetOutput())
      .WillOnce(Return(source_logical_tile1.release()));

  // Create the plan node
  TargetList target_list;
  DirectMapList direct_map_list;

  /////////////////////////////////////////////////////////
  // PROJECTION 3, 1, 3
  /////////////////////////////////////////////////////////

  // construct schema
  std::vector<catalog::Column> columns;
  auto orig_schema = data_table.get()->GetSchema();
  columns.push_back(orig_schema->GetColumn(3));
  columns.push_back(orig_schema->GetColumn(1));
  columns.push_back(orig_schema->GetColumn(3));

  std::shared_ptr<const catalog::Schema> schema(new catalog::Schema(columns));

  // direct map
  DirectMap map0 = std::make_pair(0, std::make_pair(0, 3));
  DirectMap map1 = std::make_pair(1, std::make_pair(0, 1));
  DirectMap map2 = std::make_pair(2, std::make_pair(0, 3));
  direct_map_list.push_back(map0);
  direct_map_list.push_back(map1);
  direct_map_list.push_back(map2);

  std::unique_ptr<const planner::ProjectInfo> project_info(
      new planner::ProjectInfo(std::move(target_list),
                               std::move(direct_map_list)));

  planner::ProjectionPlan node(std::move(project_info), schema);

  // Create and set up executor
  executor::ExecutorContext context(txn);
  executor::ProjectionExecutor executor(&node, &context);
  executor.AddChild(&child_executor);

  RunTest(executor, 1);
}
Exemplo n.º 29
0
void CListCtrlCl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{

	// TODO:  添加您的代码以绘制指定项
	TCHAR lpBuffer[256];

	LV_ITEM lvi;

	lvi.mask = LVIF_TEXT | LVIF_PARAM ;
	lvi.iItem = lpDrawItemStruct->itemID ; 
	lvi.iSubItem = 0;
	lvi.pszText = lpBuffer ;
	lvi.cchTextMax = sizeof(lpBuffer);
	VERIFY(GetItem(&lvi));

	LV_COLUMN lvc, lvcprev ;
	::ZeroMemory(&lvc, sizeof(lvc));
	::ZeroMemory(&lvcprev, sizeof(lvcprev));
	lvc.mask = LVCF_WIDTH | LVCF_FMT;
	lvcprev.mask = LVCF_WIDTH | LVCF_FMT;

	CDC* pDC;
	pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	CRect rtClient;
	GetClientRect(&rtClient);
	for ( int nCol=0; GetColumn(nCol, &lvc); nCol++)
	{
		if ( nCol > 0 ) 
		{
			// Get Previous Column Width in order to move the next display item
			GetColumn(nCol-1, &lvcprev) ;
			lpDrawItemStruct->rcItem.left += lvcprev.cx ;
			lpDrawItemStruct->rcItem.right += lpDrawItemStruct->rcItem.left; 
		}

		CRect rcItem;   
		if (!GetSubItemRect(lpDrawItemStruct->itemID,nCol,LVIR_LABEL,rcItem))   
			continue;   

		::ZeroMemory(&lvi, sizeof(lvi));
		lvi.iItem = lpDrawItemStruct->itemID;
		lvi.mask = LVIF_TEXT | LVIF_PARAM;
		lvi.iSubItem = nCol;
		lvi.pszText = lpBuffer;
		lvi.cchTextMax = sizeof(lpBuffer);
		VERIFY(GetItem(&lvi));
		CRect rcTemp;
		rcTemp = rcItem;

		if (nCol==0)
		{
			rcTemp.left -=2;
		}

		if ( lpDrawItemStruct->itemState & ODS_SELECTED )
		{
			pDC->FillSolidRect(&rcTemp, GetSysColor(COLOR_HIGHLIGHT)) ;
			pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT)) ;
		}
		else
		{
			COLORREF color;
			color = GetBkColor();
			pDC->FillSolidRect(rcTemp,color);

			if (FindColColor(nCol,color))
			{
				pDC->FillSolidRect(rcTemp,color);
			}
			if (FindItemColor(nCol,lpDrawItemStruct->itemID,color))
			{
				pDC->FillSolidRect(rcTemp,color);
			}
			
			//pDC->SetTextColor(m_color);
		}

		pDC->SelectObject(GetStockObject(DEFAULT_GUI_FONT));

		UINT   uFormat    = DT_CENTER ;
		if (m_Header.m_Format[nCol]=='0')
		{
			uFormat = DT_LEFT;
		}
		else if (m_Header.m_Format[nCol]=='1')
		{
			uFormat = DT_CENTER;
		}
		else if (m_Header.m_Format[nCol]=='2')
		{
			uFormat = DT_RIGHT;
		}
		TEXTMETRIC metric;
		pDC->GetTextMetrics(&metric);
		int ofst;
		ofst = rcItem.Height() - metric.tmHeight;
		rcItem.OffsetRect(0,ofst/2);
		pDC->SetTextColor(m_color);
		COLORREF color;
		if (FindColTextColor(nCol,color))
		{
			pDC->SetTextColor(color);
		}
		if (FindItemTextColor(nCol,lpDrawItemStruct->itemID,color))
		{
			pDC->SetTextColor(color);
		}
		CFont nFont ,* nOldFont; 
		nFont.CreateFont(m_fontHeight,m_fontWith,0,0,0,FALSE,FALSE,0,0,0,0,0,0,_TEXT("宋体"));//创建字体 
		nOldFont = pDC->SelectObject(&nFont);
		DrawText(lpDrawItemStruct->hDC, lpBuffer, strlen(lpBuffer), 
			&rcItem, uFormat) ;

		pDC->SelectStockObject(SYSTEM_FONT) ;
	}

}
Exemplo n.º 30
0
CEdit* 
CListCtrlEx::EditSubItem (int Item, int Column)
{
    // The returned pointer should not be saved

	CancelEdit(FALSE);

    // Make sure that the item is visible
    if (!EnsureVisible (Item, TRUE)) 
    {
		InsertItemEx (Item);
		if (!EnsureVisible (Item, TRUE)) 
			return NULL;
    }

    // Make sure that nCol is valid
    CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem(0);
    int nColumnCount = pHeader->GetItemCount();
    if (Column >= nColumnCount || GetColumnWidth (Column) < 5)
		return NULL;

    // Get the column offset
    int Offset = 0;
    for (int iColumn = 0; iColumn < Column; iColumn++)
		Offset += GetColumnWidth (iColumn);

    CRect Rect;
    GetItemRect (Item, &Rect, LVIR_BOUNDS);

    // Now scroll if we need to expose the column
    CRect ClientRect;
    GetClientRect (&ClientRect);
    if (Offset + Rect.left < 0 || Offset + Rect.left > ClientRect.right)
    {
		CSize Size;
		if (Offset + Rect.left > 0)
			Size.cx = -(Offset - Rect.left);
		else
			Size.cx = Offset - Rect.left;
		Size.cy = 0;
		Scroll (Size);
		Rect.left -= Size.cx;
    }

    // Get Column alignment
    LV_COLUMN lvCol;
    lvCol.mask = LVCF_FMT;
    GetColumn (Column, &lvCol);
    DWORD dwStyle;
    if ((lvCol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT)
		dwStyle = ES_LEFT;
    else if ((lvCol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT)
		dwStyle = ES_RIGHT;
    else dwStyle = ES_CENTER;

    Rect.left += Offset+4;
    Rect.right = Rect.left + GetColumnWidth (Column) - 3;
    if (Rect.right > ClientRect.right)
		Rect.right = ClientRect.right;

    dwStyle |= WS_BORDER | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL;

    // Send Notification to parent of ListView ctrl
    LV_DISPINFO dispinfo;
    dispinfo.hdr.hwndFrom = m_hWnd;
    dispinfo.hdr.idFrom = 0;
    dispinfo.hdr.code = LVN_BEGINLABELEDIT;

    dispinfo.item.mask = LVIF_TEXT;
    dispinfo.item.iItem = Item;
    dispinfo.item.iSubItem = Column;
    dispinfo.item.pszText = NULL;
    dispinfo.item.cchTextMax = 0;

	// Return Values
	// To allow the user to edit the label, return FALSE.
	// To prevent the user from editing the label, return TRUE.
    if (!GetParent()->SendMessage (WM_NOTIFY, GetDlgCtrlID(), (LPARAM) &dispinfo)) {
		CEditCell *pEdit = new CEditCell (this, Item, Column, GetItemText(Item, Column), 
			m_AutoComplete.GetCount() > 0 ? &m_AutoComplete : NULL);
		pEdit->Create (dwStyle, Rect, this, IDC_EDITCELL);
	    return pEdit;
	} else {
		return NULL;
	}
}