// wxControl-specific processing after processing the update event void wxControlBase::DoUpdateWindowUI(wxUpdateUIEvent& event) { // call inherited wxWindowBase::DoUpdateWindowUI(event); // update label if ( event.GetSetText() ) { if ( event.GetText() != GetLabel() ) SetLabel(event.GetText()); } // Unfortunately we don't yet have common base class for // wxRadioButton, so we handle updates of radiobuttons here. // TODO: If once wxRadioButtonBase will exist, move this code there. #if wxUSE_RADIOBTN if ( event.GetSetChecked() ) { wxRadioButton *radiobtn = wxDynamicCastThis(wxRadioButton); if ( radiobtn ) radiobtn->SetValue(event.GetChecked()); } #endif // wxUSE_RADIOBTN }
bool wxControl::MSWCreateControl(const wxChar *classname, WXDWORD style, const wxPoint& pos, const wxSize& size, const wxString& label, WXDWORD exstyle) { // if no extended style given, determine it ourselves if ( exstyle == (WXDWORD)-1 ) { exstyle = 0; (void) MSWGetStyle(GetWindowStyle(), &exstyle); } // all controls should have this style style |= WS_CHILD; // create the control visible if it's currently shown for wxWidgets if ( m_isShown ) { style |= WS_VISIBLE; } // choose the position for the control: we have a problem with default size // here as we can't calculate the best size before the control exists // (DoGetBestSize() may need to use m_hWnd), so just choose the minimal // possible but non 0 size because 0 window width/height result in problems // elsewhere int x = pos.x == wxDefaultCoord ? 0 : pos.x, y = pos.y == wxDefaultCoord ? 0 : pos.y, w = size.x == wxDefaultCoord ? 1 : size.x, h = size.y == wxDefaultCoord ? 1 : size.y; // ... and adjust it to account for a possible parent frames toolbar AdjustForParentClientOrigin(x, y); m_hWnd = (WXHWND)::CreateWindowEx ( exstyle, // extended style classname, // the kind of control to create label.t_str(), // the window name style, // the window style x, y, w, h, // the window position and size GetHwndOf(GetParent()), // parent (HMENU)wxUIntToPtr(GetId()), // child id wxGetInstance(), // app instance NULL // creation parameters ); if ( !m_hWnd ) { wxLogLastError(wxString::Format ( wxT("CreateWindowEx(\"%s\", flags=%08lx, ex=%08lx)"), classname, style, exstyle )); return false; } #if !wxUSE_UNICODE // Text labels starting with the character 0xff (which is a valid character // in many code pages) don't appear correctly as CreateWindowEx() has some // special treatment for this case, apparently the strings starting with -1 // are not really strings but something called "ordinals". There is no // documentation about it but the fact is that the label gets mangled or // not displayed at all if we don't do this, see #9572. // // Notice that 0xffff is not a valid Unicode character so the problem // doesn't arise in Unicode build. if ( !label.empty() && label[0] == -1 ) ::SetWindowText(GetHwnd(), label.t_str()); #endif // !wxUSE_UNICODE // saving the label in m_labelOrig to return it verbatim // later in GetLabel() m_labelOrig = label; // install wxWidgets window proc for this window SubclassWin(m_hWnd); // set up fonts and colours InheritAttributes(); if ( !m_hasFont ) { bool setFont = true; wxFont font = GetDefaultAttributes().font; // if we set a font for {list,tree}ctrls and the font size is changed in // the display properties then the font size for these controls doesn't // automatically adjust when they receive WM_SETTINGCHANGE // FIXME: replace the dynamic casts with virtual function calls!! #if wxUSE_LISTCTRL || wxUSE_TREECTRL bool testFont = false; #if wxUSE_LISTCTRL if ( wxDynamicCastThis(wxListCtrl) ) testFont = true; #endif // wxUSE_LISTCTRL #if wxUSE_TREECTRL if ( wxDynamicCastThis(wxTreeCtrl) ) testFont = true; #endif // wxUSE_TREECTRL if ( testFont ) { // not sure if we need to explicitly set the font here for Win95/NT4 // but we definitely can't do it for any newer version // see wxGetCCDefaultFont() in src/msw/settings.cpp for explanation // of why this test works // TODO: test Win95/NT4 to see if this is needed or breaks the // font resizing as it does on newer versions if ( font != wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) ) { setFont = false; } } #endif // wxUSE_LISTCTRL || wxUSE_TREECTRL if ( setFont ) { SetFont(GetDefaultAttributes().font); } } // set the size now if no initial size specified SetInitialSize(size); return true; }