wxFrame-border & -title-bar paint Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
art-ganseforth
Earned some good credits
Earned some good credits
Posts: 116
Joined: Mon Sep 01, 2014 10:14 am

wxFrame-border & -title-bar paint

Post by art-ganseforth » Tue Feb 05, 2019 11:32 pm

Hello,

i work on a program, using some wxFrame-windows (wx 3.1.2). The application has a dark skin. So i want to get rid of the white Win10-window-borders and elements. But there are some problems with three things:
- There stays a small white top-border if the wxFrame is drawn without title-bar.
- If they have no title-bar and are created hidden, they stay white after showing them until they are resized manually.
- The same frames are not redrawn at all, after hiding them and showing them again. Resizing leads to artefacts.

Especially concerning the first point I wonder, if there is a solution for it (for the others i've workarounds).

Thank you,
Frank

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3352
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxFrame-border & -title-bar paint

Post by ONEEYEMAN » Wed Feb 06, 2019 4:32 pm

Hi,
Did you try to use wxNO_BORDER style?

Here are the default frame borders. Maybe you should get rid of wxRESIZE_BORDER?

Thank you.

art-ganseforth
Earned some good credits
Earned some good credits
Posts: 116
Joined: Mon Sep 01, 2014 10:14 am

Re: wxFrame-border & -title-bar paint

Post by art-ganseforth » Wed Feb 06, 2019 6:29 pm

I need resizing. Currently i try to use the draw-event, to draw on wxScrennDC (having some problems with coorinates at the moment). If it works, i'll post it here. I think this is interesting not only for me...

Concerning the other points:
- Resizing the frame after showing it, shows its content at the first Show()-call
- The other problem was (missing content and artefacts) was something in my code

art-ganseforth
Earned some good credits
Earned some good credits
Posts: 116
Joined: Mon Sep 01, 2014 10:14 am

Re: wxFrame-border & -title-bar paint

Post by art-ganseforth » Wed Feb 06, 2019 6:49 pm

wxScreenDC won't work if the titlebar is covered by other windows. So i stop this...

User avatar
doublemax
Moderator
Moderator
Posts: 13876
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFrame-border & -title-bar paint

Post by doublemax » Wed Feb 06, 2019 8:27 pm

I need resizing.
So i guess that means that you have wxRESIZE_BORDER set?

In that case get rid of wxRESIZE_BORDER and handle the resizing yourself. You can't have the OS's resize behavior without the visible resize border.
Use the source, Luke!

art-ganseforth
Earned some good credits
Earned some good credits
Posts: 116
Joined: Mon Sep 01, 2014 10:14 am

Re: wxFrame-border & -title-bar paint

Post by art-ganseforth » Wed Feb 06, 2019 8:42 pm

Okay...

Here is a raw programmed fix for this white top-border. It's a wxFrame covering it. It has to be created calling

Code: Select all

new clsBorderHelper(this);
Class:

Code: Select all

class clsBorderHelper : public wxFrame  {    wxWindow *Parent ;
    
    public:
        virtual void         OnParentRepos (wxEvent &event)  {     event.Skip();
            wxSize diff(Parent->GetSize()-Parent->GetClientSize()); //unfortunately GetWindowBorderSize() returns 0...
            this->SetPosition   (Parent->GetPosition()+wxPoint(diff.GetWidth()/2, 1));
            this->SetSize(wxSize(Parent->GetSize().GetWidth() - diff.GetWidth(), diff.GetHeight() / 2 ));
        };
        
        clsBorderHelper(wxWindow *parent) : wxFrame (parent, -1, "", wxPoint(0,0), wxSize(0,0), 
        										wxNO_BORDER|wxFRAME_NO_TASKBAR|wxFRAME_FLOAT_ON_PARENT) {
             Parent = parent;
             Parent->Connect (wxEVT_MOVE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);
             Parent->Connect (wxEVT_SIZE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);
             SetBackgroundColour (wxColour("#330066")); //SetBackgroundColour(wxColour(Parent->GetBackgroundColour());
             Show();
        };
        ~clsBorderHelper() {             // might be better to use Destroy() or smth..          
              Parent->Disconnect (wxEVT_MOVE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);
              Parent->Disconnect (wxEVT_SIZE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);
       };
} ;
It leaves one pixel on top for resizing, but it also might be easy, to connect some mouse-events, so that it's a full resize-border (but not transparent, as the others). Also it might be used as window-move-bar...

Best,
Frank

art-ganseforth
Earned some good credits
Earned some good credits
Posts: 116
Joined: Mon Sep 01, 2014 10:14 am

Re: wxFrame-border & -title-bar paint

Post by art-ganseforth » Wed Feb 06, 2019 9:09 pm

Supplement:

Calling Update() in OnParentRepos (wxEvent &event) after this->SetSize(...); reduces the delay of the covering frame...

art-ganseforth
Earned some good credits
Earned some good credits
Posts: 116
Joined: Mon Sep 01, 2014 10:14 am

Re: wxFrame-border & -title-bar paint

Post by art-ganseforth » Wed Feb 06, 2019 9:53 pm

And one more...

... working as resize-border (note the the destruchtor is probably not valid)...

Code: Select all

class clsBorderHelper : public wxFrame  {
    wxWindow *Parent ;
    wxPoint mp;
    
    public:
        void OnMouseMove   (wxMouseEvent &event) {
            wxPoint delta = event.GetPosition() - mp;
            Parent->SetPosition (Parent->GetPosition() + wxPoint (0, delta.y));
            Parent->SetSize     (Parent->GetSize    () - wxSize  (0, delta.y * 1.0));            
            Parent->Update();
        };
        void OnLeftDown    (wxMouseEvent &event) {      CaptureMouse(); 
            Connect        (wxEVT_MOTION, wxMouseEventHandler(clsBorderHelper::OnMouseMove), NULL, this);
            mp = event.GetPosition();
        };
        void OnLeftUp      (wxMouseEvent &event) {      ReleaseMouse(); 
            Disconnect     (wxEVT_MOTION, wxMouseEventHandler(clsBorderHelper::OnMouseMove), NULL, this);
            Parent          ->SetFocus();
        };
        void OnParentRepos (wxEvent &event) {   event.Skip();
            wxSize diff    (Parent->GetSize    () - Parent->GetClientSize());
            SetPosition    (Parent->GetPosition() + wxPoint(diff.GetWidth() / 2, 1));
            SetSize (wxSize(Parent->GetSize    ().GetWidth() - diff.GetWidth(), diff.GetHeight() / 2 ));
            Update();
        };
        
        clsBorderHelper(wxWindow *parent, wxColour c = wxColour("#132652")) : wxFrame(parent, -1, "", wxPoint(0,0), wxSize(0,0),
                                                wxNO_BORDER|wxFRAME_NO_TASKBAR|wxFRAME_FLOAT_ON_PARENT) {
            Parent = parent;
            
            Parent ->Connect (wxEVT_MOVE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);
            Parent ->Connect (wxEVT_SIZE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);

                     Connect (wxEVT_LEFT_DOWN, wxMouseEventHandler(clsBorderHelper::OnLeftDown), NULL, this);
                     Connect (wxEVT_LEFT_UP,   wxMouseEventHandler(clsBorderHelper::OnLeftUp  ), NULL, this);

            SetBackgroundColour (c);//Parent->GetBackgroundColour());
            this->SetCursor(wxCURSOR_SIZENS );
            Show ();
        };
        
        ~clsBorderHelper(){};
} ;
I marked this as soved, but for the issue with the not painted content when the wxFrame without title-bar is shown first, i use a workaround.
It's maybe a wxWidgets-problem (version 3.1.2 / win10 / MingW32)...


Source updated: Parent->Update(); in OnMouseMove(wxMouseEvent &event) makes it faster...
One more update: Added "Parent->SetFocus();" in OnLeftUp (wxMouseEvent &event). 1px Border is now perfectly drawn.

Post Reply