mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-05 11:04:42 +03:00
* dialog.h: Replaced object-like macros with implicit references
to an identifier ``h'' with function-like macros. Adjusted all users. * dialog.c: Likewise. * find.c: Likewise. * tree.c: Likewise. * widget.c: Likewise. * widget.c (widget_selectcolor): New function that selects a color among DLG_{HOT_,}{FOCUS,NORMAL}C.
This commit is contained in:
parent
0c2b595997
commit
bc446f0cee
@ -1,3 +1,15 @@
|
|||||||
|
2005-07-07 Roland Illig <roland.illig@gmx.de>
|
||||||
|
|
||||||
|
* dialog.h: Replaced object-like macros with implicit references
|
||||||
|
to an identifier ``h'' with function-like macros. Adjusted all
|
||||||
|
users.
|
||||||
|
* dialog.c: Likewise.
|
||||||
|
* find.c: Likewise.
|
||||||
|
* tree.c: Likewise.
|
||||||
|
* widget.c: Likewise.
|
||||||
|
* widget.c (widget_selectcolor): New function that selects a
|
||||||
|
color among DLG_{HOT_,}{FOCUS,NORMAL}C.
|
||||||
|
|
||||||
2005-07-07 Roland Illig <roland.illig@gmx.de>
|
2005-07-07 Roland Illig <roland.illig@gmx.de>
|
||||||
|
|
||||||
* view.c (view_compute_areas): Fixed a bug noted by Pavel
|
* view.c (view_compute_areas): Fixed a bug noted by Pavel
|
||||||
|
@ -160,12 +160,12 @@ common_dialog_repaint (struct Dlg_head *h)
|
|||||||
|
|
||||||
space = (h->flags & DLG_COMPACT) ? 0 : 1;
|
space = (h->flags & DLG_COMPACT) ? 0 : 1;
|
||||||
|
|
||||||
attrset (NORMALC);
|
attrset (DLG_NORMALC (h));
|
||||||
dlg_erase (h);
|
dlg_erase (h);
|
||||||
draw_box (h, space, space, h->lines - 2 * space, h->cols - 2 * space);
|
draw_box (h, space, space, h->lines - 2 * space, h->cols - 2 * space);
|
||||||
|
|
||||||
if (h->title) {
|
if (h->title) {
|
||||||
attrset (HOT_NORMALC);
|
attrset (DLG_HOT_NORMALC (h));
|
||||||
dlg_move (h, space, (h->cols - strlen (h->title)) / 2);
|
dlg_move (h, space, (h->cols - strlen (h->title)) / 2);
|
||||||
addstr (h->title);
|
addstr (h->title);
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@
|
|||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
|
|
||||||
/* Color constants */
|
/* Color constants */
|
||||||
#define FOCUSC h->color[1]
|
#define DLG_NORMALC(h) ((h)->color[0])
|
||||||
#define NORMALC h->color[0]
|
#define DLG_FOCUSC(h) ((h)->color[1])
|
||||||
#define HOT_NORMALC h->color[2]
|
#define DLG_HOT_NORMALC(h) ((h)->color[2])
|
||||||
#define HOT_FOCUSC h->color[3]
|
#define DLG_HOT_FOCUSC(h) ((h)->color[3])
|
||||||
|
|
||||||
/* Common return values */
|
/* Common return values */
|
||||||
#define B_EXIT 0
|
#define B_EXIT 0
|
||||||
|
@ -719,7 +719,7 @@ do_search (struct Dlg_head *h)
|
|||||||
|
|
||||||
if (verbose){
|
if (verbose){
|
||||||
pos = (pos + 1) % 4;
|
pos = (pos + 1) % 4;
|
||||||
attrset (NORMALC);
|
attrset (DLG_NORMALC (h));
|
||||||
dlg_move (h, FIND2_Y-6, FIND2_X - 4);
|
dlg_move (h, FIND2_Y-6, FIND2_X - 4);
|
||||||
addch (rotating_dash [pos]);
|
addch (rotating_dash [pos]);
|
||||||
mc_refresh ();
|
mc_refresh ();
|
||||||
|
12
src/tree.c
12
src/tree.c
@ -54,7 +54,7 @@
|
|||||||
extern int command_prompt;
|
extern int command_prompt;
|
||||||
|
|
||||||
/* Use the color of the parent widget for the unselected entries */
|
/* Use the color of the parent widget for the unselected entries */
|
||||||
#define TREE_NORMALC NORMALC
|
#define TREE_NORMALC(h) (DLG_NORMALC (h))
|
||||||
|
|
||||||
/* Specifies the display mode: 1d or 2d */
|
/* Specifies the display mode: 1d or 2d */
|
||||||
static int tree_navigation_flag;
|
static int tree_navigation_flag;
|
||||||
@ -171,13 +171,13 @@ static void tree_show_mini_info (WTree *tree, int tree_lines, int tree_cols)
|
|||||||
|
|
||||||
if (tree->searching){
|
if (tree->searching){
|
||||||
/* Show search string */
|
/* Show search string */
|
||||||
attrset (TREE_NORMALC);
|
attrset (TREE_NORMALC (h));
|
||||||
attrset (FOCUSC);
|
attrset (DLG_FOCUSC (h));
|
||||||
addch (PATH_SEP);
|
addch (PATH_SEP);
|
||||||
|
|
||||||
addstr ((char *) name_trunc (tree->search_buffer, tree_cols-2));
|
addstr ((char *) name_trunc (tree->search_buffer, tree_cols-2));
|
||||||
addch (' ');
|
addch (' ');
|
||||||
attrset (FOCUSC);
|
attrset (DLG_FOCUSC (h));
|
||||||
} else {
|
} else {
|
||||||
/* Show full name of selected directory */
|
/* Show full name of selected directory */
|
||||||
addstr ((char *) name_trunc (tree->selected_ptr->name, tree_cols));
|
addstr ((char *) name_trunc (tree->selected_ptr->name, tree_cols));
|
||||||
@ -197,7 +197,7 @@ static void show_tree (WTree *tree)
|
|||||||
tree_lines = tlines (tree);
|
tree_lines = tlines (tree);
|
||||||
tree_cols = tree->widget.cols;
|
tree_cols = tree->widget.cols;
|
||||||
|
|
||||||
attrset (TREE_NORMALC);
|
attrset (TREE_NORMALC (h));
|
||||||
widget_move ((Widget*)tree, y, x);
|
widget_move ((Widget*)tree, y, x);
|
||||||
if (tree->is_panel){
|
if (tree->is_panel){
|
||||||
tree_cols -= 2;
|
tree_cols -= 2;
|
||||||
@ -306,7 +306,7 @@ static void show_tree (WTree *tree)
|
|||||||
addch (' ');
|
addch (' ');
|
||||||
|
|
||||||
/* Return to normal color */
|
/* Return to normal color */
|
||||||
attrset (TREE_NORMALC);
|
attrset (TREE_NORMALC (h));
|
||||||
|
|
||||||
/* Calculate the next value for current */
|
/* Calculate the next value for current */
|
||||||
current = current->next;
|
current = current->next;
|
||||||
|
48
src/widget.c
48
src/widget.c
@ -66,6 +66,20 @@ static int button_event (Gpm_Event *event, void *);
|
|||||||
|
|
||||||
int quote = 0;
|
int quote = 0;
|
||||||
|
|
||||||
|
static void
|
||||||
|
widget_selectcolor (Widget *w, gboolean focused, gboolean hotkey)
|
||||||
|
{
|
||||||
|
Dlg_head *h = w->parent;
|
||||||
|
|
||||||
|
attrset (hotkey
|
||||||
|
? (focused
|
||||||
|
? DLG_HOT_FOCUSC (h)
|
||||||
|
: DLG_HOT_NORMALC (h))
|
||||||
|
: (focused
|
||||||
|
? DLG_FOCUSC (h)
|
||||||
|
: DLG_NORMALC (h)));
|
||||||
|
}
|
||||||
|
|
||||||
static cb_ret_t
|
static cb_ret_t
|
||||||
button_callback (Widget *w, widget_msg_t msg, int parm)
|
button_callback (Widget *w, widget_msg_t msg, int parm)
|
||||||
{
|
{
|
||||||
@ -159,14 +173,14 @@ button_callback (Widget *w, widget_msg_t msg, int parm)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
attrset ((b->selected) ? FOCUSC : NORMALC);
|
widget_selectcolor (w, b->selected, FALSE);
|
||||||
widget_move (&b->widget, 0, 0);
|
widget_move (w, 0, 0);
|
||||||
|
|
||||||
addstr (buf);
|
addstr (buf);
|
||||||
|
|
||||||
if (b->hotpos >= 0) {
|
if (b->hotpos >= 0) {
|
||||||
attrset ((b->selected) ? HOT_FOCUSC : HOT_NORMALC);
|
widget_selectcolor (w, b->selected, TRUE);
|
||||||
widget_move (&b->widget, 0, b->hotpos + off);
|
widget_move (w, 0, b->hotpos + off);
|
||||||
addch ((unsigned char) b->text[b->hotpos]);
|
addch ((unsigned char) b->text[b->hotpos]);
|
||||||
}
|
}
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
@ -342,18 +356,16 @@ radio_callback (Widget *w, widget_msg_t msg, int parm)
|
|||||||
case WIDGET_DRAW:
|
case WIDGET_DRAW:
|
||||||
for (i = 0; i < r->count; i++) {
|
for (i = 0; i < r->count; i++) {
|
||||||
register const char *cp;
|
register const char *cp;
|
||||||
attrset ((i == r->pos
|
const gboolean focused = (i == r->pos && msg == WIDGET_FOCUS);
|
||||||
&& msg == WIDGET_FOCUS) ? FOCUSC : NORMALC);
|
widget_selectcolor (w, focused, FALSE);
|
||||||
widget_move (&r->widget, i, 0);
|
widget_move (&r->widget, i, 0);
|
||||||
|
|
||||||
printw ("(%c) ", (r->sel == i) ? '*' : ' ');
|
printw ("(%c) ", (r->sel == i) ? '*' : ' ');
|
||||||
for (cp = r->texts[i]; *cp; cp++) {
|
for (cp = r->texts[i]; *cp; cp++) {
|
||||||
if (*cp == '&') {
|
if (*cp == '&') {
|
||||||
attrset ((i == r->pos && msg == WIDGET_FOCUS)
|
widget_selectcolor (w, focused, TRUE);
|
||||||
? HOT_FOCUSC : HOT_NORMALC);
|
|
||||||
addch (*++cp);
|
addch (*++cp);
|
||||||
attrset ((i == r->pos
|
widget_selectcolor (w, focused, FALSE);
|
||||||
&& msg == WIDGET_FOCUS) ? FOCUSC : NORMALC);
|
|
||||||
} else
|
} else
|
||||||
addch (*cp);
|
addch (*cp);
|
||||||
}
|
}
|
||||||
@ -449,12 +461,12 @@ check_callback (Widget *w, widget_msg_t msg, int parm)
|
|||||||
case WIDGET_FOCUS:
|
case WIDGET_FOCUS:
|
||||||
case WIDGET_UNFOCUS:
|
case WIDGET_UNFOCUS:
|
||||||
case WIDGET_DRAW:
|
case WIDGET_DRAW:
|
||||||
attrset ((msg == WIDGET_FOCUS) ? FOCUSC : NORMALC);
|
widget_selectcolor (w, msg == WIDGET_FOCUS, FALSE);
|
||||||
widget_move (&c->widget, 0, 0);
|
widget_move (&c->widget, 0, 0);
|
||||||
printw ("[%c] %s", (c->state & C_BOOL) ? 'x' : ' ', c->text);
|
printw ("[%c] %s", (c->state & C_BOOL) ? 'x' : ' ', c->text);
|
||||||
|
|
||||||
if (c->hotpos >= 0) {
|
if (c->hotpos >= 0) {
|
||||||
attrset ((msg == WIDGET_FOCUS) ? HOT_FOCUSC : HOT_NORMALC);
|
widget_selectcolor (w, msg == WIDGET_FOCUS, TRUE);
|
||||||
widget_move (&c->widget, 0, +c->hotpos + 4);
|
widget_move (&c->widget, 0, +c->hotpos + 4);
|
||||||
addch ((unsigned char) c->text[c->hotpos]);
|
addch ((unsigned char) c->text[c->hotpos]);
|
||||||
}
|
}
|
||||||
@ -549,7 +561,7 @@ label_callback (Widget *w, widget_msg_t msg, int parm)
|
|||||||
if (l->transparent)
|
if (l->transparent)
|
||||||
attrset (DEFAULT_COLOR);
|
attrset (DEFAULT_COLOR);
|
||||||
else
|
else
|
||||||
attrset (NORMALC);
|
attrset (DLG_NORMALC (h));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int xlen;
|
int xlen;
|
||||||
|
|
||||||
@ -649,7 +661,7 @@ gauge_callback (Widget *w, widget_msg_t msg, int parm)
|
|||||||
|
|
||||||
if (msg == WIDGET_DRAW){
|
if (msg == WIDGET_DRAW){
|
||||||
widget_move (&g->widget, 0, 0);
|
widget_move (&g->widget, 0, 0);
|
||||||
attrset (NORMALC);
|
attrset (DLG_NORMALC (h));
|
||||||
if (!g->shown)
|
if (!g->shown)
|
||||||
printw ("%*s", gauge_len, "");
|
printw ("%*s", gauge_len, "");
|
||||||
else {
|
else {
|
||||||
@ -671,7 +683,7 @@ gauge_callback (Widget *w, widget_msg_t msg, int parm)
|
|||||||
addch ('[');
|
addch ('[');
|
||||||
attrset (GAUGE_COLOR);
|
attrset (GAUGE_COLOR);
|
||||||
printw ("%*s", (int) columns, "");
|
printw ("%*s", (int) columns, "");
|
||||||
attrset (NORMALC);
|
attrset (DLG_NORMALC (h));
|
||||||
printw ("%*s] %3d%%", (int)(gauge_len - 7 - columns), "", (int) percentage);
|
printw ("%*s] %3d%%", (int)(gauge_len - 7 - columns), "", (int) percentage);
|
||||||
}
|
}
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
@ -1738,14 +1750,14 @@ listbox_draw (WListbox *l, int focused)
|
|||||||
int i;
|
int i;
|
||||||
int sel_line;
|
int sel_line;
|
||||||
Dlg_head *h = l->widget.parent;
|
Dlg_head *h = l->widget.parent;
|
||||||
int normalc = NORMALC;
|
int normalc = DLG_NORMALC (h);
|
||||||
int selc;
|
int selc;
|
||||||
const char *text;
|
const char *text;
|
||||||
|
|
||||||
if (focused){
|
if (focused){
|
||||||
selc = FOCUSC;
|
selc = DLG_FOCUSC (h);
|
||||||
} else {
|
} else {
|
||||||
selc = HOT_FOCUSC;
|
selc = DLG_HOT_FOCUSC (h);
|
||||||
}
|
}
|
||||||
sel_line = -1;
|
sel_line = -1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user