How can I add RichTextCtrl to Status bar?
How can I add RichTextCtrl to Status bar? And use that instead to show rich text messages? I cannot add directly using AddFrame as its not a InfoCtrl.
I tried the following and add it to status bar, but its interfering with other status bar functions like progress bar etc.
`
struct RichInfoCtrl : InfoCtrl {
RichTextCtrl richCtrl;
RichInfoCtrl() {
richCtrl.HSizePosZ(0, 0).VSizePosZ(0, 0);
this->Add(richCtrl);
Set(" "); // to clear default "Ready" text
richCtrl = "Ready"; // use richtext instead
}
void SetMsg(String str) {
richCtrl = str;
}
};
`
Is there a recommended way to add RichTextCtrl to status bar?
How can I add RichTextCtrl to Status bar? And use that instead to show rich text messages? I cannot add directly using AddFrame as its not a InfoCtrl.
I tried the following and add it to status bar, but its interfering with other status bar functions like progress bar etc.
`
struct RichInfoCtrl : InfoCtrl { RichTextCtrl richCtrl; RichInfoCtrl() { richCtrl.HSizePosZ(0, 0).VSizePosZ(0, 0); this->Add(richCtrl); Set(" "); // to clear default "Ready" text richCtrl = "Ready"; // use richtext instead } void SetMsg(String str) { richCtrl = str; } };`
Is there a recommended way to add RichTextCtrl to status bar?
You can use smart text (RichText) in info widgets. Just use DrawSmartText function to paint text in the display. Below is the modified version of uppsrc/reference/StatusBar example. It adds rich text support (Remember: there are also other ways to achive this):
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct PosDisplay : Display {
virtual void Paint(Draw& w, const Rect& r, const Value& q,
Color ink, Color paper, dword style) const {
if(q.Is<String>())
Upp::DrawSmartText(w, 0, 0, r.Width(), q.To<String>()); // Draws the rich text;
}
};
struct App : TopWindow {
StatusBar status;
InfoCtrl x, y;
PosDisplay dx, dy;
virtual void MouseMove(Point p, dword)
{
String sx, sy;
sx << "\1[g@4=/ x: " << p.x << " ]"; // Rich text, green, centered, italic
sy << "\1[g@3>_ y: " << p.y << " ]"; // Rich text, red, right aligned, underlined
x.Set(PaintRect(dx, sx));
y.Set(PaintRect(dy, sy));
}
App() {
Sizeable();
SetFrame(FieldFrame());
AddFrame(status);
status.AddFrame(x.Left(100));
status.AddFrame(y.Left(100));
}
};
GUI_APP_MAIN
{
App().Run();
}
`
Edit: Simplified the example.
Best regards,