Turing Help! ^^

Computer builds, hardware and software discussion or troubleshooting, including peripherals. Essentially a general place to talk about desktop computers.
Locked
KukuriChan
Posts: 13
Joined: Tue Dec 30, 2003 1:41 pm

Turing Help! ^^

Post by KukuriChan »

I'm making a paint program but there are some things I don't know how to do. First of all, I want to make a colour palette with a scrollbar except that the codes I used doesn't work.

var x := 90
var x2 := 106
var y := 40
var y2 := 55

for col : 0 .. 31
drawfillbox (x, y, x2, y2, col)
x := x + 16
x2 := x2 + 16
end for

I want to include the scrollbar so that if it goes off the screen you'll be able to keep on scrolling to get the colour. Can anybody help me with that? I looked in the Help Menu but the thing I want to do, it won't let me and it always says that there are errors. :cry: I don't know what to do!

I also need help with how the code should look like if you want to fill the canvas with a certain colour. ^^;;

Archived topic from Iceteks, old topic ID:1859, old post ID:15327
User avatar
Red Squirrel
Posts: 29206
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

Turing Help! ^^

Post by Red Squirrel »

I don't think allot of us know turing but I know syb does so maybe he can help you when he comes on. ;)

Archived topic from Iceteks, old topic ID:1859, old post ID:15328
Honk if you love Jesus, text if you want to meet Him!
KukuriChan
Posts: 13
Joined: Tue Dec 30, 2003 1:41 pm

Turing Help! ^^

Post by KukuriChan »

Ok. Thanks.

Archived topic from Iceteks, old topic ID:1859, old post ID:15332
syb
Posts: 222
Joined: Wed Jun 18, 2003 10:12 pm

Turing Help! ^^

Post by syb »

thats going to be a lot of graphic input man!

scollbar:
% The "Scrllbrs" program.
% This demonstrates the Scroll Bar widget along with the GUI routines
% that use Scroll Bar widgets. [Enable, Disable, Show, Hide,
% SetPosition, SetSize, Refresh, SetSliderValue, Quit, SetSliderReverse,
% SetSliderMinMax, CreateHorizontalScrollBar, CreateVerticalScrollBar,
% ProcessEvent, Dispose]

import GUI in "%oot/support/lib/GUI" % Must be included in a programs using the GPL

View.Set ("graphics:400;300") % Shrink the window to the minimum size

% The slider IDs
var verticalScrollBar, horizontalScrollBar : int

% The label ID
var minMaxLabel : int

% The button IDs
var reverseButton, enableDisableButton, showHideButton : int
var moveButton, resizeButton, refreshButton, setPositionButton : int
var setMinMaxButton, quitButton : int

% Variables used by the button routines
var enable := false % Whether to enable or disable the slider
var hide := true % Whether to hide or show the slider
var newValue := 50 % Value to set slider to
var minMax := 1 % Setting for min/max
var up := true % Whether to move the slider up or down
var big := false % Whether to make the slider big or small

% The routines the widgets call when pressed
% Called when vertical slider moved
procedure VerticalScrollBarMoved (value : int)
locate (1, 1)
put "Vertical Scroll Bar: ", value : 4 ..
end VerticalScrollBarMoved

% Called when horizontal slider moved
procedure HorizontalScrollBarMoved (value : int)
locate (2, 1)
put "Horizontal Scroll Bar: ", value : 4 ..
end HorizontalScrollBarMoved

% Called when enable/disable button is pressed
procedure EnableDisablePressed
locate (3, 1)
if enable then
put "Horizontal Scroll Bar Enabled " ..
GUI.Enable (horizontalScrollBar) % Enable Horizontal Scroll Bar
enable := false
GUI.SetLabel (enableDisableButton, "Disable Horizontal Scroll Bar")
else
put "Horizontal Scroll Bar Disabled " ..
GUI.Disable (horizontalScrollBar) % Disable Horizontal Scroll Bar
enable := true
GUI.SetLabel (enableDisableButton, "Enable Horizontal Scroll Bar")
end if
end EnableDisablePressed

% Called when show/hide button is pressed
procedure ShowHidePressed
locate (1, 1)
if hide then
put "Horizontal Scroll Bar Hidden " ..
GUI.Hide (horizontalScrollBar) % Hide Horizontal Scroll Bar
hide := false
GUI.SetLabel (showHideButton, "Show Horizontal Scroll Bar")
else
put "Horizontal Scroll Bar Shown " ..
GUI.Show (horizontalScrollBar) % Show Horizontal Scroll Bar
hide := true
GUI.SetLabel (showHideButton, "Hide Horizontal Scroll Bar")
end if
end ShowHidePressed

