Welcome to Anything Forums! We are a general discussion forum that believes in freedom of expression and aim to provide a low moderation (within reasonable means) environment to discuss any topic. If you want to join, simply click HERE to be taken to our account management system where you can make an account. If you had an account at iceteks.com, anythingforums.com, uovalor.com or uogateway.com in the past it has been transfered over and you can simply do a password reset.
Computer builds, hardware and software discussion or troubleshooting, including peripherals. Essentially a general place to talk about desktop computers.
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. 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
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)
% 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
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
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
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