GithubHelp home page GithubHelp logo

Comments (1)

ismail-yilmaz avatar ismail-yilmaz commented on June 11, 2024

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,

from ultimatepp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.