[MSEide-MSEgui-talk] Fonts

classic Classic list List threaded Threaded
31 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[MSEide-MSEgui-talk] Fonts

mohamed hamza
Hi there,

How to get font width and height in pixels  of an  object.frame.caption  ?  

Best Regards

Med


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

fredvs
Hello Med.

> How to get font width and height in pixels  of an  object.frame.caption  ?  

If a font was assigned in object.frame.font:  :

fontwidth := object.frame.font.width;
fontheight := object.frame.font.height;

It the font assigned is <parent>, you should check for the font used by
parent of the object.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

mohamed hamza
Hi Fredv,

   Suppose you have a simplewidget   with bound_x=490,  If you want to fill it's frame.caption with  '-'  the number of chars must be   125
 then the width of char is  490/125=3,92  wich is not the width of the font?  

Best Regards.

Med 

De : fredvs <[hidden email]>
Envoyé : lundi 5 août 2019 22:22
À : [hidden email] <[hidden email]>
Objet : Re: [MSEide-MSEgui-talk] Fonts
 
Hello Med.

> How to get font width and height in pixels  of an  object.frame.caption  ? 

If a font was assigned in object.frame.font:  :

fontwidth := object.frame.font.width;
fontheight := object.frame.font.height;

It the font assigned is <parent>, you should check for the font used by
parent of the object.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

fredvs
>   Suppose you have a simplewidget   with bound_x=490,  If you want to fill
it's frame.caption with  '-'  
> the number of chars must be   125
> then the width of char is  490/125=3,92  wich is not the width of the
> font?  

Ha, ok,I see, it should work only with font with fixed width.

Sorry but I dont have any idea how to do it with font with variable width.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

fredvs
Hello Med.

As work around, I would do this:

- Add a ATLabel somewhere,  set to autosize = true and visible = false.

When you need to know the width of a character:

ATlabel.font := theObject.frame.font;
ATlabel.font.height := theObject.frame.font.height;
ATlabel.font.width := theObject.frame.font.width;
ATlabel.caption := '-';

width_of_char := ATlabel.width ;  ----> here the width you want.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

mohamed hamza
Hello Fredvs;

     I think there is  a problem to get the length of a caption.

     would you like to try this small demo  ( as Attn)

Best Regards

Med.


De : fredvs <[hidden email]>
Envoyé : mardi 6 août 2019 19:00
À : [hidden email] <[hidden email]>
Objet : Re: [MSEide-MSEgui-talk] Fonts
 
Hello Med.

As work around, I would do this:

- Add a ATLabel somewhere,  set to autosize = true and visible = false.

When you need to know the width of a character:

ATlabel.font := theObject.frame.font;
ATlabel.font.height := theObject.frame.font.height;
ATlabel.font.width := theObject.frame.font.width;
ATlabel.caption := '-';

width_of_char := ATlabel.width ;  ----> here the width you want.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

np.rar (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

fredvs
> would you like to try this small demo  ( as Attn)

With pleasure if you add demo.pas file that is missing in your Attn!

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

mohamed hamza
Here it is .   In fact length(frame.caption )  returns 1   , maybe function length is not appropriate in this case?

Regards.   

De : fredvs <[hidden email]>
Envoyé : mercredi 7 août 2019 18:55
À : [hidden email] <[hidden email]>
Objet : Re: [MSEide-MSEgui-talk] Fonts
 
> would you like to try this small demo  ( as Attn)

With pleasure if you add demo.pas file that is missing in your Attn!

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

np.rar (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

fredvs
Hello Med.

It seems to me that you created a perpetual loop in your code.
You assigned this to onpaint():

procedure tmainfo.paintGrEv(const sender: twidget; const acanvas: tcanvas);
begin
// this will be a perpetual loop because it will re-paint after the
execution of the procedure
twidgetgrid(sender).frame.caption:=inttostr(length(twidgetgrid(sender).frame.caption));
end;

IMHO, you should use something else than onpaint().

Could you try the demo,zip in attachment:

demo.zip <http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/demo.zip>  

Fre;D





--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

Sieghard
In reply to this post by mohamed hamza
Hello mohamed,

you wrote on Tue, 6 Aug 2019 16:35:58 +0000:

>    Suppose you have a simplewidget   with bound_x=490,  If you want to
> fill it's frame.caption with  '-'  the number of chars must be   125 then
> the width of char is  490/125=3,92  wich is not the width of the font?

That's because you probabely use a proportional font, where all the
characters have their individual width and font.width returns that of a
"representative" character, often an "m". If you used a monospaced font,
the font.width would be the same for all characters, although, of course,
it looks different.
But maybe you can make use of one of the "textrect" functions of the
"msedrawtext" unit, which generally take a canvas object as their first
parameter (implicitely specifying the font to check) and several other
parameters, often a string to be evaluated. They return a "rectty" record,
where the "cx" field contains the width value you are looking for.
You probabely will have to select the appropriate version of the function
according to your needs; the unit is located in the "mse.common/graphics"
directory, the file name is "msedrawtext.pas".

--
--
(Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung
nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem)
-----------------------------------------------------------
Mit freundlichen Grüßen, S. Schicktanz
-----------------------------------------------------------




_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

mohamed hamza
Hi all,

Now the problem is clear and the solution found. Thanks to all .

According Fred's advice  onPaint is avoided.

I tried  baseform.onfocusedwidgetchanged( newwidget .......)

It works only when  newwidget object  is  a Mse*Object ? 

I mean 

  If (newwidget is myownobject )  return false then 
     I can not adjust the  caption 


so the only solution is oncreate form which is not so  smart.

Regards

Med.



De : Sieghard <[hidden email]>
Envoyé : mercredi 7 août 2019 22:53
À : [hidden email] <[hidden email]>
Objet : Re: [MSEide-MSEgui-talk] Fonts
 
Hello mohamed,

you wrote on Tue, 6 Aug 2019 16:35:58 +0000:

>    Suppose you have a simplewidget   with bound_x=490,  If you want to
> fill it's frame.caption with  '-'  the number of chars must be   125 then
> the width of char is  490/125=3,92  wich is not the width of the font?

That's because you probabely use a proportional font, where all the
characters have their individual width and font.width returns that of a
"representative" character, often an "m". If you used a monospaced font,
the font.width would be the same for all characters, although, of course,
it looks different.
But maybe you can make use of one of the "textrect" functions of the
"msedrawtext" unit, which generally take a canvas object as their first
parameter (implicitely specifying the font to check) and several other
parameters, often a string to be evaluated. They return a "rectty" record,
where the "cx" field contains the width value you are looking for.
You probabely will have to select the appropriate version of the function
according to your needs; the unit is located in the "mse.common/graphics"
directory, the file name is "msedrawtext.pas".

--
--
(Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung
nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem)
-----------------------------------------------------------
Mit freundlichen Grüßen, S. Schicktanz
-----------------------------------------------------------




_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

fredvs
Hello Med.

> so the only solution is oncreate form which is not so  smart.

Indeed, I would use oncreated vs oncreate.

Maybe if you explain what you want to archive we can find better solution.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

mohamed hamza
Hi All,

   Currently   grid and groupbox are activated only when we click inside them or on their caption.  
I wanted to paddR the caption and then extended this zone ( frame.caption) .

CAPTION <          HOTZONE ALSO                                                                                                                                                >                                       





































































































I think we have to redefine that  in mseide lib. Is it a good Idea?

Regards

Med



De : fredvs <[hidden email]>
Envoyé : jeudi 8 août 2019 20:35
À : [hidden email] <[hidden email]>
Objet : Re: [MSEide-MSEgui-talk] Fonts
 
Hello Med.

> so the only solution is oncreate form which is not so  smart.

Indeed, I would use oncreated vs oncreate.

Maybe if you explain what you want to archive we can find better solution.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

mohamed hamza
Sorry the the text is not displayed well in mailist archive.

I continue:

CAPTION <   ADDED     HOTZONE                             >
________________________________________




------------------------------------------------------------------

To have this enhancement we have to make a change to mseide.lib

Is it safe and a good  idea?

Regards

Med


De : mohamed hamza <[hidden email]>
Envoyé : jeudi 8 août 2019 21:25
À : General list for MSEide+MSEgui <[hidden email]>
Objet : Re: [MSEide-MSEgui-talk] Fonts
 
Hi All,

   Currently   grid and groupbox are activated only when we click inside them or on their caption.  
I wanted to paddR the caption and then extended this zone ( frame.caption) .

CAPTION <          HOTZONE ALSO                                                                                                                                                >                                       





































































































I think we have to redefine that  in mseide lib. Is it a good Idea?

Regards

Med



De : fredvs <[hidden email]>
Envoyé : jeudi 8 août 2019 20:35
À : [hidden email] <[hidden email]>
Objet : Re: [MSEide-MSEgui-talk] Fonts
 
Hello Med.

> so the only solution is oncreate form which is not so  smart.

Indeed, I would use oncreated vs oncreate.

Maybe if you explain what you want to archive we can find better solution.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

fredvs
In reply to this post by mohamed hamza
Hello Med.

I think that you can do that without changing anything in mse.

With theobject.setfocus() + theform.onmouseevent().

You just have to know the area of frame.caption (but you know now how to get
his height + width).

Pseudo code:

procedure tmainfo.onmouseev(const sender: twidget; var ainfo:
mouseeventinfoty);
begin
if mouseclick_is_in_ frame.caption_area then theobject.setfocus();
end;

Fre;D





--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

mohamed hamza
Hello Fred,

    In MouseEvent Procedure we have to search the object to setfocus to  . I do not know the structure of ainfo  does it contain the object   selected?

Regards

Med.

De : fredvs <[hidden email]>
Envoyé : vendredi 9 août 2019 00:35
À : [hidden email] <[hidden email]>
Objet : Re: [MSEide-MSEgui-talk] Fonts
 
Hello Med.

I think that you can do that without changing anything in mse.

With theobject.setfocus() + theform.onmouseevent().

You just have to know the area of frame.caption (but you know now how to get
his height + width).

Pseudo code:

procedure tmainfo.onmouseev(const sender: twidget; var ainfo:
mouseeventinfoty);
begin
if mouseclick_is_in_ frame.caption_area then theobject.setfocus();
end;

Fre;D





--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

fredvs
Hello Med.

>  In MouseEvent Procedure we have to search the object to setfocus to.

Yes but if the objects dont move on the form, it will be easy to find the
object to setfocus for.

>  I do not know the structure of ainfo  does it contain the object  
> selected?

No but you will know the position of the click then you can find if it was
cliqued in a "frame.caption" area.

Maybe somebody else has a better idea than me.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

fredvs
Hello Med.

Here demo of working focus-frame-caption:
demo_focusframecaption.zip
<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/demo_focusframecaption.zip>  

And here the video of the result:
focus_framecaption.mp4
<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/focus_framecaption.mp4>  

Fre;D





--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

mohamed hamza
Hi Fred,

    Many thanks for  your help.

  I wanted  to do an  universal solution but I do not know how to get the count of components in the current form   and of course the current object .
  There is not a guide to mseide class

    I want to write something like 

     For i := 1 to   n             // n is the count  of twidget(sender)
       if object [i] is  twidgetgrid then
         if (ainfo.pos.x   and .........  )   then  twidgetgrid( object[i]. setfocus 
          exit  
         else  

Regards

Med


De : fredvs <[hidden email]>
Envoyé : vendredi 9 août 2019 14:03
À : [hidden email] <[hidden email]>
Objet : Re: [MSEide-MSEgui-talk] Fonts
 
Hello Med.

Here demo of working focus-frame-caption:
demo_focusframecaption.zip
<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/demo_focusframecaption.zip

And here the video of the result:
focus_framecaption.mp4
<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/focus_framecaption.mp4

Fre;D





--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Fonts

fredvs
Hello Med.

     for i:= 0 to form1.childrencount - 1 do begin
     if  form1.children[i] is  twidgetgrid then
          if (ainfo.pos.x   and .........  )   then  twidgetgrid(
form1.children[i].setfocus
          exit  
         else  

PS: Not tested.

Fre;D





--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
12