Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Look and Chameleon Technology » Manual for custom Chameleonized Ctrls
Re: Manual for custom Chameleonized Ctrls [message #27091 is a reply to message #27090] Fri, 25 June 2010 12:31 Go to previous messageGo to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
In case it may be of use to other people here is example of how to modify a Chameleon style while retaining theming.

Before Chameleon ButtonOptions had a none themed look that I prefered, so when Chameleon was added I reproduced it:
index.php?t=getfile&id=2606&private=0
(both buttons are pressed, I keep the OS look when not pressed)

This is the code that does it:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;

#define IMAGECLASS Img
#define IMAGEFILE <LayoutTest/LayoutTest.iml>
#include <Draw/iml.h>

Image ApplyStyle(const Value &base, const Image &style)
{
	Size sz(30, 30);
	ImageDraw w(30, 30);
	w.DrawRect(sz, SColorFace());
	ChPaint(w, sz, base);
	ChPaint(w, sz, style);
	
	Image img = w;
	ImageBuffer ib(img);
	ib.SetHotSpot(style.GetHotSpot());
	ib.Set2ndSpot(style.Get2ndSpot());
	return (Image)ib;
}

void ButtonOption_HotPress(ButtonOption &bo)
{
	static ButtonOption::Style style;
	style = ButtonOption::StyleDefault();
	style.look[2] = ApplyStyle(style.look[2], Img::HotPress());;
	bo.SetStyle(style);
}

GUI_APP_MAIN
{
	TopWindow wnd;
	ButtonOption normal, hotpress;
	
	wnd.SetRect(Size(140, 32));
	wnd.CenterScreen();
	
	ButtonOption_HotPress(hotpress);

	normal.SetLabel("Normal").LeftPos(4, 64).TopPos(4, 24);
	hotpress.SetLabel("HotPress").LeftPos(72, 64).TopPos(4, 24);
	wnd.Add(normal);
	wnd.Add(hotpress);
	
	wnd.Run();
}


What it does is render the existing style value to a buffer (since it's not an Image - it's an os theme) and then draw my own image over the top.

[Updated on: Fri, 25 June 2010 12:44]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: RichEdit crashes with BlueBar
Next Topic: FIX: proper use of Style in Ctrls from CtrlLib
Goto Forum:
  


Current Time: Mon May 13 23:35:52 CEST 2024

Total time taken to generate the page: 0.02532 seconds