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

Username:   Password: 
 RegisterRegister   
 GUI implementation
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Geminias




PostPosted: Fri Jan 06, 2006 4:02 am   Post subject: GUI implementation

need some help from you turing experts.

its not really as much as it seems and its well organized take a look:

Turing:

import GUI

setscreen ("graphics:max,max,nobuttonbar")

var sizeOfArray : int := 1
var linesArray : array 1 .. sizeOfArray of string
var search, url : string  %Globals

%the view window---------------------------------------
var canvasID : int := GUI.CreateCanvas (10,0, maxx - 20, maxy - 100)
%end view window---------------------------------------

proc searchProc (search, url : string)

    var stream : int    := Net.OpenURLConnection (url)
    var lines  : string
    var y      : int    := 30
    var font1  : int    := Font.New ("serif:12")
    var Y      : string
if stream <= 0 then  %error check.
  GUI.FontDraw (canvasID, "Unable to establish connection", 0, y, font1, black)
  return  %End Procedure (allow user to enter new url)
end if
loop
  exit when eof
  get : stream, lines
  GUI.FontDraw (canvasID, lines+"Y="+Y, 0, y, font1, black)
  y -= 1
  Y := (string) y
  linesArray (sizeOfArray++) := lines
end loop
Net.CloseConnection (stream)
 
end searchProc
GUI.SetBackgroundColor (gray)


%textfields-----------------------------------------
    var searchField_ID, urlField_ID : int

proc searchFieldProc (text : string)
   GUI.SetSelection (urlField_ID, 0, 0)
   GUI.SetActive    (urlField_ID)
end searchFieldProc

proc urlFieldProc (text : string)

 %should automatically press search if user hits enter whilst in this text field.

end urlFieldProc


searchField_ID := GUI.CreateTextFieldFull (200, 873, 690,
                  "Enter the word or phrase to be sought", searchFieldProc,
                  GUI.INDENT, 0, 0)
urlField_ID    := GUI.CreateTextFieldFull (200, 853, 690,
                  "Enter the url here", urlFieldProc, GUI.INDENT, 0, 0)
var search_label   := GUI.CreateLabelFull (195, 873, "Find", 0, 0, GUI.RIGHT, 0)
var url_label      := GUI.CreateLabelFull (195, 853, "URL", 0, 0, GUI.RIGHT, 0)
%end textfields---------------------------------------                     
%buttons----------------------------------------------
proc searchButtonProc
   search := GUI.GetText (searchField_ID)
   url    := GUI.GetText (urlField_ID)
   searchProc (search, url)
end searchButtonProc


   var search_button : int := GUI.CreateButton (900, 850, 0, "Search", searchButtonProc)
%end buttons-------------------------------------------
       
        var scrollBar : int
       
        procedure ScrollBarMoved (value : int)
               
        end ScrollBarMoved
       
        scrollBar := GUI.CreateVerticalScrollBar (10, 0, 814,
            50, 150, 50, ScrollBarMoved)
     
loop  %message loop
   exit when GUI.ProcessEvent
end loop
Sponsor
Sponsor
Sponsor
sponsor
Geminias




PostPosted: Fri Jan 06, 2006 4:07 am   Post subject: (No subject)

now the questions:

first of all that won't compile unless you fix the type casting i did in the searchProc.

I need to know the turing sytnax for type casting. i used "(string) some_integer" which is the c++ syntax.

Now the big question: Does anyone know an easy way to get the canvas to attach itself to the scroll bar?

I intend to do it the hard way if not. I'm going to tell the scroll bar to redraw the widget along with all the lines. (hence the global array that i just put in there) it will store all the lines, then i'll have the widget redraw itself with all the lines based on the position of the scroll bar. That is a lot of retarded work but... its the only possible way i know of so pipe up if you know an easier way.
Cervantes




PostPosted: Fri Jan 06, 2006 8:43 am   Post subject: (No subject)

code:

Y := intstr (y)


Turing Walkthrough -> String Manipulation tutorial

Also, having variables 'y' and 'Y' is generally a bad idea. Variable names should be descriptive, and not so similar to other variable names.
Geminias




PostPosted: Fri Jan 06, 2006 10:50 pm   Post subject: (No subject)

lol, thanks Cervantes.

Quote:

Variable names should be descriptive, and not so similar to other variable names.


I think I know that. The Y is symbolic to me and is not going to be included in the final source. It was for debugging purposes only, so that i could see the y value.

Quote:

Now the big question: Does anyone know an easy way to get the canvas to attach itself to the scroll bar?


this is the real reason I posted. The type casting was just a thing i figured I'd add in.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: