// we don't want focus for ourselves
virtual bool AcceptsFocus() const { return false; }
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
// flags for DoSetSelection()
enum
wxBORDER_SIMPLE = 0x02000000,
wxBORDER_RAISED = 0x04000000,
wxBORDER_SUNKEN = 0x08000000,
- wxBORDER_DOUBLE = 0x10000000,
+ wxBORDER_DOUBLE = 0x10000000, /* deprecated */
+ wxBORDER_THEME = 0x10000000,
/* a mask to extract border style from the combination of flags */
wxBORDER_MASK = 0x1f200000
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
private:
void MakeOwnerDrawn();
virtual bool SetForegroundColour(const wxColour& colour);
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
virtual wxSize DoGetBestSize() const;
virtual bool MSWShouldPreProcessMessage(WXMSG *pMsg);
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
// common part of all ctors
void Init() { m_lastAcceptedSelection = wxID_NONE; }
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
virtual wxSize DoGetBestSize() const;
WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
virtual wxSize DoGetBestSize() const;
return GetCompositeControlsDefaultAttributes(variant);
}
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
virtual void DoSetSelection(int n, bool select);
// it to behave normally
virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); }
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
void SetLabelFont(const wxFont& WXUNUSED(font)) {}
void SetButtonFont(const wxFont& font) { SetFont(font); }
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
virtual wxSize DoGetBestSize() const;
// we should let background show through the slider (and its labels)
virtual bool HasTransparentBackground() { return true; }
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
void Command(wxCommandEvent& event);
virtual bool MSWOnScroll(int orientation, WXWORD wParam,
// a wxSpinButton can't do anything useful with focus, only wxSpinCtrl can
virtual bool AcceptsFocus() const { return false; }
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
virtual wxSize DoGetBestSize() const;
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
virtual wxBorder GetDefaultBorder() const;
virtual wxSize DoGetBestSize() const;
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
virtual wxSize DoGetBestSize() const;
virtual bool AcceptsFocus() const;
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const;
+
// callbacks
void OnDropFiles(wxDropFilesEvent& event);
void OnChar(wxKeyEvent& event); // Process 'enter' if required
virtual void Command(wxCommandEvent& event);
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
virtual wxSize DoGetBestSize() const;
virtual wxBorder GetDefaultBorder() const;
// window proc for the frames
WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
// common part of all ctors
void Init();
void SetState(const wxTreeItemId& node, int state);
int GetState(const wxTreeItemId& node);
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
protected:
// SetImageList helper
void SetAnyImageList(wxImageList *imageList, int which);
// check if a native double-buffering applies for this window
virtual bool IsDoubleBuffered() const;
+ // this allows you to implement standard control borders without
+ // repeating the code in different classes that are not derived from
+ // wxControl
+ virtual wxBorder GetDefaultBorderForControl() const;
+
// synthesize a wxEVT_LEAVE_WINDOW event and set m_mouseInWindow to false
void GenerateMouseLeave();
m_value = -1;
}
- virtual bool Create( wxWindow* parent )
- {
- return wxRichTextStyleListBox::Create(parent, wxID_ANY,
- wxPoint(0,0), wxDefaultSize,
- wxSIMPLE_BORDER);
- }
+ virtual bool Create( wxWindow* parent );
virtual wxWindow *GetControl() { return this; }
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+ virtual wxBorder GetDefaultBorder() const { return GetDefaultBorderForControl(); }
+
protected:
// the derived class must implement this function to actually draw the item
// with the given index on the provided DC
// area (normal windows can't, but e.g. menubar or statusbar can):
virtual bool CanBeOutsideClientArea() const { return false; }
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return true; }
+
protected:
// event handling specific to wxWindow
virtual bool TryValidator(wxEvent& event);
// specified) border for the window class
virtual wxBorder GetDefaultBorder() const;
+ // this allows you to implement standard control borders without
+ // repeating the code in different classes that are not derived from
+ // wxControl
+ virtual wxBorder GetDefaultBorderForControl() const { return wxWindowBase::GetDefaultBorder(); }
+
// Get the default size for the new window if no explicit size given. TLWs
// have their own default size so this is just for non top-level windows.
static int WidthDefault(int w) { return w == wxDefaultCoord ? 20 : w; }
toolBar->Realize();
- wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, GetClientSize(), wxSP_NO_XP_THEME|wxSP_3D|wxSP_LIVE_UPDATE);
+ wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, GetClientSize(), wxSP_LIVE_UPDATE);
wxFont textFont = wxFont(12, wxROMAN, wxNORMAL, wxNORMAL);
wxFont boldFont = wxFont(12, wxROMAN, wxNORMAL, wxBOLD);
wxFont italicFont = wxFont(12, wxROMAN, wxITALIC, wxNORMAL);
- m_richTextCtrl = new wxRichTextCtrl(splitter, ID_RICHTEXT_CTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxNO_BORDER|wxWANTS_CHARS);
+ m_richTextCtrl = new wxRichTextCtrl(splitter, ID_RICHTEXT_CTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxWANTS_CHARS);
wxFont font(12, wxROMAN, wxNORMAL, wxNORMAL);
m_richTextCtrl->SetFont(font);
style &= ~wxBORDER_MASK;
#ifdef __WXGTK__
style |= wxBORDER_SUNKEN;
+#elif defined(__WXMSW__)
+ // Don't set the style explicitly, let GetDefaultBorder() work it out, unless
+ // we will get a sunken border (e.g. on Windows 200) in which case we must
+ // override with a simple border.
+ if (GetDefaultBorder() == wxBORDER_SUNKEN)
+ style |= wxBORDER_SIMPLE;
#else
style |= wxBORDER_SIMPLE;
#endif
long style,
const wxString& name)
{
+#ifdef __WXMSW__
+ if ((style & wxBORDER_MASK) == wxDEFAULT)
+ style |= wxBORDER_THEME;
+#endif
+
style |= wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE;
if ( !wxVScrolledWindow::Create(parent, id, pos, size, style, name) )
return false;
wxBorder wxControl::GetDefaultBorder() const
{
- // we want to automatically give controls a sunken style (confusingly,
- // it may not really mean sunken at all as we map it to WS_EX_CLIENTEDGE
- // which is not sunken at all under Windows XP -- rather, just the default)
-#if defined(__POCKETPC__) || defined(__SMARTPHONE__)
- return wxBORDER_SIMPLE;
-#else
- return wxBORDER_SUNKEN;
-#endif
+ return GetDefaultBorderForControl();
}
WXDWORD wxControl::MSWGetStyle(long style, WXDWORD *exstyle) const
const wxValidator& validator,
const wxString& name)
{
-#ifdef __WXWINCE__
- if ((style & wxBORDER_MASK) == 0)
- style |= wxBORDER_SIMPLE;
-#endif
-
// base initialization
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
return false;
return true;
}
+// returns true if the platform should explicitly apply a theme border
+bool wxTextCtrl::CanApplyThemeBorder() const
+{
+#ifdef __WXWINCE__
+ return false;
+#else
+ // Standard text control already handles theming
+ return ((GetWindowStyle() & (wxTE_RICH|wxTE_RICH2)) != 0);
+#endif
+}
+
bool wxTextCtrl::MSWCreateText(const wxString& value,
const wxPoint& pos,
const wxSize& size)
#endif
#endif
+#if wxUSE_UXTHEME
+ #include "wx/msw/uxtheme.h"
+ #define EP_EDITTEXT 1
+ #define ETS_NORMAL 1
+ #define ETS_HOT 2
+ #define ETS_SELECTED 3
+ #define ETS_DISABLED 4
+ #define ETS_FOCUSED 5
+ #define ETS_READONLY 6
+ #define ETS_ASSIST 7
+#endif
+
#if defined(TME_LEAVE) && defined(WM_MOUSELEAVE) && wxUSE_DYNLIB_CLASS
#define HAVE_TRACKMOUSEEVENT
#endif // everything needed for TrackMouseEvent()
}
}
+wxBorder wxWindowMSW::GetDefaultBorderForControl() const
+{
+ // we want to automatically give controls a sunken style (confusingly,
+ // it may not really mean sunken at all as we map it to WS_EX_CLIENTEDGE
+ // which is not sunken at all under Windows XP -- rather, just the default)
+
+#if defined(__POCKETPC__) || defined(__SMARTPHONE__)
+ return wxBORDER_SIMPLE;
+#else
+#if wxUSE_UXTHEME
+ if (CanApplyThemeBorder())
+ {
+ wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive();
+ if (theme)
+ return wxBORDER_THEME;
+ }
+#endif
+ return wxBORDER_SUNKEN;
+#endif
+}
+
WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const
{
// translate common wxWidgets styles to Windows ones
case wxBORDER_NONE:
case wxBORDER_SIMPLE:
+ case wxBORDER_THEME:
break;
case wxBORDER_STATIC:
style &= ~WS_BORDER;
break;
- case wxBORDER_DOUBLE:
- *exstyle |= WS_EX_DLGMODALFRAME;
- break;
+// case wxBORDER_DOUBLE:
+// *exstyle |= WS_EX_DLGMODALFRAME;
+// break;
}
// wxUniv doesn't use Windows dialog navigation functions at all
}
}
break;
-
+#if 0
case WM_ENTERSIZEMOVE:
{
processed = HandleEnterSizeMove();
processed = HandleExitSizeMove();
}
break;
-
+#endif
case WM_SIZING:
{
LPRECT pRect = (LPRECT)lParam;
break;
#endif // __WXWINCE__
+#if wxUSE_UXTHEME
+ // If we want the default themed border then we need to draw it ourselves
+ case WM_NCCALCSIZE:
+ {
+ wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive();
+ if (theme && GetBorder() == wxBORDER_THEME)
+ {
+ // first ask the widget to calculate the border size
+ rc.result = MSWDefWindowProc(message, wParam, lParam);
+ processed = true;
+
+ // now alter the client size making room for drawing a themed border
+ NCCALCSIZE_PARAMS *csparam = NULL;
+ RECT rect;
+ if (wParam)
+ {
+ csparam = (NCCALCSIZE_PARAMS*)lParam;
+ rect = csparam->rgrc[0];
+ }
+ else
+ {
+ rect = *((RECT*)lParam);
+ }
+ wxUxThemeHandle hTheme(this, L"EDIT");
+ RECT rcClient = { 0, 0, 0, 0 };
+ wxClientDC dc(this);
+
+ if (theme->GetThemeBackgroundContentRect(
+ hTheme, GetHdcOf(dc), EP_EDITTEXT, ETS_NORMAL,
+ &rect, &rcClient) == S_OK)
+ {
+ InflateRect(&rcClient, -1, -1);
+ if (wParam)
+ csparam->rgrc[0] = rcClient;
+ else
+ *((RECT*)lParam) = rcClient;
+ rc.result = WVR_REDRAW;
+ }
+ }
+ }
+ break;
+
+ case WM_NCPAINT:
+ {
+ wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive();
+ if (theme && GetBorder() == wxBORDER_THEME)
+ {
+ // first ask the widget to paint its non-client area, such as scrollbars, etc.
+ rc.result = MSWDefWindowProc(message, wParam, lParam);
+ processed = true;
+
+ wxUxThemeHandle hTheme(this, L"EDIT");
+ wxWindowDC dc(this);
+
+ // Clip the DC so that you only draw on the non-client area
+ RECT rcBorder;
+ wxCopyRectToRECT(GetSize(), rcBorder);
+
+ RECT rcClient;
+ theme->GetThemeBackgroundContentRect(
+ hTheme, GetHdcOf(dc), EP_EDITTEXT, ETS_NORMAL, &rcBorder, &rcClient);
+ InflateRect(&rcClient, -1, -1);
+
+ ::ExcludeClipRect(GetHdcOf(dc), rcClient.left, rcClient.top,
+ rcClient.right, rcClient.bottom);
+
+ // Make sure the background is in a proper state
+ if (theme->IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
+ {
+ theme->DrawThemeParentBackground(GetHwnd(), GetHdcOf(dc), &rcBorder);
+ }
+
+ // Draw the border
+ int nState;
+ if ( !IsEnabled() )
+ nState = ETS_DISABLED;
+ // should we check this?
+ //else if ( ::GetWindowLong(GetHwnd(), GWL_STYLE) & ES_READONLY)
+ // nState = ETS_READONLY;
+ else
+ nState = ETS_NORMAL;
+ theme->DrawThemeBackground(hTheme, GetHdcOf(dc), EP_EDITTEXT, nState, &rcBorder, NULL);
+ }
+ }
+ break;
+
+#endif // wxUSE_UXTHEME
+
default:
// try a custom message handler
const MSWMessageHandlers::const_iterator
bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style,
const wxValidator& validator, const wxString& name)
{
+ // Try to make this only necessary in 2.8
+#if 0
+#ifdef __WXMSW__
+ if ((style & wxBORDER_MASK) == wxDEFAULT)
+ style |= wxBORDER_THEME;
+#endif
+#endif
+
if (!wxTextCtrlBase::Create(parent, id, pos, size,
style|wxFULL_REPAINT_ON_RESIZE,
validator, name))
bool showSelector = ((style & wxRICHTEXTSTYLELIST_HIDE_TYPE_SELECTOR) == 0);
- m_styleListBox = new wxRichTextStyleListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, showSelector ? wxSIMPLE_BORDER : wxNO_BORDER);
+ m_styleListBox = new wxRichTextStyleListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, showSelector ? wxBORDER_DEFAULT : wxBORDER_NONE);
wxBoxSizer* boxSizer = new wxBoxSizer(wxVERTICAL);
m_styleChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices);
boxSizer->Add(m_styleListBox, 1, wxALL|wxEXPAND, 5);
- boxSizer->Add(m_styleChoice, 0, wxALL|wxEXPAND, 5);
+ boxSizer->Add(m_styleChoice, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5);
}
else
{
EVT_LEFT_DOWN(wxRichTextStyleComboPopup::OnMouseClick)
END_EVENT_TABLE()
+bool wxRichTextStyleComboPopup::Create( wxWindow* parent )
+{
+ int borderStyle = GetDefaultBorder();
+ if (borderStyle == wxBORDER_SUNKEN)
+ borderStyle = wxBORDER_SIMPLE;
+
+ return wxRichTextStyleListBox::Create(parent, wxID_ANY,
+ wxPoint(0,0), wxDefaultSize,
+ borderStyle);
+}
+
void wxRichTextStyleComboPopup::SetStringValue( const wxString& s )
{
m_value = SetStyleSelection(s);