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 » Developing U++ » UppHub » MessageCtrl: A passive notifications ctrl and manager. (A a usefule CtrlLib add-on.)
Re: MessageCtrl: A passive notifications ctrl and manager. [message #49603 is a reply to message #49602] Sun, 11 March 2018 12:32 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Luigi,

The thing is, MessageCtrl is simply a manager, there is no real reason to add it to a "layout".
IT is not a Ctrl derived class.
Messages will resize automatically depending on the size of it's parent.

You instantiate it in your, say, TopWindow, and then set a target (a Ctrl) for it to attach:


class MyWindow : public TopWindow {
 MessageCtrl messages;
 DocEdit     editor;
 RichEdit    richeditor; 

 void DisplayEditorErrorMessage() { 
      messages.Error(editor, "This is an error message.");
 }

 void DisplayRichEditorSuccessMessage() {
      messages.Success(richeditor, "This is a success message.");
 }

 // Other members, constructors, etc...
};




Think of it like a Prompt. You do not use them with layout. Nor MessageCtrl. (Of course you can also attach messages to layouted ctrls)

Example code provided with the MessageCtrl demonstrates that. (It adds top message boxes to the window itself, and the bottom meassage box to the editor widget.)

I've written a new example to clarify the behaviour. Please find the attached example. Smile
Best regards,
Oblivion



[Updated on: Sun, 11 March 2018 18:04]

Report message to a moderator

Re: MessageCtrl: A passive notifications ctrl and manager. [message #49604 is a reply to message #49603] Mon, 12 March 2018 08:24 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Oblivion wrote on Sun, 11 March 2018 12:32

I've written a new example to clarify the behaviour. Please find the attached example. Smile


Hello Oblivion,

now everything is clear.
Thanks!
Luigi
Re: MessageCtrl: A passive notifications ctrl and manager. [message #49606 is a reply to message #49603] Mon, 12 March 2018 09:58 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Oblivion wrote on Sun, 11 March 2018 12:32

I've written a new example to clarify the behaviour. Please find the attached example. Smile


One more question, please.
How can I clear the message present, let's say, in editor ctrl? I tried

messages.Clear(editor.GetCaptureCtrl());
messages.Clear(editor);

with no success. Perhaps I must use several MessageCtrl and bind each of them to a different ctrl.
Thanks,
Luigi
Re: MessageCtrl: A passive notifications ctrl and manager. [message #49607 is a reply to message #49606] Mon, 12 March 2018 11:34 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Luigi,



with no success. Perhaps I must use several MessageCtrl and bind each of them to a different ctrl.


This is possible (and in some rare cases, might be useful) but not necessary. A single instance of MessageCtrl is usually sufficient.


All you need to do is pass a pointer to your ctrl:

messages.Clear(&editor)


(One shortcoming of the MessageCtrl is that currenty you cannot target a single message box automatically. Will be available soon though.)

Best regards,
Oblivion


[Updated on: Mon, 12 March 2018 13:54]

Report message to a moderator

Re: MessageCtrl: A passive notifications ctrl and manager. [message #49700 is a reply to message #49494] Fri, 06 April 2018 23:10 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello,

MessageCtrl updated.

From now on informative message boxes (information, warning, success, error) use crosses instead of OK button.


You can find the updated package in the first message of this topic, or grab it from:
https://github.com/ismail-yilmaz/upp-components/tree/master/ CtrlLib/MessageCtrl

Screenshot:

index.php?t=getfile&id=5546&private=0

Best regards,
Oblivion


Re: MessageCtrl: A passive notifications ctrl and manager. [message #51502 is a reply to message #49494] Fri, 05 April 2019 12:57 Go to previous messageGo to next message
Mahanthesh is currently offline  Mahanthesh
Messages: 3
Registered: May 2012
Location: Bangalore
Junior Member
Hi,
I want to change the message font size of MessageCtrl.
Please let me know how to do..
Re: MessageCtrl: A passive notifications ctrl and manager. [message #51503 is a reply to message #49494] Fri, 05 April 2019 13:00 Go to previous messageGo to next message
Mahanthesh is currently offline  Mahanthesh
Messages: 3
Registered: May 2012
Location: Bangalore
Junior Member
Hi,
I want to change the message font size of MessageCtrl.
Please let me know how to do..
Re: MessageCtrl: A passive notifications ctrl and manager. [message #51504 is a reply to message #51503] Fri, 05 April 2019 14:50 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Mahanthesh, and welcome to the U++ forums!

MessageCtrl is using Qtf. And it can be formatted using Qtf syntax. You can even put images or tables in it (if you really need such options...)

See here for more details on the format: https://www.ultimatepp.org/srcdoc$RichText$QTF_en-us.html

As for your question. Here is a modified version of the reference code:

#include <CtrlLib/CtrlLib.h>
#include <MessageCtrl/MessageCtrl.h>

using namespace Upp;

class Messages : public TopWindow {
	MessageCtrl msg;
	DocEdit editor;
	Button  button1,  button2;
	
public:
	Messages()
	{
		Title("U++ Message Boxes (Passive Notifications)");
		SetRect(0,0, 640, 480);
		Sizeable().Zoomable().CenterScreen();
		SetMinSize({100, 100});

		auto action = [=](int id) {
			switch(id) {
			case IDYES: PromptOK("You've chosen 'yes'"); break;
			case IDNO:  PromptOK("You've chosen 'no'"); break;
			}
		};
		
		Add(editor.HSizePosZ().VSizePos(0, 24));
		Add(button1.SetLabel("Test").RightPos(4).BottomPos(4));
		Add(button2.SetLabel("Clear").LeftPos(4).BottomPos(4));

		button2 << [=] { msg.Clear(this); }; // Selective clearing.
		button1 << [=] {
			msg.Animation()
			  .Top()
			  .Information(*this, "This is a time-constrained information message. It will disappear in 5 seconds.", Null, 5)
			  .Success(*this, "This is a success message.")
			  .Warning(*this, "This is a warning message.")
			  .Error(*this, "This is an error message.")
			  .Information(*this, "[C [4 This information message is using 16 pt courier font...]") // <-- Different font face and font size...
			  .Bottom()
			  .AskYesNo(editor, "This is a question box 'in' the text editor with "
			                   "[^https:www`.ultimatepp`.org^ l`i`n`k]"
			                   " support. Would you like to continue?",
			                   action,
			                   callback(LaunchWebBrowser)
			);
			
		};
	}
};

GUI_APP_MAIN
{
	Messages().Run();
}



Result should be (this is on Linux):
index.php?t=getfile&id=5797&private=0

If you have more questions about the MesasgeCtrl, I'll try to answer them.

Best regards,
Oblivion


[Updated on: Fri, 05 April 2019 14:51]

Report message to a moderator

Re: MessageCtrl: A passive notifications ctrl and manager. [message #52274 is a reply to message #51504] Sun, 25 August 2019 23:03 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello Oblivion,

for first time I used MessageCtrl under linux.
There is a compilation problem... maybe again a name clash

index.php?t=getfile&id=5897&private=0

Best regards,
Luigi
Re: MessageCtrl: A passive notifications ctrl and manager. [message #52275 is a reply to message #52274] Mon, 26 August 2019 01:30 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Luigi,

Thank you for reporting the compilation error.

Apparently the "Success" tag is defined as a preprocessor constant in X.h, and this include file is required for the Upp's X11 mode.

And unfortunately the method has to be renamed to something else. (undefining and redefining the "Success" constant won't work in this case). Therefore, I renamed it to OK.

It should work now. Just substitute the MessageCtrl::Success calls with MessageCtrl::OK calls in your code.

https://github.com/ismail-yilmaz/upp-components/tree/master/ CtrlLib/MessageCtrl

Let me know if you run into any other troubles.

And I am sorry for the trouble it caused.

Best regards,
Oblivion



[Updated on: Mon, 26 August 2019 01:30]

Report message to a moderator

Re: MessageCtrl: A passive notifications ctrl and manager. [message #52279 is a reply to message #52275] Mon, 26 August 2019 08:56 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Oblivion wrote on Mon, 26 August 2019 01:30
Hello Luigi,

And unfortunately the method has to be renamed to something else. (undefining and redefining the "Success" constant won't work in this case). Therefore, I renamed it to OK.



Hi Oblivion,

thanks a lot for the correction! Now it works as usual.
Best regards,
Luigi
Re: MessageCtrl: A passive notifications ctrl and manager. [message #56168 is a reply to message #49494] Tue, 02 February 2021 22:07 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hi,

MessageCtrl got a small update:

- Standard message boxesnow adjust to light/dark theme.


Also, MessageCtrl is also available via UppHub. This means it can be downloaded and updated via TheIDE's package manager if you are using the latest nightly build of TheIDE.

Best regards,
Oblivion




Re: MessageCtrl: A passive notifications ctrl and manager. [message #59543 is a reply to message #49494] Sat, 21 January 2023 09:19 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hi,

Since Upp's migration to GTK3, the slide animation was not working on most linux/POSIX system -usually with Gnome installed)

It was a problem with Upp's animation routine and is now fixed in the nightly builds of U++.
Message boxes should now have slide animation as expected.


Best regards,
Oblivion


[Updated on: Sat, 21 January 2023 09:19]

Report message to a moderator

Previous Topic: GDAL status
Next Topic: Sharing a few small packages
Goto Forum:
  


Current Time: Thu Mar 28 13:11:45 CET 2024

Total time taken to generate the page: 0.02172 seconds