Tought Systemettings that sysfont has 12 pts
wxListCtrl can now resize column by dragging git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@936 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -232,7 +232,7 @@ class wxListItemData : public wxObject
|
|||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxListItemData);
|
DECLARE_DYNAMIC_CLASS(wxListItemData);
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
wxString m_text;
|
wxString m_text;
|
||||||
int m_image;
|
int m_image;
|
||||||
long m_data;
|
long m_data;
|
||||||
@@ -306,7 +306,7 @@ class wxListLineData : public wxObject
|
|||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxListLineData);
|
DECLARE_DYNAMIC_CLASS(wxListLineData);
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
wxList m_items;
|
wxList m_items;
|
||||||
wxRectangle m_bound_all;
|
wxRectangle m_bound_all;
|
||||||
wxRectangle m_bound_label;
|
wxRectangle m_bound_label;
|
||||||
@@ -359,6 +359,10 @@ class wxListHeaderWindow : public wxWindow
|
|||||||
wxListMainWindow *m_owner;
|
wxListMainWindow *m_owner;
|
||||||
wxCursor *m_currentCursor;
|
wxCursor *m_currentCursor;
|
||||||
wxCursor *m_resizeCursor;
|
wxCursor *m_resizeCursor;
|
||||||
|
bool m_isDraging;
|
||||||
|
int m_column;
|
||||||
|
int m_minX;
|
||||||
|
int m_currentX;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxListHeaderWindow( void );
|
wxListHeaderWindow( void );
|
||||||
@@ -367,6 +371,7 @@ class wxListHeaderWindow : public wxWindow
|
|||||||
long style = 0, const wxString &name = "columntitles" );
|
long style = 0, const wxString &name = "columntitles" );
|
||||||
void DoDrawRect( wxPaintDC *dc, int x, int y, int w, int h );
|
void DoDrawRect( wxPaintDC *dc, int x, int y, int w, int h );
|
||||||
void OnPaint( wxPaintEvent &event );
|
void OnPaint( wxPaintEvent &event );
|
||||||
|
void DrawCurrent();
|
||||||
void OnMouse( wxMouseEvent &event );
|
void OnMouse( wxMouseEvent &event );
|
||||||
void OnSetFocus( wxFocusEvent &event );
|
void OnSetFocus( wxFocusEvent &event );
|
||||||
|
|
||||||
@@ -618,7 +623,7 @@ class wxListCtrl: public wxControl
|
|||||||
bool PopupMenu( wxMenu *menu, int x, int y )
|
bool PopupMenu( wxMenu *menu, int x, int y )
|
||||||
{ return m_mainWin->PopupMenu( menu, x, y ); }
|
{ return m_mainWin->PopupMenu( menu, x, y ); }
|
||||||
|
|
||||||
protected:
|
// implementation
|
||||||
|
|
||||||
// wxListTextCtrl m_textCtrl;
|
// wxListTextCtrl m_textCtrl;
|
||||||
wxImageList *m_imageListNormal;
|
wxImageList *m_imageListNormal;
|
||||||
|
@@ -2,9 +2,8 @@
|
|||||||
// Name: listctrl.cpp
|
// Name: listctrl.cpp
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Author: Robert Roebling
|
// Author: Robert Roebling
|
||||||
// Created: 01/02/97
|
// Id: $Id$
|
||||||
// Id:
|
// Copyright: (c) 1998 Robert Roebling
|
||||||
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
|
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -12,6 +11,8 @@
|
|||||||
#pragma implementation "listctrl.h"
|
#pragma implementation "listctrl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "wx/dcscreen.h"
|
||||||
|
#include "wx/app.h"
|
||||||
#include "wx/listctrl.h"
|
#include "wx/listctrl.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -74,8 +75,8 @@ void wxListItemData::SetPosition( int x, int y )
|
|||||||
|
|
||||||
void wxListItemData::SetSize( int const width, int height )
|
void wxListItemData::SetSize( int const width, int height )
|
||||||
{
|
{
|
||||||
m_width = width;
|
if (width != -1) m_width = width;
|
||||||
m_height = height;
|
if (height != -1) m_height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListItemData::SetColour( wxColour *col )
|
void wxListItemData::SetColour( wxColour *col )
|
||||||
@@ -537,7 +538,7 @@ void wxListLineData::DoDraw( wxPaintDC *dc, bool hilight, bool paintBG )
|
|||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxListItemData *info = (wxListItemData*)node->Data();
|
wxListItemData *info = (wxListItemData*)node->Data();
|
||||||
dc->SetClippingRegion( info->GetX(), info->GetY(), info->GetWidth(), info->GetHeight() );
|
dc->SetClippingRegion( info->GetX(), info->GetY(), info->GetWidth()-3, info->GetHeight() );
|
||||||
info->GetText( s );
|
info->GetText( s );
|
||||||
if (hilight)
|
if (hilight)
|
||||||
dc->SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) );
|
dc->SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) );
|
||||||
@@ -650,6 +651,7 @@ wxListHeaderWindow::wxListHeaderWindow( void )
|
|||||||
m_owner = (wxListMainWindow *) NULL;
|
m_owner = (wxListMainWindow *) NULL;
|
||||||
m_currentCursor = (wxCursor *) NULL;
|
m_currentCursor = (wxCursor *) NULL;
|
||||||
m_resizeCursor = (wxCursor *) NULL;
|
m_resizeCursor = (wxCursor *) NULL;
|
||||||
|
m_isDraging = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxListHeaderWindow::wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMainWindow *owner,
|
wxListHeaderWindow::wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMainWindow *owner,
|
||||||
@@ -722,23 +724,86 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
dc.EndDrawing();
|
dc.EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxListHeaderWindow::DrawCurrent()
|
||||||
|
{
|
||||||
|
int x1 = m_currentX;
|
||||||
|
int y1 = 0;
|
||||||
|
int x2 = m_currentX-1;
|
||||||
|
int y2 = 0;
|
||||||
|
m_owner->GetClientSize( (int*)NULL, &y2 );
|
||||||
|
ClientToScreen( &x1, &y1 );
|
||||||
|
m_owner->ClientToScreen( &x2, &y2 );
|
||||||
|
|
||||||
|
wxScreenDC dc;
|
||||||
|
dc.SetLogicalFunction( wxXOR );
|
||||||
|
dc.SetPen( wxPen( *wxBLACK, 2, wxSOLID ) );
|
||||||
|
dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
||||||
|
|
||||||
|
dc.DrawLine( x1, y1, x2, y2 );
|
||||||
|
|
||||||
|
dc.SetLogicalFunction( wxCOPY );
|
||||||
|
|
||||||
|
dc.SetPen( wxNullPen );
|
||||||
|
dc.SetBrush( wxNullBrush );
|
||||||
|
}
|
||||||
|
|
||||||
void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
|
void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
|
||||||
{
|
{
|
||||||
float fx = 0;
|
int x = event.GetX();
|
||||||
float fy = 0;
|
int y = event.GetY();
|
||||||
event.Position( &fx, &fy );
|
if (m_isDraging)
|
||||||
int x = (int)fx;
|
{
|
||||||
int y = (int)fy;
|
DrawCurrent();
|
||||||
|
if (event.ButtonUp())
|
||||||
|
{
|
||||||
|
// wxScreenDC::EndDrawingOnTop();
|
||||||
|
ReleaseMouse();
|
||||||
|
wxYield(); // for debugging
|
||||||
|
m_isDraging = FALSE;
|
||||||
|
m_owner->SetColumnWidth( m_column, m_currentX-m_minX );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int size_x = 0;
|
||||||
|
GetClientSize( &size_x, (int*) NULL );
|
||||||
|
if (x > m_minX+7)
|
||||||
|
m_currentX = x;
|
||||||
|
else
|
||||||
|
m_currentX = m_minX+7;
|
||||||
|
if (m_currentX > size_x-7) m_currentX = size_x-7;
|
||||||
|
DrawCurrent();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_minX = 0;
|
||||||
|
bool hit_border = FALSE;
|
||||||
|
int xpos = 0;
|
||||||
|
for (int j = 0; j < m_owner->GetColumnCount(); j++)
|
||||||
|
{
|
||||||
|
xpos += m_owner->GetColumnWidth( j );
|
||||||
|
if ((abs(x-xpos) < 3) && (y < 22))
|
||||||
|
{
|
||||||
|
hit_border = TRUE;
|
||||||
|
m_column = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m_minX = xpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.LeftDown() && hit_border)
|
||||||
|
{
|
||||||
|
m_isDraging = TRUE;
|
||||||
|
m_currentX = x;
|
||||||
|
// wxScreenDC::StartDrawingOnTop( m_owner );
|
||||||
|
DrawCurrent();
|
||||||
|
CaptureMouse();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.Moving())
|
if (event.Moving())
|
||||||
{
|
{
|
||||||
bool hit = FALSE;
|
if (hit_border)
|
||||||
int xpos = 0;
|
|
||||||
for (int j = 0; j < m_owner->GetColumnCount(); j++)
|
|
||||||
{
|
|
||||||
xpos += m_owner->GetColumnWidth( j );
|
|
||||||
if ((abs(x-xpos) < 2) && (y < 14)) { hit = TRUE; break; }
|
|
||||||
}
|
|
||||||
if (hit)
|
|
||||||
{
|
{
|
||||||
if (m_currentCursor == wxSTANDARD_CURSOR) SetCursor( m_resizeCursor );
|
if (m_currentCursor == wxSTANDARD_CURSOR) SetCursor( m_resizeCursor );
|
||||||
m_currentCursor = m_resizeCursor;
|
m_currentCursor = m_resizeCursor;
|
||||||
@@ -1514,17 +1579,38 @@ void wxListMainWindow::SetColumn( int col, wxListItem &item )
|
|||||||
wxListHeaderData *column = (wxListHeaderData*)node->Data();
|
wxListHeaderData *column = (wxListHeaderData*)node->Data();
|
||||||
column->SetItem( item );
|
column->SetItem( item );
|
||||||
}
|
}
|
||||||
|
wxListCtrl *lc = (wxListCtrl*) GetParent();
|
||||||
|
if (lc->m_headerWin) lc->m_headerWin->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListMainWindow::SetColumnWidth( int col, int width )
|
void wxListMainWindow::SetColumnWidth( int col, int width )
|
||||||
{
|
{
|
||||||
|
if (!(m_mode & wxLC_REPORT)) return;
|
||||||
|
|
||||||
m_dirty = TRUE;
|
m_dirty = TRUE;
|
||||||
|
|
||||||
wxNode *node = m_columns.Nth( col );
|
wxNode *node = m_columns.Nth( col );
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
wxListHeaderData *column = (wxListHeaderData*)node->Data();
|
wxListHeaderData *column = (wxListHeaderData*)node->Data();
|
||||||
column->SetWidth( width );
|
column->SetWidth( width );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node = m_lines.First();
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
wxListLineData *line = (wxListLineData*)node->Data();
|
||||||
|
wxNode *n = line->m_items.Nth( col );
|
||||||
|
if (n)
|
||||||
|
{
|
||||||
|
wxListItemData *item = (wxListItemData*)n->Data();
|
||||||
|
item->SetSize( width, -1 );
|
||||||
|
}
|
||||||
|
node = node->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxListCtrl *lc = (wxListCtrl*) GetParent();
|
||||||
|
if (lc->m_headerWin) lc->m_headerWin->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListMainWindow::GetColumn( int col, wxListItem &item )
|
void wxListMainWindow::GetColumn( int col, wxListItem &item )
|
||||||
|
@@ -34,8 +34,8 @@ extern "C" {
|
|||||||
#include "gdk/gdkx.h"
|
#include "gdk/gdkx.h"
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
int nevent_masks = 17;
|
int my_nevent_masks = 17;
|
||||||
int event_mask_table[19] =
|
int my_event_masks_table[19] =
|
||||||
{
|
{
|
||||||
ExposureMask,
|
ExposureMask,
|
||||||
PointerMotionMask,
|
PointerMotionMask,
|
||||||
@@ -143,10 +143,10 @@ gdk_window_transparent_new ( GdkWindow *parent,
|
|||||||
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
||||||
|
|
||||||
xattributes.event_mask = StructureNotifyMask;
|
xattributes.event_mask = StructureNotifyMask;
|
||||||
for (i = 0; i < nevent_masks; i++)
|
for (i = 0; i < my_nevent_masks; i++)
|
||||||
{
|
{
|
||||||
if (attributes->event_mask & (1 << (i + 1)))
|
if (attributes->event_mask & (1 << (i + 1)))
|
||||||
xattributes.event_mask |= event_mask_table[i];
|
xattributes.event_mask |= my_event_masks_table[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xattributes.event_mask)
|
if (xattributes.event_mask)
|
||||||
|
@@ -166,7 +166,7 @@ wxFont wxSystemSettings::GetSystemFont( int index )
|
|||||||
case wxSYS_DEFAULT_GUI_FONT:
|
case wxSYS_DEFAULT_GUI_FONT:
|
||||||
{
|
{
|
||||||
if (!g_systemFont)
|
if (!g_systemFont)
|
||||||
g_systemFont = new wxFont( 10, wxSWISS, wxNORMAL, wxNORMAL );
|
g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
|
||||||
return *g_systemFont;
|
return *g_systemFont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,8 +34,8 @@ extern "C" {
|
|||||||
#include "gdk/gdkx.h"
|
#include "gdk/gdkx.h"
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
int nevent_masks = 17;
|
int my_nevent_masks = 17;
|
||||||
int event_mask_table[19] =
|
int my_event_masks_table[19] =
|
||||||
{
|
{
|
||||||
ExposureMask,
|
ExposureMask,
|
||||||
PointerMotionMask,
|
PointerMotionMask,
|
||||||
@@ -143,10 +143,10 @@ gdk_window_transparent_new ( GdkWindow *parent,
|
|||||||
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
||||||
|
|
||||||
xattributes.event_mask = StructureNotifyMask;
|
xattributes.event_mask = StructureNotifyMask;
|
||||||
for (i = 0; i < nevent_masks; i++)
|
for (i = 0; i < my_nevent_masks; i++)
|
||||||
{
|
{
|
||||||
if (attributes->event_mask & (1 << (i + 1)))
|
if (attributes->event_mask & (1 << (i + 1)))
|
||||||
xattributes.event_mask |= event_mask_table[i];
|
xattributes.event_mask |= my_event_masks_table[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xattributes.event_mask)
|
if (xattributes.event_mask)
|
||||||
|
@@ -166,7 +166,7 @@ wxFont wxSystemSettings::GetSystemFont( int index )
|
|||||||
case wxSYS_DEFAULT_GUI_FONT:
|
case wxSYS_DEFAULT_GUI_FONT:
|
||||||
{
|
{
|
||||||
if (!g_systemFont)
|
if (!g_systemFont)
|
||||||
g_systemFont = new wxFont( 10, wxSWISS, wxNORMAL, wxNORMAL );
|
g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
|
||||||
return *g_systemFont;
|
return *g_systemFont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user