window gradient background Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Lamego
Earned some good credits
Earned some good credits
Posts: 101
Joined: Wed Jun 29, 2005 10:13 pm
Location: Portugal
Contact:

window gradient background

Post by Lamego » Mon Oct 31, 2005 1:43 pm

Does anyone have some example code to create a gradient pattern to use as a window background, the gradient pattern should be created based on the window size (to get a nice effect).
wxMSW 2.6.3 - GCC 3.4.2 (MinGW/MSYS)
wxGTK 2.6.3 - GCC 4.02 (Ubuntu)
Code::Blocks Win/Lin
PTlink Tech Admin
PTlink Chat Software Lead Developer
http://software.pt-link.net

emarti
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 210
Joined: Sat May 07, 2005 8:24 pm
Location: Eskisehir, TURKEY
Contact:

Post by emarti » Wed Nov 02, 2005 1:08 pm

Hi,

Code: Select all


#include <wx/dc.h>
#include <wx/colour.h>
#include <wx/window.h>
#include <wx/pen.h>

// Your Frame or Dialog Paint Event

void formgradientFrm::formgradientFrmPaint(wxPaintEvent& event)
{
	wxPaintDC dc(this);
	
	int hh,ww;
	wxWindow::GetClientSize(&ww,&hh);
	
	int h;
	h = (hh + 255)/256; 
	
	for (int r=0; r<=hh; r++)
	         {
              if ((r % h) == 0)    
                 { 
                     wxPen p(wxColour(r/h,0,128)); 
                     dc.SetPen(p);
                 }
              dc.DrawLine(0,r,ww,r);
             }
                     
	dc.DrawText(_T("Gradient wxFrame Sample"),25,25);
}

- T U R K E Y ?
- I love this country!

WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/

Lamego
Earned some good credits
Earned some good credits
Posts: 101
Joined: Wed Jun 29, 2005 10:13 pm
Location: Portugal
Contact:

nice

Post by Lamego » Wed Nov 02, 2005 11:28 pm

Just what I was looking for.
Thanks :)
wxMSW 2.6.3 - GCC 3.4.2 (MinGW/MSYS)
wxGTK 2.6.3 - GCC 4.02 (Ubuntu)
Code::Blocks Win/Lin
PTlink Tech Admin
PTlink Chat Software Lead Developer
http://software.pt-link.net

emarti
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 210
Joined: Sat May 07, 2005 8:24 pm
Location: Eskisehir, TURKEY
Contact:

Re: nice

Post by emarti » Thu Nov 03, 2005 11:45 am

Lamego wrote:Just what I was looking for.
Thanks :)
Not at all :)
- T U R K E Y ?
- I love this country!

WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/

Post Reply