Homer Library
HomerMessage


MessageListItem is a class which is used to issue a message to Homer. The type of the message (error, warning or information) is set at construction time. With an instance of this class, you can append pieces of data to generate the message's body. Once you're done, you can send it to the message looper (BLooper object) which is provided as an argument to HomerFilter::Accepts and HomerCommand::Process() methods. The what member of the BMessage to send can be:

The message body consists of a set of items, each having a particular style or action:


MessageListItem::MessageListItem(message_type type);

Allocates an error, warning or information message, based on type which is one of:


virtual MessageListItem::~MessageListItem();

Deletes every items in every line of the message.


MessageListItem& operator<<(MessageListItem& msg)

Append the items of msg to the current message. msg is made empty by this operation, but the caller has to delete it. Note that if msg2 stands for a line in itself, you have to append a endl_item() to the end of the current message first (it is not inserted for you).


bool IsType(message_type type) const;

Returns if the type of the message is type.


MessageListItem& operator<<(plain_item item);
MessageListItem& operator<<(bold_item item);
MessageListItem& operator<<(underlined_item item);
MessageListItem& operator<<(italic_item item);
MessageListItem& operator<<(endl_item item);
MessageListItem& operator<<(space_item item);

Appends the item to the current message. The data contained in item is copied.


Sample code


// generate the message
MessageListItem* msg_item = new MessageListItem(HOMER_WARNING_MESSAGE);
*msg_item << MessageListItem::plain_item("It's not because ");
*msg_item << MessageListItem::underlined_item("I don't care");
*msg_item << MessageListItem::bold_item("that I don't understand");
*msg_item << MessageListItem::endl_item();
*msg_item << MessageListItem::italic_item("Come on, Lisa,");
*msg_item << MessageListItem::endl_item();
*msg_item << MessageListItem::plain_item("You got all my attention...");

// send the message
BMessage msg(ADD_HOMER_MESSAGE);    // or ADD_ADDON_MESSAGE;
looper->PostMessage(&msg);


This page was last updated on 12/12/99.