Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #211 > unrolled thread
| Started by | Paul Sprangers <Paul@sprie.nl> |
|---|---|
| First post | 2011-04-25 17:34 +0200 |
| Last post | 2011-04-30 00:05 +0200 |
| Articles | 8 on this page of 28 — 10 participants |
Back to article view | Back to comp.sys.acorn.programmer
How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-25 17:34 +0200
Re: How to put a caret in a window Matthew Phillips <mnews@sinenomine.freeserve.co.uk> - 2011-04-25 19:29 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-25 23:28 +0200
Re: How to put a caret in a window Matthew Phillips <mnews@sinenomine.freeserve.co.uk> - 2011-04-26 23:17 +0100
Re: How to put a caret in a window Matthew Phillips <mnews@sinenomine.freeserve.co.uk> - 2011-04-27 07:38 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-27 13:31 +0200
Re: How to put a caret in a window Jeremy Nicoll - news posts <jn.nntp.scrap007@wingsandbeaks.org.uk> - 2011-04-27 13:14 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-27 17:15 +0200
Re: How to put a caret in a window pdm <pd.miller2@tiscali.co.uk> - 2011-04-27 08:59 -0700
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-27 21:50 +0200
Re: How to put a caret in a window pdm <pd.miller2@tiscali.co.uk> - 2011-04-27 23:19 -0700
Re: How to put a caret in a window Matthew Phillips <mnews@sinenomine.freeserve.co.uk> - 2011-04-27 19:58 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-27 22:15 +0200
Re: How to put a caret in a window Martin Wuerthner <spamtrap@mw-software.com> - 2011-04-30 17:12 +0200
Re: How to put a caret in a window Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-04-30 19:12 +0200
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-05-02 09:37 +0200
Re: How to put a caret in a window Alan Wrigley <spamhater@keepyourfilthyspamtoyourself.co.uk> - 2011-05-02 08:49 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-05-02 09:59 +0200
Re: How to put a caret in a window Alan Adams <alan@adamshome.org.uk> - 2011-05-02 21:27 +0100
Re: How to put a caret in a window Steve Fryatt <news@stevefryatt.org.uk> - 2011-05-02 09:08 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-30 12:54 +0200
Re: How to put a caret in a window Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-04-30 13:52 +0200
Re: How to put a caret in a window cferris@freeRemoveuk.com.invalid - 2011-04-30 13:34 +0100
Re: How to put a caret in a window Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-04-30 15:39 +0200
Re: How to put a caret in a window Matthew Phillips <mnews@sinenomine.freeserve.co.uk> - 2011-04-28 08:20 +0100
Re: How to put a caret in a window pdm <pd.miller2@tiscali.co.uk> - 2011-04-28 02:16 -0700
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-29 17:49 +0200
Re: How to put a caret in a window Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-04-30 00:05 +0200
Page 2 of 2 — ← Prev page 1 [2]
| From | Paul Sprangers <Paul@sprie.nl> |
|---|---|
| Date | 2011-04-30 12:54 +0200 |
| Message-ID | <51cc00fe22Paul@sprie.nl> |
| In reply to | #226 |
Dear Rick, Thank you for your extensive explanation. It's certainly not your fault (or anyone else's) that I still don't understand a bit of it. > Just a thought - do you have StrongHelp (or for browsing under Windows, > my StrawHelp) ? If so, grab the OS320 help file. I do have the StrongHelp OS manual, and I even have the PRM's in PDF format. Unfortunately, both tools seem to assume a certain threshold of intelligence. With the help of many people I've found out how to put the caret at the end of string, while typing. Therefore, I had to pas large values in [R3] and [R4] on entry in SYS "Font_ScanString". Only then, [R3] would contain a value other than 0 on exit. Now I want to use the same call to find the x value of the nearest character to put the caret next to, when I click somewhere in the middle of the string. Let me describe how I wander in the dark: > · How wide is a string? > Use large values for R3, R4 and no split character > · Given a width, how much of a string will fit? > AND · Address of a mouse click? > Use correct width in R3, large value in R4 and (if needed) a split char > in the buffer at R5 > · Graphical position of a caret? > Set R7 to offset into string, use huge values for R3,4, and no split The first problem that I encounter, when I read the OS stronghelp file (or your extract), is that I can't decide whether I need to find the 'Address of a mouse click?' or the 'Graphical position of a caret?' When I go for the Address of a mouse click, then I have to 'Use correct width in R3...' First of all, I have no idea what is meant by 'correct width'. Is it the width of the entire string, or the width of the string until the position of the caret? Or is it something completely different? And what is 'correct'? What are the dimensions? Pixels, points, millipoints, number of characters? Anyhow, when I enter a value in [R3] other than &7FFFFFFF, the call will always return 0 in [R3] on exit. When I go for the Graphical position of a caret, I have to set R7 to offset into string. It may have something to do with the fact that I'm Dutch, but what on earth is 'offset into string'? And again, what are its dimensions? Those help files would be so much more helpful (at least to me), if they provided an example, e.g.: *********************************************************************** EXAMPLE: Say, the x value of the mouse click is 1970. The start of the string is at 1660. So, the relative x value [offset?] of the pointer is 310. When you want to put the caret next to the nearest character at that position, you will have to use the following parameters: SYS "Font_ScanString",font%,string$,(1<<7)+(1<<8)+(1<<17),304*400,&3FFFFFF TO ,charnumb%,,cx% [R3] (=cx%) will now contain the exact position of the caret. [It doesn't.] [R1] will contain the number or the character that is nearest. [Idem.] *********************************************************************** Something like that, but then with the right parameters, of course. (Probably, this example example will prove that I totally misunderstand the whole concept, rather than missing a few details.) Apologise for my lack of notion. Hopefully, it won't discourage you to help me once more. Kind regards, Paul Sprangers
[toc] | [prev] | [next] | [standalone]
| From | Rick Murray <heyrickmail-usenet@yahoo.co.uk> |
|---|---|
| Date | 2011-04-30 13:52 +0200 |
| Message-ID | <4dbbf809$0$14672$ba4acef3@reader.news.orange.fr> |
| In reply to | #231 |
Hi, can't write much - going to do stuff in a mo...
On 30/04/2011 12:54, Paul Sprangers wrote:
> The first problem that I encounter, when I read the OS stronghelp file (or
> your extract), is that I can't decide whether I need to find the 'Address
> of a mouse click?' or the 'Graphical position of a caret?'
Logically, I would think that the "start" of the string should be
position 0,0, and the offset (address, whatever), being millipoints from
this 0,0 location.
I say 0,0 because you can't paste a string anywhere on-screen and expect
the Font Manager to know what to do with it.
> And what is 'correct'? What are the dimensions? Pixels, points,
> millipoints, number of characters?
I would imagine string length would be in bytes (possibly not equal to
characters if using UTF?), while the StrongHelp manual states:
Unlike Font_Paint, this call only allows millipoints for all
coordinates.
> into string. It may have something to do with the fact that I'm Dutch, but
> what on earth is 'offset into string'? And again, what are its dimensions?
Try characters?
string = "this is a boring example string because I lack originality!"
^ offset points here
So offset would be 18, so with a little luck, the return will be the
caret position (expressed in millipoints) of where to place the caret to
the left of the word "example".
In fine tradition, I'm writing this on a PC and have tested exactly none
of this. I guess the problem is, essentially, the bewildering array of
functions available with Font_ScanString.
Perhaps later I'll dig out my paper PRM, fire up RedSquirrel, and have a
play. I recall a gazillion years ago before we all had Internet, running
into the same sort of difficulties making sense of ScanString. Maybe now
I'm older and wiser [*], I'll look at it again.
Best wishes,
Rick.
* - both points are, however, open to debate ;-)
[toc] | [prev] | [next] | [standalone]
| From | cferris@freeRemoveuk.com.invalid |
|---|---|
| Date | 2011-04-30 13:34 +0100 |
| Message-ID | <29250acc51.cferris@cferris.freeuk.com> |
| In reply to | #226 |
In message <4dbb363e$0$30746$ba4acef3@reader.news.orange.fr>
Rick Murray <heyrickmail-usenet@yahoo.co.uk> wrote:
> On 29/04/2011 17:49, Paul Sprangers wrote:
>
> > ... I realised that I still don't understand the ins and outs
> > (entries and exits) of the Font_ScanString call.
>
> Just a thought - do you have StrongHelp (or for browsing under
> Windows, my StrawHelp) ? If so, grab the OS320 help file.
>
Thanks for your 'StrawHelp' for Windows.
How difficult would it be to do a version of 'StrawHelp' for Linux?
Thanks
--
Colin Ferris Cornwall UK
[toc] | [prev] | [next] | [standalone]
| From | Rick Murray <heyrickmail-usenet@yahoo.co.uk> |
|---|---|
| Date | 2011-04-30 15:39 +0200 |
| Message-ID | <4dbc110b$0$14666$ba4acef3@reader.news.orange.fr> |
| In reply to | #235 |
On 30/04/2011 14:34, cferris@freeRemoveuk.com.invalid wrote: > How difficult would it be to do a version of 'StrawHelp' for Linux? Near impossible - I know exactly diddly-squat about Linux (though I'm giving myself a crash course in Qt4 as it is the UI used in the Neuros OSD), plus it is written in VisualBasic, plus it has a fairly heavy dependence on the MSIE plug-in thing. I'd prefer Firefox, but to my knowledge there is no drop-in ActiveX (or whatever) to give HTML capabilities to a VB application. Um, sorry. You could, I guess, see if the thing would work under WINE? The app itself will, but I don't know how far you'd get with the IE side. Best wishes, Rick.
[toc] | [prev] | [next] | [standalone]
| From | Matthew Phillips <mnews@sinenomine.freeserve.co.uk> |
|---|---|
| Date | 2011-04-28 08:20 +0100 |
| Message-ID | <7fbce5ca51.Matthew@sinenomine.freeserve.co.uk> |
| In reply to | #226 |
In message <51caa8d5c0Paul@sprie.nl> on 27 Apr 2011 Paul Sprangers wrote: > > You'll need to set bit 8 in order to make sure the right font is measured > > As far as I understand, bit 8 doesn't need to be set if R1 contains the > pointer to the intended font. Yes, that makes sense. > > I think that bit 17 should only be set if you have a real x,y of a mouse > > click in your R3,4 and want to know the caret position and index into the > > string that is appropriate for placing the caret given the click at that > > x,y position. > > That is exactly what is next on my ToDo list, > My window has to mimic a writable icon, so it must be possible to click > somewhere in a given string and put the caret there. The only question at > the moment is: How? This one is not too bad. Subtract from the x and y of the mouse click the x and y screen co-ordinates of the place you are painting the string and pass those in R3 and R4. Pass the pointer to the string in R1 as before, and R5 and R6 equal to zero unless you want to use those features. Flags should be (1<<7)+(1<<17) Put the length of the full string in R7 (this may be unnecessary but I guess it might ensure that Font_ScanString knows where to stop scanning, which is probably a good thing to know). You'll then be given the correct co-ordinates for setting the caret in R3,R4 and R1 will point to the character in the string which the caret is before, i.e. the position you would need to insert any new characters typed. The coordinates are returned in millipoints, so use Font_ConverttoOS to get OS units. I see I have code which just divides by 400 but that's probably not particularly good practice. Regarding my suggestion that you avoid using &7FFFFFFF for big values in R3 and R4. Looking at my code again I see that actually it was only the "y" value that caused a problem, and in fact only when using the call with bit 17 set. I use &10000000 in y and &7FFFFFFF for x and it all works fine. I cannot remember what the symptoms of the problem were: I think it only affected certain fonts or font sizes. I don't seem to have documented it in the source code. It's perhaps in my CVS logs somewhere. But anyway, I'd advise not using &7FFFFFFF for R4 to be on the safe side. -- Matthew Phillips Durham
[toc] | [prev] | [next] | [standalone]
| From | pdm <pd.miller2@tiscali.co.uk> |
|---|---|
| Date | 2011-04-28 02:16 -0700 |
| Message-ID | <f18e4487-0f70-433d-bcde-e4d6d728142e@p23g2000vbl.googlegroups.com> |
| In reply to | #238 |
On Apr 28, 8:20 am, Matthew Phillips <mn...@sinenomine.freeserve.co.uk> wrote: > In message <51caa8d5c0P...@sprie.nl> > on 27 Apr 2011 Paul Sprangers wrote: > <snip> > > This one is not too bad. Subtract from the x and y of the mouse click the x > and y screen co-ordinates of the place you are painting the string and pass > those in R3 and R4. Pass the pointer to the string in R1 as before, and R5 > and R6 equal to zero unless you want to use those features. > > Flags should be (1<<7)+(1<<17) > > Put the length of the full string in R7 (this may be unnecessary but I guess > it might ensure that Font_ScanString knows where to stop scanning, which is > probably a good thing to know). > Font_ScanString also expects millipoint values on input, so before using it convert your calculated OS unit values by calling Font_Converttopoints - SYS "Font_Converttopoints",,cx%, cy% TO ,cx%, cy% > > You'll then be given the correct co-ordinates for setting the caret in R3,R4 > and R1 will point to the character in the string which the caret is before, > i.e. the position you would need to insert any new characters typed. > > The coordinates are returned in millipoints, so use Font_ConverttoOS to get > OS units. > <snip> Regards, Pete Miller.
[toc] | [prev] | [next] | [standalone]
| From | Paul Sprangers <Paul@sprie.nl> |
|---|---|
| Date | 2011-04-29 17:49 +0200 |
| Message-ID | <51cb982b94Paul@sprie.nl> |
| In reply to | #238 |
Dear Matthew,
When I was reading your advice on how to calculate the place of the caret
when clicking in a string ...
> Subtract from the x and y of the mouse click the x and y screen
> co-ordinates of the place you are painting the string and pass those in
> R3 and R4. Pass the pointer to the string in R1 as before, and R5 and
> R6 equal to zero unless you want to use those features.
... I realised that I still don't understand the ins and outs (entries and
exits) of the Font_ScanString call.
When I subtract the x screen co-ordinate from the x mouse click, the result
is a number roughly between 100 and 400. Even if I convert that value to
millipoints (which multiplies it by 400, indeed), I still have a value that
is far, far less than the value of &7FFFFFFF that I originally had to pass
through R3, in order to get something returned in cx%.
Therefore, I was expecting that cx% would be 0 again, after passing a
calculated millipoints value, roughly between 40,000 and 160,000 through
R3. And so it appeared to be.
Apparently, I don't understand something (many things). Could you once
again try to explain it to me?
The relevant code, that I have so far is:
DEF PROCwindowclick(mx%,my%,button%)
CASE button% OF
WHEN 1,4
block%!0=window%
SYS "Wimp_GetWindowInfo",,block%
windowx%=block%!4-block%!16
ox%=mx%-windowx%
SYS "Font_Converttopoints",,ox% TO ,ox%
PROCcaret(ox%,maxy%,LENstring$)
PROCredraw(window%)
ENDCASE
ENDPROC
DEF PROCcaret(x%,y%,len%)
SYS "Font_ScanString",iconfont%,string$,(1<<7)+(1<<17),x%,y%,,,len% TO
,,,cx%,,,,l%
SYS "Font_ConverttoOS",,cx% TO ,cx%
SYS "Wimp_SetCaretPosition",window%,-1,cx%+10,-44,40,-1
ENDPROC
(maxy% in PROCcaret is previously set to &3FFFFFFF.)
Kind regards,
Paul Sprangers
[toc] | [prev] | [next] | [standalone]
| From | Rick Murray <heyrickmail-usenet@yahoo.co.uk> |
|---|---|
| Date | 2011-04-30 00:05 +0200 |
| Message-ID | <4dbb363e$0$30746$ba4acef3@reader.news.orange.fr> |
| In reply to | #256 |
On 29/04/2011 17:49, Paul Sprangers wrote:
> ... I realised that I still don't understand the ins and outs (entries and
> exits) of the Font_ScanString call.
Just a thought - do you have StrongHelp (or for browsing under Windows,
my StrawHelp) ? If so, grab the OS320 help file.
=> R0 = initial font handle, or 0 for current
R1 = pointer to string
R2 = flags
R3,4 = (x,y) of mouse click, or max w,h of string
R5 = pointer to block holding spacing, split & bounding box
R6 = pointer to transformation matrix
R7 = length of string
> When I subtract the x screen co-ordinate from the x mouse click, the result
> is a number roughly between 100 and 400.
By screen X co-ord, you mean the position of the start of the string?
All of this must be relative to the start of the string, so Font_xxx
knows what it is working with.
> I still have a value that is far, far less than the value of&7FFFFFFF
That was specifying, instead, a "maximum" size.
--8<--------
This SWI is used to find various info on a string :
· How wide is a string?
Use large values for R3, R4 and no split character
· Given a width, how much of a string will fit?
AND · Address of a mouse click?
Use correct width in R3, large value in R4 and (if needed) a split char
in the buffer at R5
· Graphical position of a caret?
Set R7 to offset into string, use huge values for R3,4, and no split
Registers 0,5,6 and 7 are only used if bits 8,5,6 and 7 are set in R2
--8<--------
> in order to get something returned in cx%.
^^^
It makes things easier if you put the register number in brackets -
saves us looking at the code and counting commas. ;-)
> block%!0=window%
> SYS "Wimp_GetWindowInfo",,block%
> windowx%=block%!4-block%!16
> ox%=mx%-windowx%
windowx = visible_area_min_x - scroll_x ?
Given it is a nasty offset-by-4 return (for window handle at !0), I'm
wondering if something isn't astray here. If !4 is the x offset, that
would mean the !16 is really !12, which is visible area minimum Y.
> SYS "Font_Converttopoints",,ox% TO ,ox%
OS units to millipoints, which you then pass to ScanString...
> SYS "Font_ScanString",iconfont%,string$,(1<<7)+(1<<17),x%,y%,,,len% TO
> ,,,cx%,,,,l%
You set bits 7 and 17 = R7 is length of string, and to return the
nearest caret position.
Shouldn't you also set bit 8 - saying R0 is the initial font handle? If
this bit is clear, the current font will be assumed, which mightn't be
what you expect under the WIMP...
x% and y% are the mouse click position, though I would imagine this
ought to be preprocessed to have 0,0 being the start of the string.
Best wishes,
Rick.
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.sys.acorn.programmer
csiph-web