Message
| After mucking around with miniwindows for a while I thought that some of the function calls were a little obscure. For example:
WindowCreate (win,
0, 0, 200, 200, // left, top, width, height
12, 4,
ColourNameToRGB("white")) // background colour
What do the 12 and 4 mean? It would be better if they were more descriptive, eg.
WindowCreate (win, 0, 0, 200, 200, // left, top, width, height
miniwin.pos_center_all,
miniwin.create_transparent,
ColourNameToRGB("white")) // background colour
The same could be said for a lot of the other functions that just take "magic numbers" as arguments.
To help make miniwindow writing more self-documenting, version 4.52 has a new table built into the script space called "miniwin". This defines the following constants (in numeric order, grouped alphabetically):
miniwin = {
-- WindowBlendImage modes (argument 7)
blend_normal = 1,
blend_average = 2,
blend_interpolate = 3,
blend_dissolve = 4,
blend_darken = 5,
blend_multiply = 6,
blend_colour_burn = 7,
blend_linear_burn = 8,
blend_inverse_colour_burn = 9,
blend_subtract = 10,
blend_lighten = 11,
blend_screen = 12,
blend_colour_dodge = 13,
blend_linear_dodge = 14,
blend_inverse_colour_dodge = 15,
blend_add = 16,
blend_overlay = 17,
blend_soft_light = 18,
blend_hard_light = 19,
blend_vivid_light = 20,
blend_linear_light = 21,
blend_pin_light = 22,
blend_hard_mix = 23,
blend_difference = 24,
blend_exclusion = 25,
blend_reflect = 26,
blend_glow = 27,
blend_freeze = 28,
blend_heat = 29,
blend_negation = 30,
blend_phoenix = 31,
blend_stamp = 32,
blend_xor = 33,
blend_and = 34,
blend_or = 35,
blend_red = 36,
blend_green = 37,
blend_blue = 38,
blend_yellow = 39,
blend_cyan = 40,
blend_magenta = 41,
blend_green_limited_by_red = 42,
blend_green_limited_by_blue = 43,
blend_green_limited_by_average_of_red_and_blue = 44,
blend_blue_limited_by_red = 45,
blend_blue_limited_by_green = 46,
blend_blue_limited_by_average_of_red_and_green = 47,
blend_red_limited_by_green = 48,
blend_red_limited_by_blue = 49,
blend_red_limited_by_average_of_green_and_blue = 50,
blend_red_only = 51,
blend_green_only = 52,
blend_blue_only = 53,
blend_discard_red = 54,
blend_discard_green = 55,
blend_discard_blue = 56,
blend_all_red = 57,
blend_all_green = 58,
blend_all_blue = 59,
blend_hue_mode = 60,
blend_saturation_mode = 61,
blend_colour_mode = 62,
blend_luminance_mode = 63,
blend_hsl = 64,
-- brush styles for drawing shapes (WindowCircleOp, WindowPolygon)
brush_solid = 0,
brush_null = 1,
brush_hatch_horizontal = 2,
brush_hatch_vertical = 3,
brush_hatch_forwards_diagonal = 4,
brush_hatch_backwards_diagonal = 5,
brush_hatch_cross = 6,
brush_hatch_cross_diagonal = 7,
brush_fine_pattern = 8,
brush_medium_pattern = 9,
brush_coarse_pattern = 10,
brush_waves_horizontal = 11,
brush_waves_vertical = 12,
-- WindowCircleOp action parameter (argument 2)
circle_ellipse = 1,
circle_rectangle = 2,
circle_round_rectangle = 3,
circle_chord = 4,
circle_pie = 5,
-- flags for WindowCreate (argument 7)
create_underneath = 1,
create_absolute_location = 2,
create_transparent = 4,
create_ignore_mouse = 8,
create_keep_hotspots = 16,
-- WindowAddHotspot and SetCursor cursor types
cursor_none = -1,
cursor_arrow = 0,
cursor_hand = 1,
cursor_ibeam = 2,
cursor_plus = 3,
cursor_wait = 4,
cursor_up = 5,
cursor_nw_se_arrow = 6,
cursor_ne_sw_arrow = 7,
cursor_ew_arrow = 8,
cursor_ns_arrow = 9,
cursor_both_arrow = 10,
cursor_x = 11,
cursor_help = 12,
-- drag handler callback flags
drag_got_shift = 1,
drag_got_control = 2,
drag_got_alt = 4,
-- WindowFilter operations (argument 6)
filter_noise = 1,
filter_monochrome_noise = 2,
filter_blur = 3,
filter_sharpen = 4,
filter_find_edges = 5,
filter_emboss = 6,
filter_brightness = 7,
filter_contrast = 8,
filter_gamma = 9,
filter_red_brightness = 10,
filter_red_contrast = 11,
filter_red_gamma = 12,
filter_green_brightness = 13,
filter_green_contrast = 14,
filter_green_gamma = 15,
filter_blue_brightness = 16,
filter_blue_contrast = 17,
filter_blue_gamma = 18,
filter_grayscale = 19,
filter_normal_grayscale = 20,
filter_brightness_multiply = 21,
filter_red_brightness_multiply = 22,
filter_green_brightness_multiply = 23,
filter_blue_brightness_multiply = 24,
filter_lesser_blur = 25,
filter_minor_blur = 26,
filter_average = 27,
-- WindowFont charset
font_charset_ansi = 0,
font_charset_default = 1,
font_charset_symbol = 2,
-- WindowFont PitchAndFamily (these can be or'ed or added together)
-- font family
font_family_any = 0,
font_family_roman = 16,
font_family_swiss = 32,
font_family_modern = 48,
font_family_script = 64,
font_family_decorative = 80,
-- font pitch
font_pitch_default = 0,
font_pitch_fixed = 1,
font_pitch_variable = 2,
font_truetype = 4,
font_pitch_monospaced = 8,
-- WindowGradient mode parameter (argument 8)
gradient_horizontal = 1,
gradient_vertical = 2,
gradient_texture = 3,
-- AddHotspot flags (argument 14)
hotspot_report_all_mouseovers = 1,
-- hotspot callback flags
hotspot_got_shift = 1,
hotspot_got_control = 2,
hotspot_got_alt = 4,
hotspot_got_lh_mouse = 16,
hotspot_got_rh_mouse = 32,
hotspot_got_dbl_click = 64,
hotspot_got_not_first = 128,
-- WindowImageOp actions (argument 2)
image_fill_ellipse = 1,
image_fill_rectangle = 2,
image_fill_round_fill_rectangle = 3,
-- WindowDrawImage mode (argument 7)
image_copy = 1,
image_stretch = 2,
image_transparent_copy = 3,
-- WindowMergeImageAlpha Mode (argument 8)
merge_straight = 0,
merge_transparent = 1,
-- pen styles for drawing shapes (WindowCircleOp, WindowLine, WindowArc, WindowBezier,
-- WindowPolygon, WindowImageOp)
pen_solid = 0,
pen_dash = 1,
pen_dot = 2,
pen_dash_dot = 3,
pen_dash_dot_dot = 4,
pen_null = 5,
pen_inside_frame = 6,
-- how lines join (eg. in polygons) (add this to the style)
pen_join_round = 0,
pen_join_bevel = 4096,
pen_join_miter = 8192,
-- how lines end (add this to the style)
pen_endcap_round = 0,
pen_endcap_square = 256,
pen_endcap_flat = 512,
-- positions for WindowCreate, SetForegroundImage, SetBackgroundImage, WindowPosition
pos_stretch_to_view = 0,
pos_stretch_to_view_with_aspect = 1,
pos_stretch_to_owner = 2,
pos_stretch_to_owner_with_aspect = 3,
pos_top_left = 4,
pos_top_center = 5,
pos_top_right = 6,
pos_center_right = 7,
pos_bottom_right = 8,
pos_bottom_center = 9,
pos_bottom_left = 10,
pos_center_left = 11,
pos_center_all = 12,
pos_tile = 13,
-- WindowRectOp action parameter (argument 2)
rect_frame = 1,
rect_fill = 2,
rect_invert = 3,
rect_3d_rect = 4,
rect_draw_edge = 5,
rect_flood_fill_border = 6,
rect_flood_fill_surface = 7,
-- WindowRectOp colour1 parameter (argument 7) for action 5 (rect_draw_edge)
rect_edge_raised = 5,
rect_edge_etched = 6,
rect_edge_bump = 9,
rect_edge_sunken = 10,
-- WindowRectOp colour2 parameter (argument 8) for action 5 (rect_draw_edge)
rect_edge_at_top_left = 3,
rect_edge_at_top_right = 6,
rect_edge_at_bottom_left = 9,
rect_edge_at_bottom_right = 12,
rect_edge_at_all = 15,
rect_diagonal_end_top_left = 19,
rect_diagonal_end_top_right = 22,
rect_diagonal_end_bottom_left = 25,
rect_diagonal_end_bottom_right = 28,
-- WindowRectOp other colour2 flags (or in) (argument 8) for action 5 (rect_draw_edge)
rect_option_fill_middle = 2048,
rect_option_softer_buttons = 4096,
rect_option_flat_borders = 16384,
rect_option_monochrom_borders = 32768,
-- mouse wheel handler callback flags
wheel_got_shift = 1,
wheel_got_control = 2,
wheel_got_alt = 4,
wheel_scroll_back = 256,
}
You can use these constants in advance of version 4.52 by simply including the above table in your code.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|