本文整理汇总了C++中wxGetCharSize函数的典型用法代码示例。如果您正苦于以下问题:C++ wxGetCharSize函数的具体用法?C++ wxGetCharSize怎么用?C++ wxGetCharSize使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxGetCharSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxGetWindowText
wxSize wxToggleButton::DoGetBestSize() const
{
wxString label = wxGetWindowText(GetHWND());
int wBtn;
wxFont vFont = GetFont();
int wChar;
int hChar;
GetTextExtent(label, &wBtn, NULL);
wxGetCharSize(GetHWND(), &wChar, &hChar, &vFont);
// add a margin - the button is wider than just its label
wBtn += 3*wChar;
// the button height is proportional to the height of the font used
int hBtn = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
#if wxUSE_BUTTON
wxSize sz = wxButton::GetDefaultSize();
if (wBtn > sz.x)
sz.x = wBtn;
if (hBtn > sz.y)
sz.y = hBtn;
#else
wxSize sz(wBtn, hBtn);
#endif
return sz;
}
示例2: wxGetCharSize
wxSize wxStaticBox::DoGetBestSize() const
{
wxSize best;
// Calculate the size needed by the label
int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
int wBox;
GetTextExtent(GetLabelText(wxGetWindowText(m_hWnd)), &wBox, &cy);
wBox += 3*cx;
int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
// If there is a sizer then the base best size is the sizer's minimum
if (GetSizer() != NULL)
{
wxSize cm(GetSizer()->CalcMin());
best = ClientToWindowSize(cm);
// adjust for a long label if needed
best.x = wxMax(best.x, wBox);
}
// otherwise the best size falls back to the label size
else
{
best = wxSize(wBox, hBox);
}
return best;
}
示例3: wxGetCharSize
int wxChoice::SetHeightSimpleComboBox(int nItems) const
{
int cx, cy;
wxGetCharSize( GetHWND(), &cx, &cy, GetFont() );
int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, (WPARAM)-1, 0);
return EDIT_HEIGHT_FROM_CHAR_HEIGHT( cy ) * wxMin( wxMax( nItems, 3 ), 6 ) + hItem - 1;
}
示例4: wxGetWindowText
wxSize wxToggleButton::DoGetBestSize() const
{
wxString label = wxGetWindowText(GetHWND());
int wBtn;
GetTextExtent(GetLabelText(label), &wBtn, NULL);
int wChar, hChar;
wxGetCharSize(GetHWND(), &wChar, &hChar, GetFont());
// add a margin - the button is wider than just its label
wBtn += 3*wChar;
// the button height is proportional to the height of the font used
int hBtn = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
#if wxUSE_BUTTON
// make all buttons of at least standard size unless wxBU_EXACTFIT is given
if ( !HasFlag(wxBU_EXACTFIT) )
{
const wxSize szMin = wxButton::GetDefaultSize();
if ( wBtn < szMin.x )
wBtn = szMin.x;
if ( hBtn < szMin.y )
hBtn = szMin.y;
}
#endif // wxUSE_BUTTON
wxSize sz(wBtn, hBtn);
CacheBestSize(sz);
return sz;
}
示例5: GetCount
wxSize wxChoice::DoGetBestSize() const
{
//
// Find the widest string
//
int nLineWidth;
int nChoiceWidth = 0;
int nItems = GetCount();
int nCx;
int nCy;
wxFont vFont = (wxFont)GetFont();
for (int i = 0; i < nItems; i++)
{
wxString sStr(GetString(i));
GetTextExtent( sStr
,&nLineWidth
,NULL
);
if (nLineWidth > nChoiceWidth)
nChoiceWidth = nLineWidth;
}
//
// Give it some reasonable default value if there are no strings in the
// list
//
if (nChoiceWidth == 0L)
nChoiceWidth = 100L;
//
// The combobox should be larger than the widest string
//
wxGetCharSize( GetHWND()
,&nCx
,&nCy
,&vFont
);
nChoiceWidth += 5 * nCx;
//
// Choice drop-down list depends on number of items (limited to 10)
//
size_t nStrings = nItems == 0 ? 10 : wxMin(10, nItems) + 1;
int nChoiceHeight = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * nStrings;
return wxSize( nChoiceWidth
,nChoiceHeight
);
} // end of wxChoice::DoGetBestSize
示例6: wxGetCharSize
wxSize wxStaticBox::DoGetBestSize() const
{
int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
int wBox;
GetTextExtent(GetLabelText(wxGetWindowText(m_hWnd)), &wBox, &cy);
wBox += 3*cx;
int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
wxSize best(wBox, hBox);
CacheBestSize(best);
return best;
}
示例7: wxGetWindowText
wxSize wxButton::DoGetBestSize() const
{
wxString rsLabel = wxGetWindowText(GetHWND());
int nWidthButton;
int nWidthChar;
int nHeightChar;
wxFont vFont = (wxFont)GetFont();
GetTextExtent( rsLabel
,&nWidthButton
,NULL
);
wxGetCharSize( GetHWND()
,&nWidthChar
,&nHeightChar
,&vFont
);
//
// Add a margin - the button is wider than just its label
//
nWidthButton += 3 * nWidthChar;
//
// The button height is proportional to the height of the font used
//
int nHeightButton = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(nHeightChar);
//
// Need a little extra to make it look right
//
nHeightButton += (int)(nHeightChar/1.5);
if (!HasFlag(wxBU_EXACTFIT))
{
wxSize vSize = GetDefaultSize();
if (nWidthButton > vSize.x)
vSize.x = nWidthButton;
if (nHeightButton > vSize.y)
vSize.y = nHeightButton;
return vSize;
}
return wxSize( nWidthButton
,nHeightButton
);
} // end of wxButton::DoGetBestSize
示例8: vStr
wxSize wxListBox::DoGetBestSize() const
{
//
// Find the widest string
//
int nLine;
int nListbox = 0;
int nCx;
int nCy;
wxFont vFont = (wxFont)GetFont();
for (int i = 0; i < m_nNumItems; i++)
{
wxString vStr(GetString(i));
GetTextExtent( vStr
,&nLine
,NULL
);
if (nLine > nListbox)
nListbox = nLine;
}
//
// Give it some reasonable default value if there are no strings in the
// list.
//
if (nListbox == 0)
nListbox = 100;
//
// The listbox should be slightly larger than the widest string
//
wxGetCharSize( GetHWND()
,&nCx
,&nCy
,&vFont
);
nListbox += 3 * nCx;
int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * (wxMax(m_nNumItems, 7));
return wxSize( nListbox
,hListbox
);
} // end of wxListBox::DoGetBestSize
示例9: wxGetCharSize
wxSize wxTextCtrl::DoGetBestSize() const
{
int nCx;
int nCy;
wxFont vFont = (wxFont)GetFont();
wxGetCharSize(GetHWND(), &nCx, &nCy, &vFont);
int wText = DEFAULT_ITEM_WIDTH;
int hText = (int)(EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * .8);
if (m_windowStyle & wxTE_MULTILINE)
{
hText *= wxMax(GetNumberOfLines(), 5);
}
//else: for single line control everything is ok
return wxSize(wText, hText);
} // end of wxTextCtrl::DoGetBestSize
示例10: wxGetCharSize
wxSize wxSpinCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const
{
wxSize sizeBtn = wxSpinButton::DoGetBestSize();
int y;
wxGetCharSize(GetHWND(), NULL, &y, GetFont());
// JACS: we should always use the height calculated
// from above, because otherwise we'll get a spin control
// that's too big. So never use the height calculated
// from wxSpinButton::DoGetBestSize().
wxSize tsize(xlen + sizeBtn.x + MARGIN_BETWEEN + 3*y/10 + 10,
EDIT_HEIGHT_FROM_CHAR_HEIGHT(y));
// Check if the user requested a non-standard height.
if ( ylen > 0 )
tsize.IncBy(0, ylen - y);
return tsize;
}
示例11: wxGetCharSize
wxSize wxTextCtrl::DoGetBestSize() const
{
int cx, cy;
wxGetCharSize(GetBuddyHwnd(), &cx, &cy, GetFont());
int wText = DEFAULT_ITEM_WIDTH;
int hText = cy;
if ( m_windowStyle & wxTE_MULTILINE )
{
hText *= wxMax(GetNumberOfLines(), 5);
}
//else: for single line control everything is ok
// we have to add the adjustments for the control height only once, not
// once per line, so do it after multiplication above
hText += EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) - cy;
return wxSize(wText, hText);
}
示例12: wxGetCharSize
wxSize wxSpinCtrl::DoGetBestSize() const
{
wxSize sizeBtn = wxSpinButton::DoGetBestSize();
sizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN;
int y;
wxGetCharSize(GetHWND(), NULL, &y, GetFont());
y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(y);
// JACS: we should always use the height calculated
// from above, because otherwise we'll get a spin control
// that's too big. So never use the height calculated
// from wxSpinButton::DoGetBestSize().
// if ( sizeBtn.y < y )
{
// make the text tall enough
sizeBtn.y = y;
}
return sizeBtn;
}
示例13: wxGetCharSize
wxSize wxRadioBox::GetTotalButtonSize(const wxSize& sizeBtn) const
{
// the radiobox should be big enough for its buttons
int cx1, cy1;
wxGetCharSize(m_hWnd, &cx1, &cy1, GetFont());
int extraHeight = cy1;
int height = GetRowCount() * sizeBtn.y + cy1/2 + extraHeight;
int width = GetColumnCount() * (sizeBtn.x + cx1) + cx1;
// Add extra space under the label, if it exists.
if (!wxControl::GetLabel().empty())
height += cy1/2;
// and also wide enough for its label
int widthLabel;
GetTextExtent(GetLabelText(), &widthLabel, NULL);
widthLabel += RADIO_SIZE; // FIXME this is bogus too
if ( widthLabel > width )
width = widthLabel;
return wxSize(width, height);
}
示例14: wxGetCharSize
wxSize wxSpinCtrl::DoGetBestSize() const
{
wxSize vSizeBtn = wxSpinButton::DoGetBestSize();
int nHeight;
wxFont vFont = (wxFont)GetFont();
vSizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN;
wxGetCharSize( GetHWND()
,NULL
,&nHeight
,&vFont
);
nHeight = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nHeight)+4;
if (vSizeBtn.y < nHeight)
{
//
// Make the text tall enough
//
vSizeBtn.y = nHeight;
}
return vSizeBtn;
} // end of wxSpinCtrl::DoGetBestSize
示例15: str
wxSize wxListBox::DoGetBestSize() const
{
// find the widest string
int wLine;
int wListbox = 0;
for (unsigned int i = 0; i < m_noItems; i++)
{
wxString str(GetString(i));
GetTextExtent(str, &wLine, NULL);
if ( wLine > wListbox )
wListbox = wLine;
}
// give it some reasonable default value if there are no strings in the
// list
if ( wListbox == 0 )
wListbox = 100;
// the listbox should be slightly larger than the widest string
int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
wListbox += 3*cx;
// Add room for the scrollbar
wListbox += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
// don't make the listbox too tall (limit height to 10 items) but don't
// make it too small neither
int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*
wxMin(wxMax(m_noItems, 3), 10);
wxSize best(wListbox, hListbox);
CacheBestSize(best);
return best;
}