Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Text model

ITextModel inherits from the IModel interface and contains data that can be represented by a Brew MP AECHAR text string.

The ITextModel interface provides functions for:

  • managing reference counting of the interface object
  • registering a listener with a text model
  • manipulating the text represented by the model

Using a text model

The following example shows how to use ITextModel and IRichTextModel to manage serialized markup text:

// Create the Static widget which will display the serialized markup text
nErr = ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_CStaticWidget, 
                  (void**)&pMe->m_pRichTextWgt);
	
// Create a text model interface
if (AEE_SUCCESS == nErr) {
   nErr = ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_CTextModel, 
               (void**)&pTextMdl);

   // Get the rich text model version
   if (AEE_SUCCESS == nErr) {
      nErr = ITextModel_QueryInterface(pTextMdl, AEEIID_IRichTextModel, 
                  (void**)&pMe->m_pRichTextMdl);
      ITextModel_Release(pTextMdl);
   }
   // Add the model to the static widget
   if (AEE_SUCCESS == nErr) {
      nErr = IWidget_SetModel(pMe->m_pRichTextWgt, (IModel*)pMe->m_pRichTextMdl);

      // Create and set markup text to rich text model, if supported
      if (AEE_SUCCESS == nErr) {
         // Create serialized markup text
         AECHAR szMarkupText[] = L"[b]Email Configuration[/b] \n“
                                 L"[blue]Server Settings[/blue]\n";

         /* Set rich text font and properties */

         // Set markup text to rich text model
         (void)IRichTextModel_SetMarkupText(pMe->m_pRichTextMdl, szMarkupText, -1);
      }
   }
}