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 » U++ Widgets - General questions or Mixed problems » Help needed to deal with Display
Help needed to deal with Display [message #20656] Mon, 30 March 2009 12:39 Go to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Hello,
I am new to Upp. I am trying to do my first steps.
Reading the Alex thread concerning droplist colors I decided to try it using a different display but I lost the selection bar. Please try the program that is in attachment. It seems that the blue bar (selection bar) is drawn behind Display painting. how to fix this?

By the way, which is the best way to change switch control fore color. I tryied with Display but it seems that switch controls do not support it.

Is this a bug?

Thank you very much

Jose

[Updated on: Mon, 30 March 2009 23:31]

Report message to a moderator

Re: Help needed to deal with Display [message #20673 is a reply to message #20656] Tue, 31 March 2009 12:54 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
JoseB wrote on Mon, 30 March 2009 11:39

Hello,
I am new to Upp. I am trying to do my first steps.
Reading the Alex thread concerning droplist colors I decided to try it using a different display but I lost the selection bar. Please try the program that is in attachment. It seems that the blue bar (selection bar) is drawn behind Display painting. how to fix this?

By the way, which is the best way to change switch control fore color. I tryied with Display but it seems that switch controls do not support it.

Is this a bug?

How to set the colors of a DropList (this is actually not obvious, it took me some time to figure out):
struct DropListColorDisplay : Display 
{
	Color fore;
	Color back;
	Font font;
	dword style;

	void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword s) const 
	{
		bool hasstyle = s & style;
		StdDisplay().Paint(w, r, q, hasstyle ? ink : fore, hasstyle ? paper : back, s);
	}
	
	DropListColorDisplay(Color _fore, Color _back, dword s = 0, Font _font = StdFont()) : 
		fore(_fore), back(_back), style(s), font(_font) {}
};

void SetColor(DropList &list)
{
	Color fore(255,255,0);
	Color bk(0,255,0);
	static DropListColorDisplay display1(fore, bk, 0);
	static DropListColorDisplay display2(fore, bk, Display::CURSOR);
	list.ValueDisplay(display1);
	list.SetDisplay(display2);
}


Currently it is impossible to set the color of a Switch ctrl. However, I actually have had a small need for this for a while but hadn't got around to it so I will submit a patch to fix it. See attached files.

The patch adds a virtual PaintCase function that can be overloaded to give more control over how the text is rendered. This isn't the usual Upp approach, but the Switch ctrl is kind of a special case because it's a cross between a data and Button-like ctrl.

After the path is applied you will be able to use the following class:
class ColorSwitch : public Switch
{
protected:
	Vector<Color> color;
	virtual void PaintCase(Draw &w, int i, int x, int y, int cx, const Font &font, bool disabled)
	{
		const Case &v = GetCases()[i];
		Color c = (i < color.GetCount()) ? color[i] : SColorLabel;
		DrawSmartText(w, x, y, cx, v.label, font,
		              disabled ? SColorDisabled : c, ///////
		              VisibleAccessKeys() ? v.accesskey : 0);	
	}	
public:
	void SetCaseColor(int i, Color c) 	{ ASSERT(i < GetCases().GetCount()); color.At(i, SColorLabel) = c; }
	void Reset()						{ color.Clear(); Switch::Reset(); }
};


Mirek: Could this patch be applied?
  • Attachment: PushCtrl.h
    (Size: 10.64KB, Downloaded 344 times)
  • Attachment: Switch.cpp
    (Size: 6.91KB, Downloaded 546 times)
Re: Help needed to deal with Display [message #20676 is a reply to message #20673] Tue, 31 March 2009 13:19 Go to previous messageGo to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
My Env is Upp svn 315

Well, as far as DropList is concern, it works great now. I thought that no one was interested in that thread. Now, i realise that to solve that it took too much time to you. I tryed to go deep into source code but I stoped on the CreateWindowEx windows call or something like that without understanding how to paint it in the right order... So, Thank you very much once again mrjt!

For wsitch control, I overwriten the files you send in attach (after make backup copies Smile) and changed the type of my switch control in the form designer to ColorSwitch and compiler says this:

----- CtrlLib ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (1 / 9)
BLITZ: LabelBase.cpp Button.cpp EditField.cpp Text.cpp LineEdit.cpp DocEdit.cpp ScrollBar.cpp HeaderCtrl.cpp ArrayCtr
l.cpp MultiButton.cpp PopupTable.cpp DropList.cpp DropChoice.cpp Static.cpp Splitter.cpp FrameSplitter.cpp Slider
Ctrl.cpp ColumnList.cpp Progress.cpp AKeys.cpp RichTextView.cpp Prompt.cpp Help.cpp DateTimeCtrl.cpp Bar.cpp Menu
Item.cpp MenuBar.cpp ToolButton.cpp ToolBar.cpp ToolTip.cpp StatusBar.cpp TabCtrl.cpp TreeCtrl.cpp DlgColor.cpp C
olorPopup.cpp ColorPusher.cpp FileList.cpp FileSel.cpp PrinterJob.cpp Windows.cpp Win32.cpp TrayIconWin32.cpp Tra
yIconX11.cpp CtrlUtil.cpp Update.cpp LNGCtrl.cpp Ch.cpp ChGtk.cpp
In file included from C:/upp/out/CtrlLib/MINGW.Debug.Debug_full.Gui\$blitz.cpp:7:
C:\upp\uppsrc\CtrlLib\Button.cpp:680: error: definition of implicitly-declared 'virtual Upp::DataPusher::~DataPusher(
)'
In file included from C:/upp/out/CtrlLib/MINGW.Debug.Debug_full.Gui\$blitz.cpp:180 :
C:\upp\uppsrc/CtrlLib/PushCtrl.h: In member function 'virtual void Upp::ColorCtrl::DoAction()':
C:\upp\uppsrc/CtrlLib/PushCtrl.h:336: error: 'const Upp::Convert* Upp::DataPusher::convert' is private
C:\upp\uppsrc\CtrlLib\DlgColor.cpp:1628: error: within this context
C:\upp\uppsrc/CtrlLib/PushCtrl.h:336: error: 'const Upp::Convert* Upp::DataPusher::convert' is private
C:\upp\uppsrc\CtrlLib\DlgColor.cpp:1630: error: within this context
Switch.cpp
C:\upp\uppsrc\CtrlLib\Switch.cpp: In member function 'virtual void Upp::Switch::PaintCase(Upp::Draw&, int, int, int,
int, const Upp::Font&, bool)':
C:\upp\uppsrc\CtrlLib\Switch.cpp:207: error: 'SColorLabel' was not declared in this scope
ChWin32.cpp
CtrlLib.icpp
CtrlLib: 51 file(s) built in (0:31.84), 624 msecs / file, duration = 32329 msecs

