Colored text



  • On 10/09/2016 at 10:53, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R18 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hello.

    I want to create a console-like dialog and I was wondering if you can have colored text.
    In general, can you have colored Strings anywhere (red, orange e.t.c)?
    Is there any example ?

    Thank you.



  • On 10/09/2016 at 14:41, xxxxxxxx wrote:

    GeDialog  Example:

    //This is how to set the various color options in an EditText gizmo  
      
      GroupBegin(0,BFH_LEFT,2,0,"MyTextGroup",0);  
      {                  
        AddEditText(1001, BFH_SCALEFIT,400,15,0);  
        SetDefaultColor(1001, COLOR_TEXT_EDIT, Vector(1,0,0));      //Sets the color of the text  
        SetDefaultColor(1001, COLOR_TEXTFOCUS, Vector(0,1,0));      //Sets the color of the cursor line when typing text  
        SetDefaultColor(1001, COLOR_BGSELECTEDTEXT, Vector(0,0,1)); //Sets the color of the background(only the text bg) when text is selected(highlighted)  
        SetDefaultColor(1001, COLOR_FGSELECTEDTEXT, Vector(0,0,0)); //Sets the color of the text (only the text bg) when it's selected(highlighted)  
        SetDefaultColor(1001, COLOR_TRANS, Vector(0,0,0));          //Sets the background color behind the text(normally it's transparent)  
      }  
      GroupEnd();
    

    -ScottA



  • On 12/09/2016 at 01:59, xxxxxxxx wrote:

    Hello,

    as Scott shows you can define the colors used by default GeDialog gadgets using SetDefaultColor(). This way you could use default gadets to build your dialog.

    But if you want something like the build-in console you might want to create you own gadget. Such a gadget is based on GeUserArea. So if you want to draw multiple lines with different colors you might want to use a GeClipMap to draw such a bitmap. Then you can use GeUserArea::DrawBitmap() to draw the result BaseBitmap inside GeUserArea::DrawMsg(). You find an example on how to use a GeUserArea in the customdata_customgui.cpp example.

    best wishes,
    Sebastian


Log in to reply