Fixed dialog colors definition, setup and handling.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2009-08-11 10:51:00 +04:00
parent 791404055b
commit 5feea4aead
4 changed files with 15 additions and 11 deletions

View File

@ -169,8 +169,10 @@ create_dlg (int y1, int x1, int lines, int cols, const int *color_set,
y1 -= 2; y1 -= 2;
new_d = g_new0 (Dlg_head, 1); new_d = g_new0 (Dlg_head, 1);
if (color_set != NULL) if (color_set != NULL) {
memmove (new_d->color, color_set, sizeof (new_d->color)); new_d->color = g_new (int, DLG_COLOR_NUM);
memmove (new_d->color, color_set, sizeof (int) * DLG_COLOR_NUM);
}
new_d->help_ctx = help_ctx; new_d->help_ctx = help_ctx;
new_d->callback = callback ? callback : default_dlg_callback; new_d->callback = callback ? callback : default_dlg_callback;
new_d->x = x1; new_d->x = x1;
@ -802,6 +804,7 @@ destroy_dlg (Dlg_head *h)
g_free (h->current); g_free (h->current);
h->current = c; h->current = c;
} }
g_free (h->color);
g_free (h->title); g_free (h->title);
g_free (h); g_free (h);

View File

@ -26,12 +26,6 @@
#include "../src/tty/mouse.h" #include "../src/tty/mouse.h"
#include "util.h" /* Hook */ #include "util.h" /* Hook */
/* Color constants */
#define DLG_NORMALC(h) ((h)->color[0])
#define DLG_FOCUSC(h) ((h)->color[1])
#define DLG_HOT_NORMALC(h) ((h)->color[2])
#define DLG_HOT_FOCUSC(h) ((h)->color[3])
/* Common return values */ /* Common return values */
#define B_EXIT 0 #define B_EXIT 0
#define B_CANCEL 1 #define B_CANCEL 1
@ -89,11 +83,18 @@ typedef enum {
struct Dlg_head; struct Dlg_head;
typedef cb_ret_t (*dlg_cb_fn)(struct Dlg_head *h, dlg_msg_t msg, int parm); typedef cb_ret_t (*dlg_cb_fn)(struct Dlg_head *h, dlg_msg_t msg, int parm);
/* Dialog color constants */
#define DLG_COLOR_NUM 4
#define DLG_NORMALC(h) ((h)->color[0])
#define DLG_FOCUSC(h) ((h)->color[1])
#define DLG_HOT_NORMALC(h) ((h)->color[2])
#define DLG_HOT_FOCUSC(h) ((h)->color[3])
typedef struct Dlg_head { typedef struct Dlg_head {
/* Set by the user */ /* Set by the user */
int flags; /* User flags */ int flags; /* User flags */
const char *help_ctx; /* Name of the help entry */ const char *help_ctx; /* Name of the help entry */
const int color[4]; /* Color set. Unused in viewer and editor */ int *color; /* Color set. Unused in viewer and editor */
/*notconst*/ char *title; /* Title of the dialog */ /*notconst*/ char *title; /* Title of the dialog */
/* Set and received by the user */ /* Set and received by the user */

View File

@ -1671,7 +1671,7 @@ mc_maybe_editor_or_viewer (void)
static void static void
do_nc (void) do_nc (void)
{ {
const int midnight_colors[4] = const int midnight_colors[DLG_COLOR_NUM] =
{ {
NORMAL_COLOR, /* NORMALC */ NORMAL_COLOR, /* NORMALC */
REVERSE_COLOR, /* FOCUSC */ REVERSE_COLOR, /* FOCUSC */

View File

@ -50,7 +50,7 @@ Listbox *
create_listbox_window_delta (int delta_x, int delta_y, int cols, int lines, create_listbox_window_delta (int delta_x, int delta_y, int cols, int lines,
const char *title, const char *help) const char *title, const char *help)
{ {
const int listbox_colors[4] = const int listbox_colors[DLG_COLOR_NUM] =
{ {
MENU_ENTRY_COLOR, MENU_ENTRY_COLOR,
MENU_SELECTED_COLOR, MENU_SELECTED_COLOR,