Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 changing screen size using corners of the run window
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Siavash




PostPosted: Mon May 25, 2009 9:38 pm   Post subject: changing screen size using corners of the run window

ive seen many tutorials on how to change screen size like the fallowing:
Turing:

setscreen ('graphics:maxx,maxy')

But how do i allow the user make the screen larger by dragging the corners of the run window?
Sponsor
Sponsor
Sponsor
sponsor
DtY




PostPosted: Mon May 25, 2009 9:57 pm   Post subject: RE:changing screen size using corners of the run window

As far as I know, you can't
Dusk Eagle




PostPosted: Mon May 25, 2009 11:30 pm   Post subject: Re: changing screen size using corners of the run window

You can't do what you wanted, but you can set the screen size using variables, like this:
Turing:

var x_size := 100
var y_size := 180
View.Set ("graphics:" + intstr(x_size) + "," + intstr(y_size))

So, since this is entirely possible, you could add buttons to your screen that increase or decrease the screen's size. Not sure if this can help you here, but it's an interesting thing to know either way,
Kharybdis




PostPosted: Tue May 26, 2009 7:57 am   Post subject: RE:changing screen size using corners of the run window

you can kinda cheat and make this possible... like you can do with anything..

but i wouldn't recommend it. too much work..
BigBear




PostPosted: Tue May 26, 2009 9:34 am   Post subject: Re: RE:changing screen size using corners of the run window

Kharybdis @ Tue May 26, 2009 7:57 am wrote:
you can kinda cheat and make this possible... like you can do with anything..

but i wouldn't recommend it. too much work..


How is it cheating, you can't drag the corners with the mouse but you can figure out a way of using turing, isn't that what programming is learning how to use a programming language?
Geniis




PostPosted: Wed May 27, 2009 6:02 pm   Post subject: Re: changing screen size using corners of the run window

i made a quick prog to resize the window once. All i did was check if the mouse was on a border or corner then then figured out the difference and set the screens size with setscreen to the old size plus the difference. But whenever i did the window would disappear and reapear so its not worth dooing.
DemonWasp




PostPosted: Wed May 27, 2009 9:10 pm   Post subject: RE:changing screen size using corners of the run window

This code demonstrates how this can be done, but as Geniis notes, it destroys and re-creates the window every time you resize it, and it doesn't resize with the cursor (you could also do that, but I didn't). It's also not perfect - if you click your mouse anywhere and drag over that corner, it'll grab it anyway (this is fixable, but I'm lazy).

Turing:

var x, y : int := 400               % Size of the screen
var mx, my, mb : int                % Mouse status
var dragging : boolean := false     % True if and only if we're dragging the window corner
const TOLERANCE : int := 5          % Tolerance for mouse-click distance, in pixels

fcn nearEquals (a, b, tol : int) : boolean      % Comparator that's essentially "approximately equal to, plus or minus 'tol'".
    result a + tol >= b and a - tol <= b
end nearEquals

View.Set ("graphics:" + intstr (x) + ";" + intstr (y))

loop
    % Grab input information
    Mouse.Where (mx, my, mb)

    if mb > 0 and nearEquals (x, mx, TOLERANCE) and nearEquals (0, my, TOLERANCE) then     % We're clicking near that corner, start dragging
        dragging := true
    elsif mb = 0 and dragging then    % Released, so resize
        dragging := false
        x := mx
        y := maxy-my
        View.Set ("graphics:" + intstr (x) + ";" + intstr (y))
    end if

    % Debugging output
    Text.Locate (1, 1)
    put "x = ", x, "; y = ", y
    put "mx = ", mx, "; my = ", my
    put "dragging = ", dragging
end loop
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: