-// -----------------------------------------------------------------------
-// wxPGClipperWindow
-// -----------------------------------------------------------------------
-
-
-#if wxPG_ENABLE_CLIPPER_WINDOW
-
-//
-// Clipper window is used to "remove" borders from controls
-// which otherwise insist on having them despite of supplied
-// wxNO_BORDER window style.
-//
-class wxPGClipperWindow : public wxWindow
-{
- DECLARE_CLASS(wxPGClipperWindow)
-public:
-
- wxPGClipperWindow()
- : wxWindow()
- {
- wxPGClipperWindow::Init();
- }
-
- wxPGClipperWindow(wxWindow* parent,
- wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize)
- {
- Init();
- Create(parent,id,pos,size);
- }
-
- void Create(wxWindow* parent,
- wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize);
-
- virtual ~wxPGClipperWindow();
-
- virtual bool ProcessEvent(wxEvent& event);
-
- inline wxWindow* GetControl() const { return m_ctrl; }
-
- // This is called before wxControl is constructed.
- void GetControlRect( int xadj, int yadj, wxPoint& pt, wxSize& sz );
-
- // This is caleed after wxControl has been constructed.
- void SetControl( wxWindow* ctrl );
-
- virtual void Refresh( bool eraseBackground = true,
- const wxRect *rect = (const wxRect *) NULL );
- virtual void SetFocus();
-
- virtual bool SetFont(const wxFont& font);
-
- inline int GetXClip() const { return m_xadj; }
-
- inline int GetYClip() const { return m_yadj; }
-
-protected:
- wxWindow* m_ctrl;
-
- int m_xadj; // Horizontal border clip.
-
- int m_yadj; // Vertical border clip.
-
-private:
- void Init ()
- {
- m_ctrl = (wxWindow*) NULL;
- }
-};
-
-
-IMPLEMENT_CLASS(wxPGClipperWindow,wxWindow)
-
-
-// This is called before wxControl is constructed.
-void wxPGClipperWindow::GetControlRect( int xadj, int yadj, wxPoint& pt, wxSize& sz )
-{
- m_xadj = xadj;
- m_yadj = yadj;
- pt.x = -xadj;
- pt.y = -yadj;
- wxSize own_size = GetSize();
- sz.x = own_size.x+(xadj*2);
- sz.y = own_size.y+(yadj*2);
-}
-
-
-// This is caleed after wxControl has been constructed.
-void wxPGClipperWindow::SetControl( wxWindow* ctrl )
-{
- m_ctrl = ctrl;
-
- // GTK requires this.
- ctrl->SetSizeHints(3,3);
-
- // Correct size of this window to match the child.
- wxSize sz = GetSize();
- wxSize chsz = ctrl->GetSize();
-
- int hei_adj = chsz.y - (sz.y+(m_yadj*2));
- if ( hei_adj )
- SetSize(sz.x,chsz.y-(m_yadj*2));
-
-}
-
-
-void wxPGClipperWindow::Refresh( bool eraseBackground, const wxRect *rect )
-{
- wxWindow::Refresh(false,rect);
- if ( m_ctrl )
- m_ctrl->Refresh(eraseBackground);
-}
-
-
-// Pass focus to control
-void wxPGClipperWindow::SetFocus()
-{
- if ( m_ctrl )
- m_ctrl->SetFocus();
- else
- wxWindow::SetFocus();
-}
-
-
-bool wxPGClipperWindow::SetFont(const wxFont& font)
-{
- bool res = wxWindow::SetFont(font);
- if ( m_ctrl )
- return m_ctrl->SetFont(font);
- return res;
-}
-
-
-void wxPGClipperWindow::Create(wxWindow* parent,
- wxWindowID id,
- const wxPoint& pos,
- const wxSize& size )
-{
- wxWindow::Create(parent,id,pos,size);
-}
-
-
-wxPGClipperWindow::~wxPGClipperWindow()
-{
-}
-
-
-bool wxPGClipperWindow::ProcessEvent(wxEvent& event)
-{
- if ( event.GetEventType() == wxEVT_SIZE )
- {
- if ( m_ctrl )
- {
- // Maintain correct size relationship.
- wxSize sz = GetSize();
- m_ctrl->SetSize(sz.x+(m_xadj*2),sz.y+(m_yadj*2));
- event.Skip();
- return false;
- }
- }
- return wxWindow::ProcessEvent(event);
-}
-
-#endif // wxPG_ENABLE_CLIPPER_WINDOW
-
-/*wxWindow* wxPropertyGrid::GetActualEditorControl( wxWindow* ctrl )
-{
-#if wxPG_ENABLE_CLIPPER_WINDOW
- // Pass real control instead of clipper window
- if ( ctrl->IsKindOf(CLASSINFO(wxPGClipperWindow)) )
- {
- return ((wxPGClipperWindow*)ctrl)->GetControl();
- }
-#else
- return ctrl;
-#endif
-}*/
-