chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Sapphire / sh / ncs
1 ;
2 ; colSelect.sh
3 ;
4 ; Definitions for the colour selector
5 ;
6 ; © 1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Sapphire library.
12 ;
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
16 ; any later version.
17 ;
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ; GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire.  If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;----- Overview -------------------------------------------------------------
28 ;
29 ; Functions provided:
30 ;
31 ; Macros provided:
32 ;
33 ; Controls provided:
34
35                 [       :LNOT::DEF:colSelect__dfn
36                 GBLL    colSelect__dfn
37
38 ;----- Definition of a colour -----------------------------------------------
39
40 ; --- A colour block ---
41 ;
42 ; The first word is the only bit which applications should really be
43 ; interested in: it's a colour in RGB format suitable for passing to
44 ; ColourTrans_SetColour or similar.
45 ;
46 ; The model id is used by the colour selector to ensure that the colour
47 ; is edited in the correct way.  The date area is specific to a particular
48 ; colour model, and its format is not described here.  However, the model-
49 ; specific data must not contain pointers to external data areas or other
50 ; references to session-specific information.  Applications are permitted
51 ; to save colour blocks to disk and expect them to work properly when read
52 ; back.
53
54                 ^       0
55 csColour_rgb    #       4                       ;A ColourTrans RGB colour
56 csColour_model  #       4                       ;A ColSelect model ID
57 csColour_data   #       24                      ;Model-specific data
58 csColour_size   #       0                       ;Size of a colour block
59
60 ;----- Colour model interface -----------------------------------------------
61
62 ; --- A colour model definition block ---
63
64                 ^       0
65 csModel_id      #       4                       ;Colour model ID number
66 csModel_size    #       4                       ;Size of workspace required
67 csModel_handler #       4                       ;Pointer to handler routine
68 csModel_name    #       0                       ;Null terminated name string
69
70 ; --- Colour selector event codes ---
71
72 csEvent_base    EQU     &C0000000
73
74                 ^       csEvent_base
75 csEvent_res     #       1                       ;Diagram changed resolution
76 csEvent_get     #       1                       ;Get colour; reset panel
77
78 ; --- Resolution codes ---
79
80                 ^       0
81 csRes_perfect   #       1
82 csRes_high      #       1
83 csRes_medium    #       1
84 csRes_low       #       1
85
86 ; --- Known colour models ---
87
88 csModelId_trans EQU     0                       ;The `transparent' colour
89 csModelId_rgb   EQU     1                       ;Standard red/green/blue
90 csModelId_cmyk  EQU     2                       ;Cyan/Magenta/Yellow/Black
91 csModelId_hsv   EQU     3                       ;Hue/Saturation/Value
92 csModelId_named EQU     4                       ;Named colours
93
94 ; --- Colour selector data layout ---
95
96                 ^       0,R10
97 csData_frame    #       4                       ;Dialogue handle of frame
98 csData_panel    #       4                       ;Dialogue handle of panel
99 csData_colour   #       csColour_size           ;Working copy of colour data
100 csData_res      #       4                       ;Diagram resolution
101 csData_flags    #       4                       ;Various useful flags
102 csData_userCol  #       4                       ;Pointer to user's colour
103 csData_model    #       0                       ;Model-specific data
104 csData_size     EQU     {VAR} - csData_frame
105
106 ; --- cs_addModel ---
107 ;
108 ; On entry:     R0 = pointer to model definition block
109 ;               R1 = pointer to model workspace
110 ;
111 ; On exit:      May return an error.
112 ;
113 ; Use:          Registers a colour model with the colour selector.
114 ;
115 ;               The colour model block contains a pointer to a handler
116 ;               routine, csModel_handler, which is called to create the
117 ;               model's panel.  It is called as follows:
118 ;
119 ;               R10 = pointer to colour selector data
120 ;               R12 = workspace value passed to cs_addModel in R1
121 ;
122 ;               The handler returns a dialogue box handle in R0.  Further
123 ;               requests are sent to the dialogue box as events
124
125                 IMPORT  cs_addModel