% Called when move button is pressed
procedure MovePressed
locate (3, 1)
if up then
put "Horizontal Scroll Bar Moved Up " ..
GUI.SetPosition (horizontalScrollBar, 60, maxy - 60)
% Move Horizontal Scroll Bar Right
up := false
GUI.SetLabel (moveButton, "Move Scroll Bar Down")
else
put "Horizontal Scroll Bar Moved Down " ..
GUI.SetPosition (horizontalScrollBar, 60, maxy - 110)
% Move Horizontal Scroll Bar Left
up := true
GUI.SetLabel (moveButton, "Move Scroll Bar Up")
end if
end MovePressed

% Called when refresh button is pressed
procedure RefreshPressed
Draw.FillBox (0, 0, maxx, maxy, GUI.GetBackgroundColour) % Clear the screen
GUI.Refresh % Redraw all the widgets on the screen
end RefreshPressed

% Called when set position button is pressed
procedure SetPositionPressed
locate (3, 1)
put "Horizontal Scroll Bar Set to ", newValue, " " ..
GUI.SetSliderValue (horizontalScrollBar, newValue)
newValue += 50
if newValue > 200 then
newValue := 50
end if
GUI.SetLabel (setPositionButton, "Set Scroll Bar To " +
intstr (newValue))
end SetPositionPressed

% Called when set min/max is pressed
procedure SetMinMaxPressed
var newMin, newMax : int
case minMax of
label 0 :
newMin := - 100
newMax := 200
label 1 :
newMin := 0
newMax := 300
label 2 :
newMin := 50
newMax := 250
label 3 :
newMin := 100
newMax := 200
end case
GUI.SetSliderMinMax (horizontalScrollBar, newMin, newMax)
GUI.SetLabel (minMaxLabel, "Min: " + intstr (newMin) + " Max: " +
intstr (newMax))
minMax := (minMax + 1) mod 4
end SetMinMaxPressed

% Called when resize button is pressed
procedure ResizePressed
locate (3, 1)
if big then
put "Horizontal Scroll Bar Made Large " ..
% Move and Resize Horizontal Scroll Bar
GUI.SetSize (horizontalScrollBar, 250, 0)
big := false
GUI.SetLabel (resizeButton, "Make Scroll Bar Small")
else
put "Horizontal Scroll Bar Made Small " ..
% Move and Resize Horizontal Scroll Bar
GUI.SetSize (horizontalScrollBar, 150, 0)
big := true
GUI.SetLabel (resizeButton, "Make Scroll Bar Large")
end if
end ResizePressed

% Called when reverse button is pressed
procedure ReversePressed
locate (3, 1)
put "Scroll Bars Direction Reversed " ..
GUI.SetSliderReverse (horizontalScrollBar)
GUI.SetSliderReverse (verticalScrollBar)
end ReversePressed

% Called when quit button is pressed.
procedure QuitPressed
GUI.Quit
end QuitPressed

% The main program
% Create the buttons
horizontalScrollBar := GUI.CreateHorizontalScrollBar (60, maxy - 110, 250,
50, 150, 50, HorizontalScrollBarMoved)
verticalScrollBar := GUI.CreateVerticalScrollBar (350, maxy - 110, 100, 50,
150, 50, VerticalScrollBarMoved)

% Create a label specifying the min/max of vertical slider
minMaxLabel := GUI.CreateLabelFull (60, maxy - 110 + GUI.GetScrollBarWidth,
"Min: 50 Max: 150", 250, 50 - GUI.GetScrollBarWidth,
GUI.CENTER + GUI.MIDDLE, 0)

% Create the dividing line
var line := GUI.CreateLine (0, maxy - 135, maxx, maxy - 135, 0)

% Create the buttons
enableDisableButton := GUI.CreateButton (20, maxy - 170, 170,
"Disable Horizontal Scroll Bar", EnableDisablePressed)
showHideButton := GUI.CreateButton (210, maxy - 170, 170,
"Hide Horizontal Scroll Bar", ShowHidePressed)
moveButton := GUI.CreateButton (20, maxy - 200, 170, "Move Scroll Bar Up",
MovePressed)
refreshButton := GUI.CreateButton (210, maxy - 200, 170, "Refresh",
RefreshPressed)
setPositionButton := GUI.CreateButton (20, maxy - 230, 170,
"Set Scroll Bar To 50", SetPositionPressed)
setMinMaxButton := GUI.CreateButton (210, maxy - 230, 170,
"Change Min/Max of Scroll Bar", SetMinMaxPressed)
resizeButton := GUI.CreateButton (20, maxy - 260, 170,
"Make Scroll Bar Small",
ResizePressed)
reverseButton := GUI.CreateButton (210, maxy - 260, 170,
"Reverse Scroll Bars Ends", ReversePressed)
quitButton := GUI.CreateButton (125, maxy - 290, 150, "Quit", QuitPressed)

