Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / interface skin

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. interface skin
#2888
Posted by: 2003-11-14 16:39:08
Does anyone know when there're sources (not only from stardock corporation) to apply skin on my wxwindow/devcpp under XP interfaces ?
For example I need to apply a complex texture for a dialog background or a bordure cell, how shall I do ?
Message2. Re: interface skin
#2890
Posted by: upCASE 2003-11-14 17:50:56
Hi herve!

I suppose you mean WindowBlinds when you refer to Stardock.
Well, since Windows XP has it's own theme system I guess WindowBlinds isn't really needed anymore. To make use of the windows themes in your app, meaning that your app will have the system wide theme applied, you'll need to include a manifest file. This can easily be done with Dev-C++ since there's an option under the first tab in your project settings that when enabled generates such a file for you. This works with wxWindows last time I checked.

If you want application specific skins like for example winamp uses, it's gonna be more complex. There are libraries for doing that like guigui, but I never got it to work with wxWindows, because it's win32 API specific.
For wxWindows there's wxUniversal which uses a different set of controls that are skinned/themed/ownerdrawn. I'm not really sure if wxUniversal is still under development, but it seems to work. Problem is that wxUniversal has very few skins to use (Motif and windows style).
Currently wxWindows doesn't have a theme system like Qt does. I think in the roadmap there was a point that stated that they want to implement one in the upcoming versions, but it has low priority and I don't don't think there will be such a thing till wx 3.0.
Personally I started developing such a skinning library some time ago and implemented a set of custom controls that can be skinned using predefined images or through a zip file containing the images (like skin files for winamp). I posted to the mailing list a few times, but judging from the response I got they don't seem to be interested at all. That's why I stalled the development, maybe to return to it someday. I guess the want to go with wxUniversal... You can have a look at what I did at http://upcase.malteser-gl.de

upcase
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: interface skin
#2893
Posted by: mooncake 2003-11-16 11:26:57
Hi, would you mind show us simple example about that?

I means... background picture...

Thank you.
Meow~
Message4. Re: interface skin
#2895
Posted by: upCASE 2003-11-16 19:51:14
Hi!
Just a little piece of code for a skinned panel....
I wrote some macros for the whole wxSkin package that would allow you to use the "normal" names like wxPanel and apply wxSkinPanel later, for making "porting" to skins easier... Too bad the wxWindows list wasn't impressed at all. I'm not really sure why I did this... They stated that they needed a different set of controls with skin support, but when I told them that I wrote something like that, noone was interested.

Anyway, I hope this makes you happy :)

skinPanel.h

/*
  Name: wxSkinPanel.h
  Copyright: Ren¨? Kraus
  Author: Ren¨? Kraus
  Date: 16.11.03 12:43
  Description: A skinned panel
*/


#ifndef __WXSKINPANEL_H
#define __WXSKINPANEL_H

#ifdef __GNUG__
	#pragma interface "skinPanel.h"
#endif

#include <wx/wxprec.h>
#ifndef WX_PRECOMP
   #include <wx/wx.h>
#endif

#include <wx/image.h>

class wxSkinPanel : public wxPanel
{	wxImage back;
	wxColour default_background;
	bool m_usedefault;
	bool m_canMove;
	
	wxPoint m_delta;
	
public:
	wxSkinPanel();
	~wxSkinPanel();
#ifdef USE_WXSKIN
	wxSkinPanel(wxWindow* parent,
 				int id = -1,
     			const wxPoint& pos = wxDefaultPosition,
        		const wxSize& size = wxDefaultSize,
          		long style = wxTAB_TRAVERSAL,
            	const wxString& name = "panel");
#endif
	wxSkinPanel(wxWindow* parent,
				const wxImage& background,
				int id = -1,
 				const wxPoint& pos = wxDefaultPosition,
        		const wxSize& size = wxDefaultSize,
          		long style = wxTAB_TRAVERSAL,
            	const wxString& name = "panel");
	
	void Init();
 	void UseDefault(const bool state);
 	void OnPaint(wxPaintEvent& WXUNUSED(event));
 	
 	void OnLeftDown(wxMouseEvent& evt);
	void OnLeftUp(wxMouseEvent& evt);
	void OnMouseMove(wxMouseEvent& evt);
 	
 	void SetCanMove(bool b);
private:

	DECLARE_DYNAMIC_CLASS(wxSkinPanel)
	DECLARE_EVENT_TABLE()
};

#endif

skinPanel.cpp

/*
  Name: wxSkinPanel.cpp
  Copyright: Ren¨? Kraus
  Author: Ren¨? Kraus
  Date: 16.11.03 12:43
  Description: A skinned panel
*/


#ifdef __GNUG__
	#pragma implementation "skinPanel.h"
#endif

#include "skinPanel.h"
#include "wxSkinDef.h"
#include <wx/image.h>

BEGIN_EVENT_TABLE(wxSkinPanel, wxPanel)
   EVT_PAINT( wxSkinPanel::OnPaint)
   
   	EVT_LEFT_DOWN(wxSkinPanel::OnLeftDown)
    EVT_LEFT_UP(wxSkinPanel::OnLeftUp)
    EVT_MOTION(wxSkinPanel::OnMouseMove)
END_EVENT_TABLE()

IMPLEMENT_DYNAMIC_CLASS(wxSkinPanel,wxPanel)

wxSkinPanel::wxSkinPanel()
:wxPanel()
{
}

wxSkinPanel::wxSkinPanel(wxWindow* parent,
				int id,
				const wxPoint& pos,
        		const wxSize& size,
          		long style,
            	const wxString& name)
:wxPanel(parent,id,pos,size,style,name),
 back( wxSkinDef::getBmp_panel_back())
{
	m_canMove = true;
	default_background = /*parent->*/GetBackgroundColour();
	Init();
}

wxSkinPanel::wxSkinPanel(wxWindow* parent,
             	const wxImage& back,
				int id,
				const wxPoint& pos,
        		const wxSize& size,
          		long style,
            	const wxString& name)
:wxPanel(parent,id,pos,size,style,name),
 back(back)
{
	m_canMove = true;
	default_background = /*parent->*/GetBackgroundColour();
	Init();

}
void wxSkinPanel::Init()
{
	SetBackgroundColour( default_background );
	m_usedefault = false;

	int h, w;
	GetSize(&h,&w);
	//wxImage image( back );
   	wxBitmap back_temp(back.Scale(h, w));

	wxClientDC dc(this);
	dc.DrawBitmap( back_temp, 0, 0);
}

wxSkinPanel::~wxSkinPanel()
{
}


void wxSkinPanel::UseDefault(const bool state)
{	wxClientDC dc(this);

	if( state == true )
	{	dc.Clear();
		SetBackgroundColour( default_background );
		m_usedefault = true;
	}
	else
   	{	dc.DrawBitmap( back, 0, 0);
   		m_usedefault = false;
	}
}

void wxSkinPanel::SetCanMove(bool b)
{
	m_canMove = b;
}

void wxSkinPanel::OnPaint(wxPaintEvent& WXUNUSED(event) )
{
	wxPaintDC dc(this);
	
	int h, w;
	GetSize(&h,&w);
	if( m_usedefault == false )
	{	//wxImage image( back );
   		wxBitmap back_temp(back.Scale(h, w));
   		dc.DrawBitmap( back_temp, 0, 0);
	}
	else
	{
		dc.Clear();
		SetBackgroundColour( default_background );
	}

}

void wxSkinPanel::OnLeftDown(wxMouseEvent& evt)
{
	if(m_canMove)
    {	CaptureMouse();
	    wxPoint pos = ClientToScreen(evt.GetPosition());
	    wxPoint origin = GetParent()->GetPosition();
	    int dx =  pos.x - origin.x;
	    int dy = pos.y - origin.y;
	    m_delta = wxPoint(dx, dy);
 	}
}

void wxSkinPanel::OnLeftUp(wxMouseEvent& evt)
{
    if (HasCapture() && m_canMove)
    {
        ReleaseMouse();
    }
}

void wxSkinPanel::OnMouseMove(wxMouseEvent& evt)
{
	if(m_canMove)
    {	wxPoint pt = evt.GetPosition();
	    if (evt.Dragging() && evt.LeftIsDown())
	    {
	        wxPoint pos = ClientToScreen(pt);
	        GetParent()->Move(wxPoint(pos.x - m_delta.x, pos.y - m_delta.y));
	    }
 	}
}
upcase

upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message5. Re: interface skin
#2897
Posted by: mooncake 2003-11-16 20:12:04
Hi Upcase,

it display me the following error messages... :(

13 C:Dev-Cppincludewxwxprec.h
In file included from C:/Dev-Cpp/include/wx/wxprec.h

13 C:skinPanelskinPanel.h
                 from skinPanel.h

24 C:skinPanelskinPanel.cpp
                 from skinPanel.cpp

174 C:Dev-Cppincludewxdefs.h
redeclaration of C++ built-in

20 C:Dev-Cppincludewxmemory.h
In file included from C:/Dev-Cpp/include/wx/memory.h

....
...

mind to tell me how to do?  thank you...
Meow~
Message6. Re: interface skin
#2901
Posted by: 2003-11-17 15:56:15
Thank you,
I try your method
Message7. Re: interface skin
#2903
Posted by: 2003-11-17 21:00:32
It would be nice If your project could go further, because it's seem to be really great.

By
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-12-14  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0