Paul, each swatch is assigned a uid, and there is a common callback handler. I'm not trying to process coordinates; I have user data attached to each swatch as well, and as the cursor moves across them, the user data is sampled and that shows the user what color is 'rolled over'.
So, each swatch is created thusly:
ii = winio@('%`^gr[colour=#'//initial_color//',FULL_MOUSE_INPUT]%ud&',24,24,1000+k,track_mouse_autocad,k)
%ud&',24,24,1000+k,track_mouse_autocad,k)
[quote:584fb22ebb]I didn't see that I could supply an initial color any other way. If there is one, I'm open to change!
and the callback that populates other controls is:
integer function track_mouse_autocad()
USE MSWIN
INCLUDE 'CONFIG_AUTOCAD_COMMON.INS'
INTEGER:: I,J,K,RR,GG,BB
CHARACTER*20:: REASON
INTEGER:: USER_DATA,HANDLE
HANDLE = CLEARWIN_INFO@('CALL_BACK_WINDOW')
REASON = CLEARWIN_STRING@('CALLBACK_REASON')
SELECT CASE (REASON)
CASE ('MOUSE_MOVE')
USER_DATA = CLEARWIN_INFO@('USER_DATA')
USER_DATA = MOD(USER_DATA,1000)
IF(LAST_COLOR.NE.USER_DATA) THEN
! PICK UP THE INFO REGARDING THE COLOR
PRINT *,USER_DATA
call retrieve_color(USER_DATA, RR, GG, BB) ! to verify
AUTOCAD_COLOR(1) = RR ; AUTOCAD_COLOR(2) = GG ; AUTOCAD_COLOR(3) = BB
CALL WINDOW_UPDATE@(AUTOCAD_COLOR(1))
CALL WINDOW_UPDATE@(AUTOCAD_COLOR(2))
CALL WINDOW_UPDATE@(AUTOCAD_COLOR(3))
AUTOCAD_INDEX = USER_DATA
CALL WINDOW_UPDATE@(AUTOCAD_INDEX)
LAST_COLOR = USER_DATA
ENDIF
CASE ('MOUSE_LEFT_CLICK')
CALL SET_MOUSE_CURSOR_POSITION@(HANDLE,0,0)
I = SETFOCUS(FOCUS_CONTROL)
END SELECT
track_mouse_autocad = 1
return
end
One of the problems with this was I wanted the user to be able to see the color choices as they scanned the cursor over the swatch area. This causes a problem if the user moves the cursor over the swatches to select other controls, the selection changes. So, I have some additional work to do to make the user interface a bit more seamless (like taking the mouse_left_click and making that the selection criteria, not just scanning over the colors).
Ultimately, when the user chooses to change the color, I will use the UID to draw the new color over the old one, thus showing the change. I've already tried that out in some test code, works great! But for that, I have to have the UID to select the color to be updated.
k=select_graphics_object@(clearwin_info@('USER_DATA')+1000)
call draw_filled_rectangle@(0,0,24,24,color(i))
call perform_graphics_update@()
Being able to use the system dialog for color is great. I was also wondering if (somehow) the initial RGB color setting can be applied to that dialog so the user is at the appropriate starting point for doing a color change. That would increase its usability immensely, especially for my application!