% Process events, exit loop when GUI.QUIT called
loop
exit when GUI.ProcessEvent
end loop

% Do the clean up. Dispose of all but the main buttons.
GUI.Dispose (enableDisableButton)
GUI.Dispose (showHideButton)
GUI.Dispose (moveButton)
GUI.Dispose (refreshButton)
GUI.Dispose (setPositionButton)
GUI.Dispose (setMinMaxButton)
GUI.Dispose (resizeButton)
GUI.Dispose (reverseButton)
GUI.Dispose (quitButton)

% Create a label to indicate we're finished
var quitMessage := GUI.CreateLabelFull (0, 0, "Execution Terminated",
maxx, maxy - 135, GUI.CENTER + GUI.MIDDLE, 0)

i am not sure how to do that color thing. you may just need to lable the color as 1.green
2. yellow
on the window.

Archived topic from Iceteks, old topic ID:1859, old post ID:15335
The wisdom of sight comes from the father of lights
KukuriChan
Posts: 13
Joined: Tue Dec 30, 2003 1:41 pm

Turing Help! ^^

Post by KukuriChan »

Thanks Syb. You are the Turing Master here. ^^ Anyways, just in case you're wondering, I'm doing a paint program as a project for school. So if I ask a lot of questions, please don't get annoyed. ^^;; There's some stuff I want to do that I'm not sure how to do.

Anyways, I have another question! Is it possible to display all the fonts in a textbox? I want to do that but I'm not really sure how to do it.

I got this part done. I just need the part where you put them all in a textbox.

% displays all the possible fonts

% var fontName : string
% Font.StartName
% loop
% fontName := Font.GetName
% exit when fontName = ""
% put fontName
% end loop

Archived topic from Iceteks, old topic ID:1859, old post ID:15389
syb
Posts: 222
Joined: Wed Jun 18, 2003 10:12 pm

Turing Help! ^^

Post by syb »

I have to think about this one. You want them to display on the window. Not the font name but as a letter in that font?

Archived topic from Iceteks, old topic ID:1859, old post ID:15403
The wisdom of sight comes from the father of lights
KukuriChan
Posts: 13
Joined: Tue Dec 30, 2003 1:41 pm

Turing Help! ^^

Post by KukuriChan »

The actual font name. Kind of like in paint programs where there's a drop down menu type thing. ^^ I want it to be displayed in the active window. The user can select what type of font they want to use and then create a text field in the canvas.

Archived topic from Iceteks, old topic ID:1859, old post ID:15405
syb
Posts: 222
Joined: Wed Jun 18, 2003 10:12 pm

Turing Help! ^^

Post by syb »

Now you just stumbed me. lol :P

Archived topic from Iceteks, old topic ID:1859, old post ID:15410
The wisdom of sight comes from the father of lights
KukuriChan
Posts: 13
Joined: Tue Dec 30, 2003 1:41 pm

Turing Help! ^^

Post by KukuriChan »

That's ok. I just used a text box to display all the available font. ^^ Here's the code.

var fontName : string
var boxID : int := GUI.CreateTextBox (20, 390, 150, 65)

Font.StartName
loop
fontName := Font.GetName
exit when fontName = ""
GUI.AddLine (boxID, fontName)
end loop


loop
exit when GUI.ProcessEvent
end loop

Now I need someway of asking the user in a new window, what font they want by typing it in and then using it to display a text fied in the original window.

Archived topic from Iceteks, old topic ID:1859, old post ID:15413
syb
Posts: 222
Joined: Wed Jun 18, 2003 10:12 pm

Turing Help! ^^

Post by syb »

thast doesn't run man.

Archived topic from Iceteks, old topic ID:1859, old post ID:15416
The wisdom of sight comes from the father of lights
KukuriChan
Posts: 13
Joined: Tue Dec 30, 2003 1:41 pm

Turing Help! ^^

Post by KukuriChan »

oops. Forgot import GUI at the top. hehe... ^^

Archived topic from Iceteks, old topic ID:1859, old post ID:15425
Locked