mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 13:37:00 -04:00
Width of labels in native look editor is adjusted based on the longest label
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@449 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -58,6 +58,23 @@ void NativeLookEditor::resizeViewers() {
|
|||||||
int w, h;
|
int w, h;
|
||||||
GetClientSize(&w, &h);
|
GetClientSize(&w, &h);
|
||||||
const int default_height = 17;
|
const int default_height = 17;
|
||||||
|
// Determine label width
|
||||||
|
{
|
||||||
|
label_width = 0;
|
||||||
|
wxClientDC dc(this);
|
||||||
|
dc.SetFont(*wxNORMAL_FONT);
|
||||||
|
FOR_EACH(v, viewers) {
|
||||||
|
ValueEditor* e = v->getEditor();
|
||||||
|
if (!e || e->drawLabel()) {
|
||||||
|
// width of the label string
|
||||||
|
int w;
|
||||||
|
Style& s = *v->getStyle();
|
||||||
|
String text = tr(*set->game, s.fieldP->name, capitalize_sentence(s.fieldP->name));
|
||||||
|
dc.GetTextExtent(text,&w,nullptr);
|
||||||
|
label_width = max(label_width, w + label_margin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Set editor sizes
|
// Set editor sizes
|
||||||
FOR_EACH(v, viewers) {
|
FOR_EACH(v, viewers) {
|
||||||
StyleP s = v->getStyle();
|
StyleP s = v->getStyle();
|
||||||
|
|||||||
@@ -35,10 +35,11 @@ class NativeLookEditor : public DataEditor {
|
|||||||
virtual void onInit();
|
virtual void onInit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const UInt margin = 6;
|
static const int margin = 6;
|
||||||
static const UInt margin_left = 4;
|
static const int margin_left = 4;
|
||||||
static const UInt label_width = 150;
|
static const int vspace = 10;
|
||||||
static const UInt vspace = 10;
|
static const int label_margin = 10;
|
||||||
|
int label_width;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user