home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
windows
/
kpwdemo.zip
/
COLORDEM.SRC
< prev
next >
Wrap
Text File
|
1990-06-28
|
4KB
|
128 lines
(* ========================= COLOR.KB =================================
This KB shows the colors associated with different RBG values. Standard color
names can be used to name colors for text and window backgrounds. These are
shown in PALETTE.KB. If you want to use window background colors other than the
ones defined you can use the RBG values shown in this KB.
=====================================================================*)
collect_not_ok ().
from_edit is no. (* When the value of the color is changed using the scroll bars
the number is written into the edit line. Before the value is
written into the edit line, this topic is checked to make sure that
the value was not typed into the editor in the first place. *)
w2 is window (,21,2,38,20,,[popup,thickframe,titlebar,showchildren]).
[color,green,red,blue] is 0.
(* The #x is used to position the text in the correct column. This is done for compatibility
between Windows 2.0 which uses fixed fonts and 3.0 which uses proportional fonts.
Whenever possible it is faster to format text directly within the TEXT command instead
of using # display commands. *)
text ('
#x24RBG VALUE:
#x9GREEN
#x9RED
#x9BLUE').
g is horz_scroll_bar (green,4,7,15,1.5,0,85).
r is horz_scroll_bar (red,4,11,15,1.5,0,85).
b is horz_scroll_bar (blue,4,15,15,1.5,0,85).
ed1 is edit_line (0,define,24,4,12,[char_event]).
button (Copy,copy,25,9).
button (Quit,quit,25,14).
w1 is window (,4,2,15,3,,[child,visible,thinframe,siblings],?w2,,?color).
(* Complicated window are drawn much quicker if they are created without a visible style
and then displayed using SHOW_WINDOW after all screen objects are created. *)
show_window (?w2).
set_focus (?ed1).
topic define (item).
if ?item is 13
then color_value is get_text (?ed1) and
blue is ?color_value DIV 65536 and
remain is ?color_value - (?blue * 65536) and
green is ?remain DIV 256 and
red is ?remain - (?green * 256) and
from_edit is yes and
displayWindow () and
set_scroll_bar (?b,?blue/3) and
set_scroll_bar (?g,?green/3) and
set_scroll_bar (?r,?red/3) and
from_edit is no and
define is true.
end.
topic copy.
text_to_clipboard (?color).
:temp is window ((* eventTopic*),21,2,50,20.43,,[popup,thickFrame,titleBar,showChildren,siblings]).
make_modal (?temp).
text ('
The RGB value for the color you selected is:
#s',?color,'#l
This number has been copied to the clipboard.
It can be used to change the color of window
backgrounds or text. For example:
window (,2,4,30,50,hello, , , , #s',?color,'#l).
Creates a window with the background of the
selected color. Standard color names can also
be used. To see examples of the standard
colors, run the program PALETTE.
').
button (Continue,done,21,16.5,).
show_window ().
set_focus (?ed1).
topic done.
close_window (?temp).
end.
end.
topic quit.
new_kb ('demo.ckb').
end.
topic green (value).
green is ?value * 3.
if ?from_edit is no then displayWindow ().
end.
topic red (value).
red is ?value * 3.
if ?from_edit is no then displayWindow ().
end.
topic blue (value).
blue is ?value * 3.
if ?from_edit is no then displayWindow ().
collect ().
end.
topic displayWindow .
color is (65536 * ?blue) + (256 * ?green) + ?red.
temp is ?w1.
w1 is window (,4,2,15,3,,[child,thinframe,siblings],?w2,,?color).
show_window (?w1,4).
close_window (?temp).
if ?from_edit is no then set_text (?ed1,?color).
end.