Scale default wxGrid constants by DPI
In particular, this makes default column width better suited for high DPI displays, as it was too narrow before. Also mark a couple of obsolete constants as such with a comment.
This commit is contained in:
parent
06af121e9c
commit
59ad458d39
@ -25,8 +25,8 @@
|
||||
|
||||
extern WXDLLIMPEXP_DATA_CORE(const char) wxGridNameStr[];
|
||||
|
||||
// Default parameters for wxGrid
|
||||
//
|
||||
// Obsolete constants not used by wxWidgets itself any longer, preserved only
|
||||
// for compatibility.
|
||||
#define WXGRID_DEFAULT_NUMBER_ROWS 10
|
||||
#define WXGRID_DEFAULT_NUMBER_COLS 10
|
||||
#if defined(__WXMSW__) || defined(__WXGTK20__)
|
||||
@ -34,13 +34,18 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxGridNameStr[];
|
||||
#else
|
||||
#define WXGRID_DEFAULT_ROW_HEIGHT 30
|
||||
#endif // __WXMSW__
|
||||
#define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
|
||||
|
||||
// Various constants used in wxGrid code.
|
||||
//
|
||||
// Note that all the values are in DIPs, not pixels, i.e. you must use
|
||||
// FromDIP() when using them in your code.
|
||||
#define WXGRID_DEFAULT_COL_WIDTH 80
|
||||
#define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32
|
||||
#define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82
|
||||
#define WXGRID_LABEL_EDGE_ZONE 2
|
||||
#define WXGRID_MIN_ROW_HEIGHT 15
|
||||
#define WXGRID_MIN_COL_WIDTH 15
|
||||
#define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
|
||||
|
||||
// type names for grid table values
|
||||
#define wxGRID_VALUE_STRING wxT("string")
|
||||
@ -1372,9 +1377,9 @@ public:
|
||||
|
||||
// ------ label and gridline formatting
|
||||
//
|
||||
int GetDefaultRowLabelSize() const { return WXGRID_DEFAULT_ROW_LABEL_WIDTH; }
|
||||
int GetDefaultRowLabelSize() const { return FromDIP(WXGRID_DEFAULT_ROW_LABEL_WIDTH); }
|
||||
int GetRowLabelSize() const { return m_rowLabelWidth; }
|
||||
int GetDefaultColLabelSize() const { return WXGRID_DEFAULT_COL_LABEL_HEIGHT; }
|
||||
int GetDefaultColLabelSize() const { return FromDIP(WXGRID_DEFAULT_COL_LABEL_HEIGHT); }
|
||||
int GetColLabelSize() const { return m_colLabelHeight; }
|
||||
wxColour GetLabelBackgroundColour() const { return m_labelBackgroundColour; }
|
||||
wxColour GetLabelTextColour() const { return m_labelTextColour; }
|
||||
|
@ -2466,6 +2466,13 @@ void wxGrid::Create()
|
||||
m_defaultRowHeight += 4;
|
||||
#endif
|
||||
|
||||
m_rowLabelWidth = FromDIP(WXGRID_DEFAULT_ROW_LABEL_WIDTH);
|
||||
m_colLabelHeight = FromDIP(WXGRID_DEFAULT_COL_LABEL_HEIGHT);
|
||||
|
||||
m_defaultColWidth = FromDIP(WXGRID_DEFAULT_COL_WIDTH);
|
||||
|
||||
m_minAcceptableColWidth = FromDIP(WXGRID_MIN_COL_WIDTH);
|
||||
m_minAcceptableRowHeight = FromDIP(WXGRID_MIN_ROW_HEIGHT);
|
||||
}
|
||||
|
||||
void wxGrid::CreateColumnWindow()
|
||||
@ -2478,7 +2485,7 @@ void wxGrid::CreateColumnWindow()
|
||||
else // draw labels ourselves
|
||||
{
|
||||
m_colLabelWin = new wxGridColLabelWindow(this);
|
||||
m_colLabelHeight = WXGRID_DEFAULT_COL_LABEL_HEIGHT;
|
||||
m_colLabelHeight = FromDIP(WXGRID_DEFAULT_COL_LABEL_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2630,9 +2637,6 @@ void wxGrid::Init()
|
||||
m_defaultCellAttr = NULL;
|
||||
m_typeRegistry = NULL;
|
||||
|
||||
m_rowLabelWidth = WXGRID_DEFAULT_ROW_LABEL_WIDTH;
|
||||
m_colLabelHeight = WXGRID_DEFAULT_COL_LABEL_HEIGHT;
|
||||
|
||||
m_setFixedRows =
|
||||
m_setFixedCols = NULL;
|
||||
|
||||
@ -2655,11 +2659,15 @@ void wxGrid::Init()
|
||||
m_cornerLabelVertAlign = wxALIGN_CENTRE;
|
||||
m_cornerLabelTextOrientation = wxHORIZONTAL;
|
||||
|
||||
m_defaultColWidth = WXGRID_DEFAULT_COL_WIDTH;
|
||||
m_defaultRowHeight = 0; // this will be initialized after creation
|
||||
// All these fields require a valid window, so are initialized in Create().
|
||||
m_rowLabelWidth =
|
||||
m_colLabelHeight = 0;
|
||||
|
||||
m_minAcceptableColWidth = WXGRID_MIN_COL_WIDTH;
|
||||
m_minAcceptableRowHeight = WXGRID_MIN_ROW_HEIGHT;
|
||||
m_defaultColWidth =
|
||||
m_defaultRowHeight = 0;
|
||||
|
||||
m_minAcceptableColWidth =
|
||||
m_minAcceptableRowHeight = 0;
|
||||
|
||||
m_gridLineColour = wxColour( 192,192,192 );
|
||||
m_gridLinesEnabled = true;
|
||||
@ -7322,15 +7330,15 @@ int wxGrid::PosToEdgeOfLine(int pos, const wxGridOperations& oper) const
|
||||
if ( line == wxNOT_FOUND )
|
||||
return -1;
|
||||
|
||||
if ( oper.GetLineSize(this, line) > WXGRID_LABEL_EDGE_ZONE )
|
||||
const int edge = FromDIP(WXGRID_LABEL_EDGE_ZONE);
|
||||
|
||||
if ( oper.GetLineSize(this, line) > edge )
|
||||
{
|
||||
// We know that we are in this line, test whether we are close enough
|
||||
// to start or end border, respectively.
|
||||
if ( abs(oper.GetLineEndPos(this, line) - pos) < WXGRID_LABEL_EDGE_ZONE )
|
||||
if ( abs(oper.GetLineEndPos(this, line) - pos) < edge )
|
||||
return line;
|
||||
else if ( line > 0 &&
|
||||
pos - oper.GetLineStartPos(this,
|
||||
line) < WXGRID_LABEL_EDGE_ZONE )
|
||||
else if ( line > 0 && pos - oper.GetLineStartPos(this, line) < edge )
|
||||
{
|
||||
// We need to find the previous visible line, so skip all the
|
||||
// hidden (of size 0) ones.
|
||||
|
Loading…
Reference in New Issue
Block a user