*** /tmp/listctrl_OLD.cpp Sat Oct 5 15:43:09 2002 --- /tmp/listctrl.cpp Sat Oct 5 15:43:09 2002 *************** *** 1720,1743 **** { wxListItemData *item = node->GetData(); int width = m_owner->GetColumnWidth(col); int xOld = x; ! x += width; if ( item->HasImage() ) { - int ix, iy; m_owner->DrawImage( item->GetImage(), dc, xOld, y ); - m_owner->GetImageSize( item->GetImage(), ix, iy ); - - ix += IMAGE_MARGIN_IN_REPORT_MODE; xOld += ix; ! width -= ix; } ! wxDCClipper clipper(*dc, xOld, y, width, rect.height); if ( item->HasText() ) { dc->DrawText( item->GetText(), xOld, y ); --- 1720,1768 ---- { wxListItemData *item = node->GetData(); + wxListItem column; + m_owner->GetColumn(col, column); + int width = m_owner->GetColumnWidth(col); int xOld = x; ! //x += width; ! ! int ix = 0, iy = 0; ! if(item->HasImage()) { ! m_owner->GetImageSize(item->GetImage(), ix, iy); ! ix += IMAGE_MARGIN_IN_REPORT_MODE; ! } + int format = wxLIST_FORMAT_LEFT; + if(column.m_mask & wxLIST_MASK_FORMAT) + format = column.m_format; + + int text_w = 0; + + switch(format) { + case wxLIST_FORMAT_RIGHT: + if(item->HasText()) + dc->GetTextExtent(item->GetText(), &text_w, NULL); + xOld += width - ix - text_w - 4; + break; + case wxLIST_FORMAT_CENTRE: + if(item->HasText()) + dc->GetTextExtent(item->GetText(), &text_w, NULL); + xOld += (width - ix - text_w)/2; + } + if ( item->HasImage() ) { m_owner->DrawImage( item->GetImage(), dc, xOld, y ); xOld += ix; ! //width -= ix; } ! wxDCClipper clipper(*dc, /*xOld*/ x, y, width, rect.height); + x += width; + if ( item->HasText() ) { dc->DrawText( item->GetText(), xOld, y ); *************** *** 1913,1918 **** --- 1938,1944 ---- int numColumns = m_owner->GetColumnCount(); wxListItem item; + wxImageListType *imageList = NULL; for ( int i = 0; i < numColumns && x < w; i++ ) { m_owner->GetColumn( i, item ); *************** *** 1928,1961 **** // if we have an image, draw it on the right of the label int image = item.m_image; if ( image != -1 ) { ! wxImageListType *imageList = m_owner->m_small_image_list; if ( imageList ) { ! int ix, iy; imageList->GetSize(image, ix, iy); ! imageList->Draw ! ( ! image, ! dc, ! x + cw - ix - 1, ! HEADER_OFFSET_Y + (h - 4 - iy)/2, ! wxIMAGELIST_DRAW_TRANSPARENT ! ); ! cw -= ix + 2; } //else: ignore the column image } ! // draw the text clipping it so that it doesn't overwrite the column // boundary wxDCClipper clipper(dc, x, HEADER_OFFSET_Y, cw, h - 4 ); dc.DrawText( item.GetText(), ! x + EXTRA_WIDTH, HEADER_OFFSET_Y + EXTRA_HEIGHT ); x += wCol; } --- 1954,2020 ---- // if we have an image, draw it on the right of the label int image = item.m_image; + int ix = -2, iy = 0; if ( image != -1 ) { ! imageList = m_owner->m_small_image_list; if ( imageList ) { ! //int ix, iy; imageList->GetSize(image, ix, iy); ! // imageList->Draw ! // ( ! // image, ! // dc, ! // x + cw - ix - 1, ! // HEADER_OFFSET_Y + (h - 4 - iy)/2, ! // wxIMAGELIST_DRAW_TRANSPARENT ! // ); ! // cw -= ix + 2; } //else: ignore the column image } ! int text_width = 0; ! int text_x = x; ! int image_offset = cw - ix - 1; ! ! int format = wxLIST_FORMAT_LEFT; ! if(item.m_mask & wxLIST_MASK_FORMAT) ! format = item.m_format; ! switch(format) { ! case wxLIST_FORMAT_LEFT: ! text_x += EXTRA_WIDTH; ! cw -= ix + 2; ! break; ! case wxLIST_FORMAT_RIGHT: ! dc.GetTextExtent(item.m_text, &text_width, NULL); ! text_x += cw - text_width - EXTRA_WIDTH; ! image_offset = 0; ! break; ! case wxLIST_FORMAT_CENTRE: ! dc.GetTextExtent(item.m_text, &text_width, NULL); ! text_x += (cw - text_width)/2 + ix + 2; ! image_offset = (cw - text_width - ix - 2)/2; ! break; ! } ! ! // draw the image ! if(image != -1 && imageList) { ! imageList->Draw(image, dc, x + image_offset/*cw - ix - 1*/, ! HEADER_OFFSET_Y + (h - 4 - iy)/2, ! wxIMAGELIST_DRAW_TRANSPARENT); ! } ! ! // draw the text clipping it so that it doesn't overwrite the column // boundary wxDCClipper clipper(dc, x, HEADER_OFFSET_Y, cw, h - 4 ); dc.DrawText( item.GetText(), ! text_x /*x + EXTRA_WIDTH*/, ! HEADER_OFFSET_Y + EXTRA_HEIGHT ); x += wCol; }