ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Controlling the TIELayerPropertiesDlg

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
jrpcguru Posted - Aug 03 2020 : 15:11:35
My program defines a text layer which I call "CaptionLayer" and specifies properties different from normal text layers. The code performs a lookup in external data sources to provide a suggested caption for an image. I find the font size needs to vary depending on the megapixels of the image, so I wanted streamlined access to the font property dialog. The CaptionLayer has these properties, among others:

      TIETextLayer(ImageEnView1.CurrentLayer).IsRuler := false;
      TIETextLayer(ImageEnView1.CurrentLayer).EnableFormatting := True;
      ImageEnView1.LayerOptions :=  [loAllowReturnsInRichText, loAutoUndoChangesByUser,loAutoUndoChangesByCode,loKeyboardShortcuts, loAllowMultiSelect, loAutoSelectMask ,  loPreventOutOfBounds ];



It uses word wrapping but does not use rich text since that would be too complex for this purpose. Researching the help file I found the OnShowDialog event and this is what I've tried. Commented lines did not work.


procedure TfrmImagePopUp.ImageEnView1ShowDialog(Sender: TObject; DlgType: TIEDlgType; Form: TForm);
var
  sLayerName : string;
  LayerType : TIELayerKind ;
  iPPI : integer;
begin
if DlgType = iefLayerProperties then
  begin
    if (ImageEnView1.LayersCount > 1) and (ImageEnView1.LayersCurrent > 0) then
      begin
        sLayerName := ImageEnView1.CurrentLayer.Name;
        LayerType := ImageEnView1.CurrentLayer.Kind;
        if (LayerType = ielkText) and (sLayerName = 'CaptionLayer') then
          begin
            TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabText.TabVisible := true;       //false doesn't work
            TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabGeneral.TabVisible := False;
            TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabStyle.TabVisible := false;
//            TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabText.update; 
//            TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabText.repaint; 
//            TIELayerPropertiesDlg(Form).IELayerProps.Update;   //this caused tabStyle to be visible
            TIELayerPropertiesDlg(Form).IELayerProps.Frame.btnRemoveFormatting.Click;
//            ImageEnView1.Update;
          end;
    end;
  end;

end;



The major problem that causes my question is that when I hide the General and Style tab, the text tab is displayed as a blank dialog. I have to click on the actual Text tab to refresh the display. As you can see from my commented lines, I found and tried a few ways to refresh the tab display, but none worked. Is there a way to refresh that tab?

Since I'm not using rich text, the Text tab always displays the Remove Formatting button and that needs to be clicked to see the font adjustments. I was pleased to discover the ability to programmatically click that button so the user isn't mystified. But I wonder if a property exists that I'm missing so that this tab would automatically display the font adjustments when rich text isn't used?





J.R.
5   L A T E S T    R E P L I E S    (Newest First)
jrpcguru Posted - Aug 05 2020 : 19:41:42
Modifying ie.inc for AllowReturnsInTextLayers works better than my approach. Thank you.

Thanks for the readability tip. I know that method but routinely forget it. It is definitely easier to read.

J.R.
xequte Posted - Aug 04 2020 : 17:20:19
Hi

1. OK, I'll make that code more defensive.

2. Carriage returns are not supported by TextLayers by default. You need to enable the following define in ie.inc (and ensure the ImageEn source folder is on your Delphi library path):

{$define AllowReturnsInTextLayers}

3. Tip for readability:

const
  Caption_Layer = 99;

ImageEnView1.CurrentLayer.Tag := Caption_Layer;

if ImageEnView1.CurrentLayer.Tag = Caption_Layer then...


Nigel
Xequte Software
www.imageen.com
jrpcguru Posted - Aug 04 2020 : 10:35:18
1. I haven't found how to set the pagecontrol.activepage.

But, with the benefit of sleeping on it, I realized that this option might be available and might work:

TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabText.Visible := true;

And it did!

This worked to show the desired text tab. But when I used another option to display the full property dialog (after making all tabs visible), there was a List Index out of bounds(-1) error. I traced that to:

procedure TIELayerPropertiesDlg.FormShow(Sender: TObject);
begin
  if IELayerProps.Frame.pgcLayers.Pages[gActivePageIndex].TabVisible then
    IELayerProps.Frame.pgcLayers.ActivePageIndex := gActivePageIndex;
end;

gActivePageIndex = -1 if I have hidden tabs before. (Is that a bug?)

Fortunately this led me to figure out how to set the pagecontrol.activepage:

        TIELayerPropertiesDlg(Form).IELayerProps.Frame.pgcLayers.ActivePageIndex := 4;
//            TIELayerPropertiesDlg(Form).IELayerProps.Frame.tabText.Visible := true;


It is no longer necessary to make the tabText visible and the error no longer appears when I open the full property dialog.

2. The Remove Formatting button appears in the text tab for rich text enabled text layers. I suspect that is appropriate since the regular font dialog affects the entire text contained in the text layer. When I create the "CaptionLayer", using the properties that I listed, then launch the properties dialog, this button is displayed. It is probably because I've specified loAllowReturnsInRichText and EnableFormatting which both seem to be necessary to allow word wrap and carriage returns. But I don't specify loShowRichTextToolbar. I have a successful work around with the btnRemoveFormatting.Click but I wondered if it would help to have an explicit design allowing word wrap and carriage return without also implying full rich text? In my case, full rich text is overkill.

3. Thanks for the suggestions. It looks like using ImageEnView1.CurrentLayer.Tag := 1 seems like a good method of internally identifying my layer types. Thank you.

J.R.
xequte Posted - Aug 03 2020 : 22:42:17
Hi JR

1. I don't see that you actually display the tabText, i.e. try setting the PageControl.ActivePage to tabText.

2. Can you give me the steps to reproduce the "Remove Formatting" issue.

3. No, there isn't but there are other ways to recognize your special layer, such as the Tag property or UserData:

http://www.imageen.com/help/TIELayer.Tag.html
http://www.imageen.com/help/TIELayer.UserData.html

Nigel
Xequte Software
www.imageen.com
jrpcguru Posted - Aug 03 2020 : 16:27:37
Another question:
I am using a layer name of "CaptionLayer" to differentiate how the program functions. But the layer properties dialog allows users to change the layer name. Is there a way to lock the layer name?

J.R.