|
|
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 |
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 |
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 |
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 ) 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 #20705 is a reply to message #20685] |
Wed, 01 April 2009 11:03 |
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
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 #20779 is a reply to message #20766] |
Mon, 06 April 2009 10:40 |
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
|
|
|
Goto Forum:
Current Time: Fri Nov 01 00:48:38 CET 2024
Total time taken to generate the page: 0.03353 seconds
|
|
|