bb.donnay-software.com

Donnay Software Web Forums
It is currently Mon May 20, 2019 5:37 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: DCMULTILINE and Fontsize
PostPosted: Wed Dec 05, 2018 12:00 am 
Offline

Joined: Mon Feb 01, 2010 8:45 am
Posts: 117
Hello,

i want add a function to change the font size as needed with the
xbeK_P_CTRL_MINUS and xbeK_P_CTRL_PLUS keys
How i can do this ?

I have

Code:
@  1, 1 DCMULTILINE k_txt SIZE lastcol-5, 5 LINELENGTH 150 EXITKEY xbeK_F6 ;
            FONT {|| myEditFont(nFontSize, GetList)} WHEN {|| !v_dru } PARENT oGroupReKote


Code:
static function myEditFont(nFontSize, aGetList)
Local nKey := DC_ReadGuiLastKey(aGetList)

IF nKey = xbeK_P_CTRL_PLUS    // CTRL und +
   IF nFontSize < 16
      nFontSize++
   ENDIF
ENDIF
IF nKey = xbeK_P_CTRL_MINUS    // CTRL und -
   IF nFontSize > 8
      nFontSize--
   ENDIF
ENDIF
return ltrim(str(nFontSize))+".Courier"

_________________
Klaus


Top
 Profile  
 
PostPosted: Wed Dec 05, 2018 1:57 am 
Offline
User avatar

Joined: Thu Jan 28, 2010 12:59 am
Posts: 733
Location: Berlin, Germany
Hi, Klaus.

1. Add a custom handler using DCREAD GUI ... HANDLER(BLOCK). Hand the DCMULTILINE object and the current font size* to the handler.

2. In the (addiditional) handler, check keyboard events for xbeK_P_CTRL_PLUS and xbeK_P_CTRL_MINUS - and check whether they occur while the multiline has focus. Increase/decrease the font size like you did in your function.

3. Change the font using oMLE:SetFontCompoundName(<cNewFont>) with font size and name. Don't use a codeblock for the font - this won't work.

* You may extract the font size from oMLE:SetFontCompoundName(), so you don't need to hand it as a parameter.

If you need more help or maybe a small sample, let me know.

_________________
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."


Top
 Profile  
 
PostPosted: Wed Dec 05, 2018 2:12 am 
Offline
User avatar

Joined: Thu Jan 28, 2010 12:59 am
Posts: 733
Location: Berlin, Germany
This works as you want it:

Code:
#pragma Library("Dclipx.lib")

proc AppSys() ; RETURN

FUNCTION Main()
LOCAL GetList := {}, c := 'I love this f*cking bullshit', oMLE, cFont := "12.Tahoma"

@ 1,1 DCMULTILINE c SIZE 100,20 OBJECT oMLE FONT cFont

DCREAD GUI FIT ADDBUTTONS TITLE 'Test' ;
       HANDLERBLOCK {|a,b,c,d,e,f|MyHandler(a,b,c,d,e,f,oMLE)}

RETURN NIL

FUNCTION MyHandler(nEvent,mp1,mp2,oXbp,oDlg,GetList,oMLE)
LOCAL cFont := oMLE:SetFontCompoundName(), nFontSize := Val(Left(cFont,At(".",cFont)-1)), cFontName := SubStr(cFont,At(".",cFont)+1), lFontChanged := .F.
IF nEvent == xbeP_Keyboard .AND. oXbp == oMLE
  IF mp1 == xbeK_P_CTRL_PLUS .AND. nFontSize < 24
    nFontSize ++
    lFontChanged := .T.
    ELSE
    IF mp1 == xbeK_P_CTRL_MINUS .AND. nFontSize > 6
      nFontSize --
      lFontChanged := .T.
    ENDIF
  ENDIF
  IF lFontChanged
    oMLE:SetFontCompoundName(LTrim(Str(nFontSize,2,0))+"."+cFontName)
  ENDIF
ENDIF
RETURN DCGUI_NONE

_________________
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."


Last edited by Tom on Wed Dec 05, 2018 3:03 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Wed Dec 05, 2018 2:47 am 
Offline

Joined: Mon Feb 01, 2010 8:45 am
Posts: 117
Tom,
thank you.

_________________
Klaus


Top
 Profile  
 
PostPosted: Wed Dec 05, 2018 3:04 am 
Offline
User avatar

Joined: Thu Jan 28, 2010 12:59 am
Posts: 733
Location: Berlin, Germany
A pleasure. ;)

I added a small change (lFontChanged) which will prevent SetFontCompoundName to be executed with every key stroke.

_________________
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."


Top
 Profile  
 
PostPosted: Tue Dec 11, 2018 11:39 pm 
Offline

Joined: Mon Feb 01, 2010 8:45 am
Posts: 117
One more question.
How i can obtain which object is aktive i i can give the correct object to the HANDLERBLOCK ?

I have 2 dcmultiline
Code:
@  3.2,  1 DCSAY mess257
@ 03, 15 DCMULTILINE m_khin SIZE 65, lastrow-8 LINELENGTH 55 NOHORIZSCROLL ;
         OBJECT oMLE FONT cFont ;
         MESSAGE mess262

@  3.2, 97 DCSAY mess1839 ALIGNRIGHT
@ 03, 99 DCMULTILINE m_vtext SIZE 60, lastrow-8 LINELENGTH 50 NOHORIZSCROLL ;
         OBJECT oMLE1 FONT cFont ;
         MESSAGE mess1840

DCREAD GUI OPTIONS GetOptions TITLE mess195 + " " + Printaz(m_kdnr) + " " + ;
       rtrim(m_match) + ' '+mess196 MODAL SETAPPWINDOW to lOk ENTEREXIT ;
       HANDLERBLOCK {|a,b,c,d,e,f|MyMultiLineHandler(a,b,c,d,e,f,oMLE)}

_________________
Klaus


Top
 Profile  
 
PostPosted: Wed Dec 12, 2018 12:00 am 
Offline

Joined: Wed Jan 27, 2010 10:25 pm
Posts: 336
Location: Berlin Germany
Give your MLEs as parameter to the Handler:
Code:
DCREAD ......
HANDLER MyMultiLineHandler REFERENCE aRef ;
EVAL {|o| aRef[1]:=oMLE, aRef[2]:=oMLE1 }

in the Handler you have now access to the MLEs:
Code:
FUNCTION MyMultiLineHandler( nEvent, mp1, mp2, oXbp, GetList, oDialog, aRef)
local oMLE:=aRef[1], oMLE1:=aRef[2]

_________________
_______________________
Best Regards
Wolfgang


Top
 Profile  
 
PostPosted: Wed Dec 12, 2018 1:31 am 
Offline
User avatar

Joined: Thu Jan 28, 2010 12:59 am
Posts: 733
Location: Berlin, Germany
Or, easier: Just check if oXbp is a DCMULTILINE inside the handler:

Code:
IF oXbp:IsDerivedFrom("XbpMLE")
  * get font
  * act on font resizing
ENDIF


In this situation, you don't have to use oMLE as a parameter for the handler. But you have to move this operations:

Code:
cFont := oMLE:SetFontCompoundName()
nFontSize := Val(Left(cFont,At(".",cFont)-1))
cFontName := SubStr(cFont,At(".",cFont)+1)

from the definition of the local vars to the IF-statement, since not all other Xbparts have font settings. That's it. If you want to have this working for all MLEs, that's the way to do it. No changes to other code necessary, just this handler everywhere you have DCMULTILINES.

_________________
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."


Top
 Profile  
 
PostPosted: Wed Dec 12, 2018 4:20 am 
Offline

Joined: Mon Feb 01, 2010 8:45 am
Posts: 117
Wolfgang, Tom
Thanks

Now i use this:
Code:
FUNCTION MyMultiLineHandler(nEvent,mp1,mp2,oXbp,oDlg,GetList)
LOCAL cFont := "", ;
      nFontSize := 0, ;
      cFontName := "", ;
      lFontChanged := .F.

IF ISOBJECT( oXbp )

   IF oXbp:IsDerivedFrom("XbpMLE")
      cFont := oXbp:SetFontCompoundName()
      nFontSize := Val(Left(cFont,At(".",cFont)-1))
      cFontName := SubStr(cFont,At(".",cFont)+1)
   ENDIF

   IF nEvent == xbeP_Keyboard .AND. oXbp:IsDerivedFrom("XbpMLE")
     IF mp1 == xbeK_P_CTRL_PLUS .AND. nFontSize < 16
       nFontSize ++
       lFontChanged := .T.
       ELSE
       IF mp1 == xbeK_P_CTRL_MINUS .AND. nFontSize > 8
         nFontSize --
         lFontChanged := .T.
       ENDIF
     ENDIF
     IF lFontChanged
       oXbp:SetFontCompoundName(LTrim(Str(nFontSize,2,0))+"."+cFontName)
     ENDIF
   ENDIF

ENDIF
RETURN DCGUI_NONE

_________________
Klaus


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 3 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
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group