It is currently Thu Jul 18, 2019 8:28 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Set Center Align in StringGadget : Vertical 'n' Horizont
PostPosted: Wed Jun 12, 2019 4:36 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 671
Location: Canada
Thank you for your input and interest, RASHAD.

RASHAD wrote:
...you are depending on the font Size which can not be perfect
I realize that, but I arrived at that solution by trial and error. No great math theory or understanding behind what I'm doing here. It just works for 99.5% of the cases.

RASHAD wrote:
For comparing between StringGadget() 2 & 3 I did not notice any difference
The reason you see no great difference is, of course, because of the corrective padding I apply when re-fitting the StringGadget(). My mistake. Since I wanted you to see the difference, i should have left out the padding entirely.

RASHAD wrote:
...please put your Procedures out of the main gui just for me
Sorry, I don't know what you mean here.

But I've re-organized the code in a cleaner way and I've added a checkbox so you can see the difference with/without additional padding.

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Top
 Profile  
Reply with quote  
 Post subject: Re: Set Center Align in StringGadget : Vertical 'n' Horizont
PostPosted: Wed Jun 12, 2019 5:21 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3351
For vPadding & hPadding I do the same trial and error
For Procedure staff ,but I will not insist on that :mrgreen:
Code:
Procedure
EndProcedure

Procedure
EndProcedure

LoadFont(0,"Tahoma",14)
OpenWindow(0, 0, 0, 600, 400, "StringGadget ", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
StringGadget(1, 10,10,580,40,"ABCDEJQ")

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow


_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Set Center Align in StringGadget : Vertical 'n' Horizont
PostPosted: Wed Jun 12, 2019 5:27 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 671
Location: Canada
OK, now I understand. :D

In my defense, i had corrected the code before you said anything. But I have a very good excuse for the sloppy posting of last night : it was 3h15 in the morning and I had both eyes in a single hole, looking no further than the tip of my nose.

Thanks RASHAD
Always enlightening to exchange with you.

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Top
 Profile  
Reply with quote  
 Post subject: Re: Set Center Align in StringGadget : Vertical 'n' Horizont
PostPosted: Wed Jun 12, 2019 6:04 pm 
Offline
Addict
Addict

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 808
Location: Germany
StringEx - Module
(I have added a attribute for padding)

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules (GitHub)

[Windows 10 x64] [PB V5.7x]


Top
 Profile  
Reply with quote  
 Post subject: Re: Set Center Align in StringGadget : Vertical 'n' Horizont
PostPosted: Wed Jun 12, 2019 6:28 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3351
Hi Blue
I feel free after you informed me that you are Windows user
Next is what I think it is the proper alignment for StringGadget()
Code:
Global h,w

Procedure CharH(gadget,font , text$)
  hdc = GetDC_(GadgetID(gadget))
  SelectObject_(hdc, FontID(font))
  GetTextMetrics_(hdc, @tm.TEXTMETRIC)
  h = tm\tmHeight + tm\tmInternalLeading + tm\tmExternalLeading
  GetTextExtentPoint32_(hdc , @text$ ,Len(text$),@s.SIZE)
  w = s\cx+tm\tmAveCharWidth
  ReleaseDC_(GadgetID(gadget), hdc)
EndProcedure

LoadFont(0,"Tahoma",14)
text$ = "ABCDEJQ"+" " ;Remember to add a space
OpenWindow(0, 0, 0, 600, 400, "StringGadget ", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowColor(0,#White)
StringGadget(1, 10,10,580,40,Text$)
SetGadgetFont(1,FontID(0))
CharH(1,0 ,text$)

ResizeGadget(1,10,10,w,h)

Repeat

Until WaitWindowEvent() = #PB_Event_CloseWindow

_________________
Egypt my love


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye