- Suppressed spurious character event for decimal key in numeric keypad.
- Allow to not create wxPaintDC in EVT_PAINT handler.
- Fix sending of wxEVT_COMMAND_LIST_COL_DRAGGING events in wxListCtrl.
+- Allow putting the UAC symbol on buttons (Chris Spencer).
i18n:
public:
wxButtonBase() { }
+ // show the authentication needed symbol on the button: this is currently
+ // only implemented on Windows Vista and newer (on which it shows the UAC
+ // shield symbol)
+ void SetAuthNeeded(bool show = true) { DoSetAuthNeeded(show); }
+ bool GetAuthNeeded() const { return DoGetAuthNeeded(); }
+
// show the image in the button in addition to the label: this method is
// supported on all (major) platforms
void SetBitmap(const wxBitmap& bitmap, wxDirection dir = wxLEFT)
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
+ virtual bool DoGetAuthNeeded() const { return false; }
+ virtual void DoSetAuthNeeded(bool WXUNUSED(show)) { }
+
virtual wxBitmap DoGetBitmap(State WXUNUSED(which)) const
{ return wxBitmap(); }
virtual void DoSetBitmap(const wxBitmap& WXUNUSED(bitmap),
// usually overridden base class virtuals
virtual wxSize DoGetBestSize() const;
+ virtual bool DoGetAuthNeeded() const;
+ virtual void DoSetAuthNeeded(bool show);
virtual wxBitmap DoGetBitmap(State which) const;
virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
virtual wxSize DoGetBitmapMargins() const;
class wxButtonImageData *m_imageData;
+ // true if the UAC symbol is shown
+ bool m_authNeeded;
+
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxButton)
};
// depending on whether the label contains the new lines
void UpdateMultilineStyle(HWND hwnd, const wxString& label);
+// flags for ComputeBestSize() and GetFittingSize()
+enum
+{
+ Size_AuthNeeded = 1
+};
+
// common implementation of wxButton and wxToggleButton::DoGetBestSize()
// (implemented in src/msw/button.cpp)
-wxSize ComputeBestSize(wxControl *btn);
+wxSize ComputeBestSize(wxControl *btn, int flags = 0);
// compute the button size (as if wxBU_EXACTFIT were specified, i.e. without
// adjusting it to be of default size if it's smaller) for the given label size
-wxSize GetFittingSize(wxWindow *win, const wxSize& sizeLabel);
+wxSize GetFittingSize(wxWindow *win, const wxSize& sizeLabel, int flags = 0);
} // namespace wxMSWButton
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
+ /**
+ Returns @true if an authentication needed symbol is displayed on the
+ button.
+
+ @remarks This method always returns @false if the platform is not
+ Windows Vista or newer.
+
+ @see SetAuthNeeded()
+
+ @since 2.9.1
+ */
+ bool GetAuthNeeded() const;
+
/**
Return the bitmap shown by the button.
*/
wxString GetLabel() const;
+ /**
+ Sets whether an authentication needed symbol should be displayed on the
+ button.
+
+ @remarks This method doesn't do anything if the platform is not Windows
+ Vista or newer.
+
+ @see GetAuthNeeded()
+
+ @since 2.9.1
+ */
+ void SetAuthNeeded(bool needed = true);
+
/**
Sets the bitmap to display in the button.
wxCheckBox *m_chkBitmapOnly,
*m_chkTextAndBitmap,
*m_chkFit,
+ *m_chkAuthNeeded,
*m_chkDefault;
// more checkboxes for wxBitmapButton only
m_chkBitmapOnly =
m_chkTextAndBitmap =
m_chkFit =
+ m_chkAuthNeeded =
m_chkDefault =
m_chkUsePressed =
m_chkUseFocused =
wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
m_chkBitmapOnly = CreateCheckBoxAndAddToSizer(sizerLeft, "&Bitmap only");
- m_chkTextAndBitmap = CreateCheckBoxAndAddToSizer(sizerLeft, "Text &and &bitmap");
+ m_chkTextAndBitmap = CreateCheckBoxAndAddToSizer(sizerLeft, "Text &and bitmap");
m_chkFit = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Fit exactly"));
+ m_chkAuthNeeded = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("Require a&uth"));
m_chkDefault = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Default"));
sizerLeft->AddSpacer(5);
{
m_chkBitmapOnly->SetValue(false);
m_chkFit->SetValue(true);
+ m_chkAuthNeeded->SetValue(false);
m_chkTextAndBitmap->SetValue(false);
m_chkDefault->SetValue(false);
m_chkUseCurrent->Enable(showsBitmap);
m_chkUseDisabled->Enable(showsBitmap);
+ if ( m_chkAuthNeeded->GetValue() )
+ m_button->SetAuthNeeded();
+
if ( m_chkDefault->GetValue() )
- {
m_button->SetDefault();
- }
AddButtonToSizer();
#define DT_HIDEPREFIX 0x00100000
#endif
+// set the value for BCM_SETSHIELD (for the UAC shield) if it's not defined in
+// the header
+#ifndef BCM_SETSHIELD
+ #define BCM_SETSHIELD 0x160c
+#endif
+
// ----------------------------------------------------------------------------
// button image data
// ----------------------------------------------------------------------------
::SetWindowLong(hwnd, GWL_STYLE, styleNew);
}
-wxSize wxMSWButton::GetFittingSize(wxWindow *win, const wxSize& sizeLabel)
+wxSize wxMSWButton::GetFittingSize(wxWindow *win,
+ const wxSize& sizeLabel,
+ int flags)
{
// FIXME: this is pure guesswork, need to retrieve the real button margins
wxSize sizeBtn = sizeLabel;
sizeBtn.x += 3*win->GetCharWidth();
sizeBtn.y = 11*EDIT_HEIGHT_FROM_CHAR_HEIGHT(sizeLabel.y)/10;
+ // account for the shield UAC icon if we have it
+ if ( flags & Size_AuthNeeded )
+ sizeBtn.x += wxSystemSettings::GetMetric(wxSYS_SMALLICON_X);
+
return sizeBtn;
}
-wxSize wxMSWButton::ComputeBestSize(wxControl *btn)
+wxSize wxMSWButton::ComputeBestSize(wxControl *btn, int flags)
{
wxClientDC dc(btn);
wxSize sizeBtn;
dc.GetMultiLineTextExtent(btn->GetLabelText(), &sizeBtn.x, &sizeBtn.y);
- sizeBtn = GetFittingSize(btn, sizeBtn);
+ sizeBtn = GetFittingSize(btn, sizeBtn, flags);
// all buttons have at least the standard size unless the user explicitly
// wants them to be of smaller size and used wxBU_EXACTFIT style when
const wxValidator& validator,
const wxString& name)
{
+ m_authNeeded = false;
+
wxString label(lbl);
if (label.empty() && wxIsStockID(id))
{
// zero size)
if ( ShowsLabel() || !m_imageData )
{
- size = wxMSWButton::ComputeBestSize(const_cast<wxButton *>(this));
+ int flags = 0;
+ if ( GetAuthNeeded() )
+ flags |= wxMSWButton::Size_AuthNeeded;
+
+ size = wxMSWButton::ComputeBestSize(const_cast<wxButton *>(this), flags);
}
if ( m_imageData )
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
}
+// ----------------------------------------------------------------------------
+// authentication needed handling
+// ----------------------------------------------------------------------------
+
+bool wxButton::DoGetAuthNeeded() const
+{
+ return m_authNeeded;
+}
+
+void wxButton::DoSetAuthNeeded(bool show)
+{
+ // show/hide UAC symbol on Windows Vista and later
+ if ( wxGetWinVersion() >= wxWinVersion_6 )
+ {
+ m_authNeeded = show;
+ ::SendMessage(GetHwnd(), BCM_SETSHIELD, 0, show);
+ InvalidateBestSize();
+ }
+}
+
// ----------------------------------------------------------------------------
// button images
// ----------------------------------------------------------------------------