<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — Appgraphics Scrollbar]]></title>
	<link rel="self" href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=515&amp;type=atom" />
	<updated>2016-01-17T15:01:39Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.approximatrix.com/viewtopic.php?id=515</id>
		<entry>
			<title type="html"><![CDATA[Re: Appgraphics Scrollbar]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2325#p2325" />
			<content type="html"><![CDATA[<p>Frank,</p><p>Ah, I see the point of confusion.&nbsp; I&#039;ll take a peek at the documentation and see if it can be improved.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2016-01-17T15:01:39Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2325#p2325</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Appgraphics Scrollbar]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2324#p2324" />
			<content type="html"><![CDATA[<p>Jeff,</p><p>Thank you for providing an example of the implementation of a scroll-bar.</p><p>This example was very helpful and clarified the passing of a variable in the createscrollbar() subroutine.<br />It was not obvious to me that passing a subroutine &#039;scrolled&#039; as a parameter did not have to itself contain the passed parameter &#039;p&#039;.</p><p>scrollbar = createscrollbar(185, 0, 15, 500, SCROLL_VERTICAL, scrolled)</p><p>As in,</p><p>contains</p><p>&nbsp; &nbsp; subroutine scrolled(p)<br />&nbsp; &nbsp; implicit none<br />&nbsp; &nbsp; &nbsp; &nbsp; integer::p,i,j</p><p>&nbsp; &nbsp; &nbsp; &nbsp; scroll_position = p</p><p>&nbsp; &nbsp; &nbsp; &nbsp; call stopidle()</p><p>&nbsp; &nbsp; end subroutine scrolled</p><p>A word of caution.&nbsp; I tried moving the inner text display Do-Loop of the Do While()-End Do that displays the scrolled text to the subroutine scrolled(p) instead and it did not work as you would expect. Jeff&#039;s approach is the correct one.</p><p>!-- Incorrect implementation<br />&nbsp; &nbsp; subroutine scrolled(p)<br />&nbsp; &nbsp; &nbsp; &nbsp; implicit none<br />&nbsp; &nbsp; &nbsp; &nbsp; integer::p,i,j</p><p>&nbsp; &nbsp; &nbsp; &nbsp; scroll_position = p</p><p>&nbsp; &nbsp; &nbsp; &nbsp; call stopidle()</p><p>&nbsp; &nbsp; &nbsp; &nbsp; j = 0<br />&nbsp; &nbsp; &nbsp; &nbsp; do i = 5, 480, 25<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scroll_position = getscrollposition (scrollbar)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(text, &#039;(I4)&#039;) scroll_position+j<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; call outtextxy(10, i, text)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j + 1<br />&nbsp; &nbsp; &nbsp; &nbsp; end do<br />&nbsp; &nbsp; end subroutine scrolled</p><p>Thanks again,</p><p>Frank</p>]]></content>
			<author>
				<name><![CDATA[drfrank]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=223</uri>
			</author>
			<updated>2016-01-16T22:23:44Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2324#p2324</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Appgraphics Scrollbar]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2323#p2323" />
			<content type="html"><![CDATA[<p>Frank,</p><p>Here&#039;s a simple example of using a scrollbar:</p><div class="codebox"><pre><code>program main
use appgraphics
implicit none

    integer::myscreen
    integer::scrollbar
    integer, volatile::scroll_position
    integer::i, j
    character(len=4)::text
    
    myscreen = initwindow(200, 500, closeflag=.TRUE.)
    
    scrollbar = createscrollbar(185, 0, 15, 500, SCROLL_VERTICAL, scrolled)
    call setscrollrange(scrollbar, 0, 200)
    
    scroll_position = 0
    call settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 20)
    call setviewport(0, 0, 184, 500, .TRUE.)
    
    do while(.TRUE.)    
        call clearviewport()
        
        j = 0
        do i = 5, 480, 25
            Write(text, &#039;(I4)&#039;) scroll_position+j
            call outtextxy(10, i, text)
            j = j + 1
        end do
        
        call loop()
    end do
    
    call closewindow(myscreen)

contains

    subroutine scrolled(p)
    implicit none
    
        integer::p
        
        scroll_position = p
        
        call stopidle()
        
    end subroutine scrolled

end program main</code></pre></div><p>You can see that the scrollbar callback, <em>scrolled</em>, receives a scroll position, sets a scoped variable, and ends idling to force a redraw. You might notice that the drawing region isn&#039;t actually bigger than the window.&nbsp; The application is responsible for determining what to draw within that space based on the current position of a scroll bar.&nbsp; It&#039;s a somewhat lower level of scrolling than people might be used to dealing with in other toolkits.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2016-01-15T13:07:35Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2323#p2323</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Appgraphics Scrollbar]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2316#p2316" />
			<content type="html"><![CDATA[<p>Frank,</p><p>I apologize for the delay.&nbsp; There was a brief discussion of scroll bars in point 3 of <a href="http://forums.approximatrix.com/viewtopic.php?pid=2192#p2192">this post</a> that lays out a bit of what is supposed to happen.</p><p>Basically, one of the scroll bar arguments is a subroutine that is called whenever the scroll bar position changes.&nbsp; This subroutine should accept a single integer that represents the scroll bar&#039;s current position.&nbsp; The position range, by default, should be 1-100, but it can be changed by calling <em>setscrollrange</em> to represent whatever you&#039;d like.&nbsp; </p><p>AppGraphics might work differently than other toolkits in regards to scrolling.&nbsp; Again, AppGraphics is pretty low-level, meaning the application is responsible for creating any type of scrolling effect.&nbsp; When the scroll bar position changes, the application would have to draw the window contents based on the scroll position, in contrast to the contents being larger than the current window and our scroll bars moving the contents of the window.&nbsp; It might take a bit of getting used to, but it works in a manner similar to AppGraphic&#039;s resizing methodology.</p><p>I had though I had an already-working scroll demonstration, but apparently I do not.&nbsp; Let me build an example for you over the next day or two.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2016-01-12T12:35:37Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2316#p2316</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Appgraphics Scrollbar]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=2315#p2315" />
			<content type="html"><![CDATA[<p>Jeff,</p><p>Would it be possible to provide a simple example of the use of a scrollbar in appgraphics?</p><p>It&#039;s not clear to me how the Callback routine is implemented to activate scrolling and what the passed variables are?</p><p>It&#039;s listed in SF contents as a Subroutine but it&#039;s passed as a parameter to create a scroll bar.&nbsp; Should it be a function?</p><p>Thanks again,</p><p>Frank</p>]]></content>
			<author>
				<name><![CDATA[drfrank]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=223</uri>
			</author>
			<updated>2016-01-09T22:02:02Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=2315#p2315</id>
		</entry>
</feed>
