How to access StyledSettings without Object Inspector

0

I create an array of TRadioButton objects for which I need to adjust the TextSettings. However, since I create them "manually," I can't use the Object Inspector, so I can't get at StyledSettings to uncheck things like the font size. If I use Fire Monkey to create a single TRadioButton, then I can use the Object Inspector to uncheck, for example, size in StyledSettings for that one TRadioButton, and then my manual setting of the font size takes effect, but I can't find a way to change the font settings in my array of TRadio Buttons and have it override StyledSettings.

Thanks in advance. Example code is below. (I can't think of a way to show that I don't have access to the Object Inspector for the array of TRadioButtons, but I don't.)

River_Forest

    TRadioButton * myButtonList[3];


    int y_position = 25;



    RadioButton1->Height = 50;


    RadioButton1->Width = 200;


    RadioButton1->TextSettings->Font->Size = 24;



    for (int i = 0; i < 3; i++) {


        myButtonList[i] = new TRadioButton(Owner);


        myButtonList[i]->Parent = Form2;


        myButtonList[i]->Visible = true;


        myButtonList[i]->Position->X = 25;


        myButtonList[i]->Position->Y = y_position + 25*i;


        myButtonList[i]->Text = "Option " + IntToStr(i+1);


        myButtonList[i]->TextSettings->Font->Size = 24;


    }

 

Accepted Answer

Wednesday, January 04 2017, 03:11 PM - #Permalink
0

After some Internet searching and wrestling with what seemed to me to be fairly opaque documentation, I found the answer. If an object, say a TLabel or a TButton, is called myControl, then the following line

     myControl->TextSettings->Font->Size = 24;

generally does not take effect because it is overridden by StyledSettings. However, it does take effect if it is preceded by the line

     myControl->StyledSettings = myControl->StyledSettings >> TStyledSetting::Size;

Similarly,

     myControl->TextSettings->Font-Family = "Traditional Arabic";

does not take effect, but it does take effect if preceded by

     myControl->StyledSettings = myControl->StyledSettings >> TStyledSetting::Family;

I don't understand any of the above (I'm out of my depth), but on a "monkey see, monkey do" basis, I'm copying it from sample code that I found, and it's working.

River_Forest

The reply is currently minimized Show
Responses (1)
  • Accepted Answer

    Tuesday, January 10 2017, 06:31 AM - #Permalink
    0

    Hi River Forest,

    Help with understanding:

    a) The ObjectInspector is just a (very) convenient way of setting control properties at design time.

    b) A control created at run time (as you are doing in your array of pointers to radio buttons) doesn't exist at design time so it can't be configured by the ObjectInspector. However all the same properties do exist at run time, once the control has been created.

    c) So you need to set the properties to values to suit your requirements at run time. StyledSettings are implemented as a C++ Set (note the capital S) which is an Embarcadero termplate class to implement a set of values (you can think of the relationship between Embarcadero AnsiString and the STL std::string as being similar to the relationship between an Embarcadero Set and the STL std::set). The streaming operation syntax takes a little getting used to but it is easy to see what is going on when you get to know it. There is documentation on the Embarcadero C++ Set class at

    http://docwiki.embarcadero.com/Libraries/Berlin/en/System.Set

    Hope this helps your understanding.

    Regards, Roger

    The reply is currently minimized Show
Your Reply

Please login to post a reply