Commit ec3972c5 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Open colour picker menus in the right place

Function dboxtcol() always opens colour pickers as transient submenus (in the flags to ColourPicker_OpenDialogue, plus listening for the menus deleted message) but chose to open the dialogue at the current mouse pointer, so obscuring part of the menu rather than opening it where the Style Guide wants it.
wimp.h:
  Add a struct definition of menuwarn messages.
txtedit.c/dbox.c/ctl.c:
  Use the menuwarn struct rather than indexing the words[].
dboxtcol.c:
  Provided the last wimp event was the menu warning, use the x/y coordinates from that instead of the mouse pointer.
  Remove some local defines in favour of central ones.
  Make sure we use 0x80000000/0x7F000000 like the PRM says for the other 2 corners of the dialogue, not 0,0.
Tested in a disc build of !Draw.

Version 5.86. Not tagged
parent 3c9cbec2
......@@ -14,10 +14,10 @@
Module_MajorVersion SETS "5.86"
Module_Version SETA 586
Module_MinorVersion SETS ""
Module_Date SETS "30 Jun 2015"
Module_ApplicationDate SETS "30-Jun-15"
Module_Date SETS "07 Feb 2016"
Module_ApplicationDate SETS "07-Feb-16"
Module_ComponentName SETS "RISC_OSLib"
Module_ComponentPath SETS "castle/RiscOS/Sources/Lib/RISC_OSLib"
Module_FullVersion SETS "5.86"
Module_HelpVersion SETS "5.86 (30 Jun 2015)"
Module_HelpVersion SETS "5.86 (07 Feb 2016)"
END
......@@ -6,18 +6,18 @@
*/
#define Module_MajorVersion_CMHG 5.86
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 30 Jun 2015
#define Module_Date_CMHG 07 Feb 2016
#define Module_MajorVersion "5.86"
#define Module_Version 586
#define Module_MinorVersion ""
#define Module_Date "30 Jun 2015"
#define Module_Date "07 Feb 2016"
#define Module_ApplicationDate "30-Jun-15"
#define Module_ApplicationDate "07-Feb-16"
#define Module_ComponentName "RISC_OSLib"
#define Module_ComponentPath "castle/RiscOS/Sources/Lib/RISC_OSLib"
#define Module_FullVersion "5.86"
#define Module_HelpVersion "5.86 (30 Jun 2015)"
#define Module_HelpVersion "5.86 (07 Feb 2016)"
#define Module_LibraryVersionInfo "5:86"
......@@ -771,8 +771,8 @@ static BOOL ctl__dbox_raw_event_handler(dbox d,wimp_eventstr *e,ctl__dbox *handl
ctls->current_icon=e->data.but.m.i;
ev.e=wimp_ESEND;
ev.data.msg.hdr.action=wimp_MMENUWARN;
ev.data.msg.data.words[1]=e->data.but.m.x;
ev.data.msg.data.words[2]=e->data.but.m.y;
ev.data.msg.data.menuwarn.x=e->data.but.m.x;
ev.data.msg.data.menuwarn.y=e->data.but.m.y;
wimpt_fake_event(&ev);
wimpt_poll(0,&ev);
ctl__dbox_event_handler(d,handle);
......@@ -983,8 +983,8 @@ static int ctl__submenu_request(void *handle,void *type,void *arg,int status)
(wimp_menustr *)(((ctl__menu *)arg)->menu_body);
wimp_create_submenu(
(wimp_menustr *)(((ctl__menu *)arg)->menu_body),
wimpt_last_event()->data.msg.data.words[1],
wimpt_last_event()->data.msg.data.words[2]);
wimpt_last_event()->data.msg.data.menuwarn.x,
wimpt_last_event()->data.msg.data.menuwarn.y);
}
else wimp_create_submenu(
menu_syshandle(((ctl__menu *)arg)->menu_body),
......
......@@ -773,8 +773,8 @@ open the dbox as a submenu rather than as a standalone window. */
dbox__submenu = d->w; /* there's only ever one. */
wimp_create_submenu(
(wimp_menustr*) d->w,
e->data.msg.data.words[1],
e->data.msg.data.words[2]);
e->data.msg.data.menuwarn.x,
e->data.msg.data.menuwarn.y);
} else {
o.w = d->w;
o.box = d->window.box;
......
......@@ -48,12 +48,6 @@
#undef NULL
#define NULL 0
#undef message_MENUS_DELETED
#define message_MENUS_DELETED 0x400C9
#undef ColourPicker_OpenDialogue
#define ColourPicker_OpenDialogue 0x47702
static BOOL Open, Chosen;
static dboxtcol_colour Colour;
static dboxtcol_colourhandler Proc;
......@@ -69,7 +63,7 @@ static BOOL Unknowns (wimp_eventstr *event_str, void *h)
{ case wimp_ESEND:
case wimp_ESENDWANTACK:
switch (event_str->data.msg.hdr.action)
{ case message_MENUS_DELETED:
{ case wimp_MMENUSDELETED:
Open = FALSE;
return TRUE;
break;
......@@ -108,7 +102,7 @@ BOOL dboxtcol (dboxtcol_colour *colour_out, BOOL allow_transparent,
char *name, dboxtcol_colourhandler proc, void *handle)
{ BOOL transparent;
wimp_mousestr mouse_str;
wimp_eventstr *e;
os_error *error = NULL;
colourpicker_dialogue dialogue;
colourpicker_d d;
......@@ -117,7 +111,7 @@ BOOL dboxtcol (dboxtcol_colour *colour_out, BOOL allow_transparent,
if (!Added_Messages)
{ static int Messages [] = {message_COLOUR_PICKER_COLOUR_CHOICE,
message_COLOUR_PICKER_COLOUR_CHANGED, message_MENUS_DELETED, 0};
message_COLOUR_PICKER_COLOUR_CHANGED, wimp_MMENUSDELETED, 0};
if ((error = _swix (Wimp_AddMessages, _IN (0), Messages)) != NULL)
goto finish;
......@@ -133,17 +127,26 @@ BOOL dboxtcol (dboxtcol_colour *colour_out, BOOL allow_transparent,
transparent = allow_transparent && Colour == dboxtcol_Transparent;
wimpt_noerr (wimp_get_point_info (&mouse_str));
e = wimpt_last_event();
if (e->e == wimp_ESEND && e->data.msg.hdr.action == wimp_MMENUWARN) {
/* this is a dbox that is actually part of the menu tree. */
dialogue.visible.x0 = e->data.msg.data.menuwarn.x;
dialogue.visible.y1 = e->data.msg.data.menuwarn.y;
} else {
wimp_mousestr mouse_str;
/* a floater: float it near the pointer. */
wimpt_noerr (wimp_get_point_info (&mouse_str));
dialogue.visible.x0 = mouse_str.x;
dialogue.visible.y1 = mouse_str.y;
}
dialogue.flags =
(allow_transparent? colourpicker_DIALOGUE_OFFERS_TRANSPARENT: 0) |
colourpicker_DIALOGUE_TYPE_CLICK << colourpicker_DIALOGUE_TYPE_SHIFT |
(transparent? colourpicker_DIALOGUE_TRANSPARENT: 0);
dialogue.title = name;
dialogue.visible.x0 = mouse_str.x;
dialogue.visible.y0 = 0;
dialogue.visible.x1 = 0;
dialogue.visible.y1 = mouse_str.y;
dialogue.visible.y0 = 0x80000000;
dialogue.visible.x1 = 0x7FFFFFFF;
dialogue.xscroll = 0;
dialogue.yscroll = 0;
dialogue.colour = Colour;
......
......@@ -2988,8 +2988,8 @@ case txtedit_MSel :
/* This is the top level 'Select' submenu warning. Kick off
an exchange to decide whether the clipboard has text or not. */
withinmsel = TRUE;
mselx = e->data.msg.data.words[1];
msely = e->data.msg.data.words[2];
mselx = e->data.msg.data.menuwarn.x;
msely = e->data.msg.data.menuwarn.y;
txtedit_pasteselection(s);
}
break;
......
......@@ -212,6 +212,9 @@ typedef struct { /* icon description structure */
wimp_icondata data; /* union of bits & bobs as above */
} wimp_icon;
typedef struct wimp_menustr *wimp_menuptr;
/* Only for the circular reference in menuitem/str. */
typedef struct { /* structure for creating icons. */
wimp_w w;
wimp_icon i;
......@@ -335,15 +338,7 @@ typedef enum {
wimp_MNOTIFY = 0x40040, /* net filer notify broadcast */
wimp_MMENUWARN = 0x400c0,
/* menu warning. Sent if wimp_MSUBLINKMSG set. Data sent is:
submenu field of relevant wimp_menuitem.
screen x-coord
screen y-coord
list of menu selection indices (0..n-1 for each menu)
terminating -1 word.
Typical response is to call wimp_create_submenu.
*/
wimp_MMENUWARN = 0x400c0, /* menu warning sent if wimp_MSUBLINKMSG set */
wimp_MMODECHANGE = 0x400c1,
wimp_MINITTASK = 0x400c2,
wimp_MCLOSETASK = 0x400c3,
......@@ -509,6 +504,14 @@ typedef struct {
char text[200]; /* the helpful string */
} wimp_msghelpreply;
typedef struct {
wimp_menuptr submenu;
int x;
int y;
int menu[1]; /* list of menu hit indices (0..n-1 for each menu) */
/* as for wimp_EMENU, terminated by -1 */
} wimp_msgmenuwarn;
typedef struct { /* structure used in all print messages */
int filler[5] ;
int type ; /* filetype */
......@@ -528,6 +531,7 @@ typedef struct { /* message block */
wimp_msgramtransmit ramtransmit;
wimp_msghelprequest helprequest;
wimp_msghelpreply helpreply;
wimp_msgmenuwarn menuwarn;
wimp_msgprint print;
wimp_msgsavedesk savedesk;
wimp_msgdevice device;
......@@ -579,9 +583,6 @@ typedef enum { /* menu item flag set */
/* use wimp_INOSELECT to shade the item as unselectable,
and the button type to mark it as writable. */
typedef struct wimp_menustr *wimp_menuptr;
/* Only for the circular reference in menuitem/str. */
typedef struct {
wimp_menuflags flags; /* menu entry flags */
wimp_menuptr submenu; /* wimp_menustr* pointer to sub menu,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment