OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-05-2005, 17:15
petig
Guest
 
Posts: n/a
Default Where is the selected text?

Hi! At first, please be patient to my bad english. Thx. My question is the title. The case is: I select some text with text tool or page.textfind or some similare command, and I would like to know, where is it on the page. Only the selection, not the whole shape. Because I wolud like to zoom it to the middle of the screen, or make a rectangle under it or something like this. So, any idea?
Reply With Quote
  #2  
Old 13-05-2005, 00:50
petig
Guest
 
Posts: n/a
Default

OK. Maybe later. Another problem (maybe just me). When I get the fontsize with the Activeshape.Text.Story.Size and the shape is transformed, the result is the original size. There is any way to get the correct size what displayed on the text property bar? With transform matrix or any else?
Reply With Quote
  #3  
Old 14-05-2005, 05:20
petig
Guest
 
Posts: n/a
Default Reference point on an object?

Hm. Maybe I asked some special. But I have more questions. Next is:
Can I define on a shape or group a point like the rotation center? What is invisible, and move, change with the move/transformation of the shape/group, and later I can retrieve its changed position.
Reply With Quote
  #4  
Old 15-05-2005, 05:13
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Selecting Text

As far as I know it is not possible to zoom to just the selected text, it would zoom to the whole artistic string or paragraph. Sorry.
Reply With Quote
  #5  
Old 15-05-2005, 17:44
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Reference Point

You can use the Document.ReferencePoint to set the reference point.

The following example creates ellipses at four corners of the bounding box of the first selected object and in the center of the object.

Code:
Private Sub DrawEllipse(s As Shape)
  ActiveDocument.ActiveLayer.CreateEllipse2 s.PositionX, s.PositionY, 0.1
End Sub

Sub Test()
  Dim s As Shape
  Set s = ActiveShape
  ActiveDocument.ReferencePoint = cdrTopLeft
  DrawEllipse s
  ActiveDocument.ReferencePoint = cdrTopRight
  DrawEllipse s
  ActiveDocument.ReferencePoint = cdrBottomLeft
  DrawEllipse s
  ActiveDocument.ReferencePoint = cdrBottomRight
  DrawEllipse s
  ActiveDocument.ReferencePoint = cdrCenter
  DrawEllipse s
End Sub
You chould then create your own DataItem to store the objects original position.
Reply With Quote
  #6  
Old 16-05-2005, 13:32
petig
Guest
 
Posts: n/a
Default

OK, I found that way, but thats points for the actual bounding box, and I need another (freely selected) point. If I note a position relatively for these, how I can retrieve the changed position? e.g. the left top point after a 90 degree rotation will be left bottom, but the Ducoment.Referencepoint will refer for the new left top point, not the left bottom... May I use the Shape.GetMatrix? Sorry, but I dont't clearly understand the meaning of thats 6 replies, specialy the 5th (tx) and 6th (ty) parameters. And how I get, if the sahpe is not rotated, but mirrored?

Thanks.
Reply With Quote
  #7  
Old 16-05-2005, 14:48
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Ok, here is some code for you. These two functions can store a point in a shape, and then retrieve it at a later point. The coordinates are stored in relative untransformed form, so if you stretch/rotate/skew the object, the stored point will automatically get transformed too.

Code:
Sub StoreRefPoint(ByVal sShape As Shape, ByVal x As Double, y As Double)
    Dim m11 As Double, m12 As Double, m21 As Double, m22 As Double, tx As Double, ty As Double
    Dim rx As Double, ry As Double, det As Double
    
    sShape.GetMatrix m11, m12, m21, m22, tx, ty
    tx = ActiveDocument.ToUnits(tx, cdrTenthMicron) - ActiveDocument.DrawingOriginX
    ty = ActiveDocument.ToUnits(ty, cdrTenthMicron) - ActiveDocument.DrawingOriginY
    x = x - tx
    y = y - ty
    
    ' Untransform the point
    det = m11 * m22 - m12 * m21
    rx = (x * m22 - y * m21) / det
    ry = (-x * m12 + y * m11) / det
    
    sShape.Properties("StoreRefPoint", 1) = rx
    sShape.Properties("StoreRefPoint", 2) = ry
End Sub

Function GetStoredRefPoint(ByVal sShape As Shape, ByRef x As Double, ByRef y As Double) As Boolean
    Dim bRet As Boolean
    Dim m11 As Double, m12 As Double, m21 As Double, m22 As Double, tx As Double, ty As Double
    Dim vrx As Variant, vry As Variant
    
    bRet = False
    vrx = sShape.Properties("StoreRefPoint", 1)
    vry = sShape.Properties("StoreRefPoint", 2)
    
    If Not IsNull(vrx) And Not IsNull(vry) Then
        sShape.GetMatrix m11, m12, m21, m22, tx, ty
        tx = ActiveDocument.ToUnits(tx, cdrTenthMicron) - ActiveDocument.DrawingOriginX
        ty = ActiveDocument.ToUnits(ty, cdrTenthMicron) - ActiveDocument.DrawingOriginY
        
        ' Transform the point
        x = vrx * m11 + vry * m12 + tx
        y = vrx * m21 + vry * m22 + ty
        
        bRet = True
    End If
    
    GetStoredRefPoint = bRet
End Function
Yes, you are right, you need to use the transformation matrix associated with the object to get the transformations applied to the object. Then you can transform/untransform any point to be relative to object space or bring it back to the document space. If you are interested in the math of things, look for "linear transformations" and "transformation matrix" on the web. Here is one page: http://mathworld.wolfram.com/LinearTransformation.html

Here is an example which allows you to store a point into a rectangle. To do that, first create a rectangle, then draw a small ellipse on top of it. Select both objects (marquee select both, or select the ellipse first and Shift-select the rectangle). Then run this macro:

Code:
Sub TestStore()
    Dim sRect As Shape, sMarker As Shape
    Dim x As Double, y As Double
    
    Set sRect = ActiveSelection.Shapes(1)
    Set sMarker = ActiveSelection.Shapes(2)
    ActiveDocument.ReferencePoint = cdrCenter
    sMarker.GetPosition x, y
    StoreRefPoint sRect, x, y
End Sub
Then you can grab your rectangle and do some crazy stuff to it (stretch, rotate, move, etc). Finally when you are done, run the following and it will create a small circle in the new position for the stored reference point:

Code:
Sub TestRestore()
    Dim x As Double, y As Double
    If GetStoredRefPoint(ActiveShape, x, y) Then
        ActiveLayer.CreateEllipse2 x, y, 0.05
    Else
        MsgBox "No stored information present"
    End If
End Sub
I hope this helps.
Reply With Quote
  #8  
Old 16-05-2005, 16:30
petig
Guest
 
Posts: n/a
Default

Thank you, Alex! As soon as I have a little time, I'll try it, then write the result. I'm sure, this will help.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Text ENCODE Craig Tucker CorelDRAW/Corel DESIGNER VBA 10 26-01-2005 14:59
format text dialog box implement graphicdesigner CorelDRAW/Corel DESIGNER VBA 5 22-12-2004 14:37
Reading Font Properties from selected text in CD9 sherman01 CorelDRAW/Corel DESIGNER VBA 2 24-11-2004 08:59
Getting the center X on a text shape Rick Randall CorelDRAW/Corel DESIGNER VBA 4 03-08-2004 19:27
Reset text after text compression. Bellekom CorelDRAW/Corel DESIGNER VBA 2 05-05-2004 07:14


All times are GMT -5. The time now is 11:42.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com