There were errors. (0:32.35)



Jose
Re: Help needed to deal with Display [message #20677 is a reply to message #20676] Tue, 31 March 2009 13:36 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
My guess would be that your source is too old and that changes have been made since your version that are incompatible. If your version is 315 then it is very old since we are over 1000 these days. I would suggest you update it and then apply the path, or attempt to make equivalent changes to your version, which should be quite easy as the change is minor.
Re: Help needed to deal with Display [message #20680 is a reply to message #20677] Tue, 31 March 2009 14:09 Go to previous messageGo to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Yes, i know that my version is too old but as i changed the source code of the upp for a different approach on printing i am a little glued to that version. During the changes in the printing system i could not make them by subclassing or at the app level. I changes the source code of the main basic upp classes that implement printing.

Well, i think that I can add an SetForColor to the Swtich class and a Color member variable and update the Paint function...

Thank you very much

Jose
Re: Help needed to deal with Display [message #20685 is a reply to message #20680] Tue, 31 March 2009 15:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
JoseB wrote on Tue, 31 March 2009 08:09

Yes, i know that my version is too old but as i changed the source code of the upp for a different approach on printing i am a little glued to that version. During the changes in the printing system i could not make them by subclassing or at the app level. I changes the source code of the main basic upp classes that implement printing.



That is not very smart...

If you insist on different printing model in U++, you should convince us to change it, suggest the patch or whatever or keep your code separately (which is what you should do now).

Admittedly, this one of our problems - it is way to simple to change U++ and the way as it is distributed encourages it... But by doing so you basically end with fork and I doubt you have enough power to maintain it...

Mirek
Re: Help needed to deal with Display [message #20705 is a reply to message #20685] Wed, 01 April 2009 11:03 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Yes, you are right.

I didnt told nothing about my needs on printing system because ... It is not easy for my to ask for more functionality from you. But I am wrong. Since now I will post all limitations I saw, bugs and more functionalities in order to improve our excelent C++ Framework called Upp Wink

By the way, I didnt remember well but I think that what printing system is missing is header and footers for each page. I refer to the great RichEditWithToolBar control. May be it supports custom headers and footers and i didnt saw them.

Suppose I want to send a mailling to 100 customers. The letter is the same (the mail text) but address changes from customer to customer. Hence, if the RichEditWithToolBar supports dynamic headers and footers, in this case we enlarge the header to write there the source and target address in order to fit well on the envelop window and them we print the text of the RichEditWithToolBar as the body of the letter. I think that was that. I think was something like this and I need to change the RichEditWithToolBar source code because I didnt fount any way to do that at the application source level (implementing virtual function, deriving, etc...)

Thank you very much

Jose

[Updated on: Wed, 01 April 2009 11:10]

Report message to a moderator

Re: Help needed to deal with Display [message #20747 is a reply to message #20705] Fri, 03 April 2009 16:49 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
But does not have much to do with printing system...

QTF itself (format of texts) does not directly support headers/footers. But RichEdit has SetFooter command (but frankly, it is more or less quick hack).

In any case, you should be able to print RichEdit content (that is, RichText) page by page and add header/footer with your own code.

Mirek
Re: Help needed to deal with Display [message #20748 is a reply to message #20747] Fri, 03 April 2009 18:06 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Can i do that without modifying the object source code? I did that but modifying the source code. Any tips?

PS: To achieve that, I pull document down to get space onf the first page and then put the text there by hand...

Thanks
Jose

[Updated on: Fri, 03 April 2009 18:34]

Report message to a moderator

Re: Help needed to deal with Display [message #20749 is a reply to message #20748] Fri, 03 April 2009 20:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
kbyte wrote on Fri, 03 April 2009 12:06

Can i do that without modifying the object source code? I did that but modifying the source code. Any tips?

PS: To achieve that, I pull document down to get space onf the first page and then put the text there by hand...

Thanks
Jose


Sure. Get const reference to RichText and print it Smile

Mirek
Re: Help needed to deal with Display [message #20751 is a reply to message #20749] Sat, 04 April 2009 08:43 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Ok, but how to print it, putting an header on the first page, without pull text down to get room for the header?

Jose
Re: Help needed to deal with Display [message #20766 is a reply to message #20751] Sun, 05 April 2009 15:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
Then pull it down....

Lookup CtrlLib/RichTextView Print function - printing RichText is not really hard. And it is pretty flexible too.

Mirek
Re: Help needed to deal with Display [message #20779 is a reply to message #20766] Mon, 06 April 2009 10:40 Go to previous message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
But i can already print headers and footers, but by pulling text down by hand on the print finction.

I thought that you were saying that it would be possible to do that using a more "professional" way as far as C++ is concerned (deriving or implementing virtuals or somethings like those)

Jose
Previous Topic: Holding a Button down
Next Topic: Howto create control-collection -control? [SOLVED -good example]
Goto Forum:
  


Current Time: Fri Nov 01 00:48:38 CET 2024

Total time taken to generate the page: 0.03353 seconds