Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread State change through program
Mon, Aug 25 2014 1:01 PMPermanent Link

Matthew Jones

It would be quite nice to be able to set the "display state" of a
component like a button from my program. Basically, to activate the
mouse-over state or similar. I could for example "flash" the button
this way. Right now I'm just making an automatic demo mode, and it
would be nice to simulate the click for the video recording, but I can
see other uses. I guess I could add a rectangle behind and flash that,
but the component state would be nicer.

--

Matthew Jones
Mon, Aug 25 2014 4:48 PMPermanent Link

Walter Matte

Tactical Business Corporation

Here is how I make it work in EWB 1.

I uses TImage or buttons so I can easily show state changes..

I have two images or the button, example:   Save.png and SaveHot.png

On Enter and On Leave

And then for Mouse Down and Up I move the control....

I have global variables to hold the events...

 gbImgMouseDown     : TMouseDownEvent;
 gbImgMouseUp       : TMouseUpEvent;
 gbImgMouseEnter    : TNotifyEvent;
 gbImgMouseLeave    : TNotifyEvent;

I assign them once....

 gbImgMouseDown  := imgLogOnMouseDown;
 gbImgMouseUp    := imgLogOnMouseUp;
 gbImgMouseEnter := imgLogOnMouseEnter;
 gbImgMouseLeave := imgLogOnMouseLeave;

And reassign them in the on create o the Forms (or wherever needed)

 procedure ImgUpDown(cc : TContainerControl);

procedure ImgUpDown(cc : TContainerControl);
var
 i : integer;
begin
 for i := 0 to cc.controlcount - 1 do
 begin
   if (cc.controls[i] is TPanel) then
   begin
     ImgUpDown(TPanel(cc.controls[i]));
   end
   else if (cc.controls[i] is TImage) then
   begin                                               
     if Assigned(gbImgMouseDown) then
       TImage(cc.Controls[i]).OnMouseDown  := gbImgMouseDown;
     if Assigned(gbImgMouseUp) then
       TImage(cc.Controls[i]).OnMouseUp    := gbImgMouseUp;
     if Assigned(gbImgMouseEnter) then
       TImage(cc.Controls[i]).OnMouseEnter := gbImgMouseEnter;
     if Assigned(gbImgMouseLeave) then
       TImage(cc.Controls[i]).OnMouseLeave := gbImgMouseLeave;
   end;
 end;
end;


procedure TfrmLogin.imgLogOnMouseEnter(Sender: TObject);
var
 sTmp : string;
begin
 sTmp := TImage(Sender).ImageName;
 TImage(Sender).ImageName := strReplace(sTmp,'.','Hot.',false,true);
end;

procedure TfrmLogin.imgLogOnMouseLeave(Sender: TObject);
var
 sTmp : string;
begin
 sTmp := TImage(Sender).ImageName;
 TImage(Sender).ImageName := strReplace(sTmp,'Hot.','.',false,true);
end;

procedure TfrmLogin.imgLogOnMouseDown(Sender: TObject; Button: Integer; ShiftKey, CtrlKey, AltKey: Boolean; X,Y: Integer);
begin
 TImage(Sender).Left := TImage(Sender).Left + 1;
 TImage(Sender).Top  := TImage(Sender).Top + 1;
end;

procedure TfrmLogin.imgLogOnMouseUp(Sender: TObject; Button: Integer; ShiftKey, CtrlKey, AltKey: Boolean; X,Y: Integer);
begin
 TImage(Sender).Left := TImage(Sender).Left - 1;
 TImage(Sender).Top  := TImage(Sender).Top - 1;
end;


Walter
Mon, Aug 25 2014 10:13 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< It would be quite nice to be able to set the "display state" of a component like a button from my program. >>

From the EWB 2 source code:

  TControl = class(TComponent)
...
     protected
        property InterfaceClassName: String read GetInterfaceClassName;
        property InterfaceState: String read FInterfaceState
                                        write SetInterfaceState;

If you look at my previous status post with the image of the control interface designer, you'll see that you can create the various states of a control's interface, and internally the (above) private SetInterfaceState procedure uses the passed state value along with the InterfaceClassName property value to find the interface and, if found, look up the state in the interface.  If it finds the state, then it will apply the state's element properties in a recursive fashion to the control's main UI element.  Also, for a given element, you can also control exactly which properties are applied to the controls' various elements via an Apply property.  For example, with a button control you might want the content formatting (justification, etc.) of the caption element to be applied, but not the font, which you want the developer to specify directly via the button control's Font property.  This is important, and overcomes one of the major issues with the themes in EWB 1.x.

The InterfaceState property is protected in TControl, but promoted to public in most descendant controls.   This is done to allow the control developer/author to choose whether they want to allow for such direct manipulation of the interface state.  For example, for edit controls it makes sense to promote it because there are states like "Error" that should be able to be set programmatically.

Finally, all of this is completely optional.  For some controls, the developer may choose to ignore using interfaces/states and just directly manipulate the properties of the control's UI elements as necessary, similar to what a Delphi VCL application does.
------------

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Aug 26 2014 3:37 AMPermanent Link

Matthew Jones

Walter Matte wrote:

> Here is how I make it work in EWB 1.

Thanks - I love how powerful EWB is if you want to hook into it.

--

Matthew Jones
Tue, Aug 26 2014 3:38 AMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

> From the EWB 2 source code:

Looks good, and powerful. Ship next week? Smile

--

Matthew Jones
Image