Qt4: Add menucolors
The Qt4 windowport already supported my 3.4.3 menucolors patch, so adding that was simple.
This commit is contained in:
@@ -1723,7 +1723,7 @@ E const char *FDECL(clr2colorname, (int));
|
|||||||
E int FDECL(match_str2clr, (char *));
|
E int FDECL(match_str2clr, (char *));
|
||||||
E int FDECL(match_str2attr, (const char *, BOOLEAN_P));
|
E int FDECL(match_str2attr, (const char *, BOOLEAN_P));
|
||||||
E boolean FDECL(add_menu_coloring, (char *));
|
E boolean FDECL(add_menu_coloring, (char *));
|
||||||
E boolean FDECL(get_menu_coloring, (char *, int *, int *));
|
E boolean FDECL(get_menu_coloring, (const char *, int *, int *));
|
||||||
E void NDECL(free_menu_coloring);
|
E void NDECL(free_menu_coloring);
|
||||||
E boolean FDECL(msgtype_parse_add, (char *));
|
E boolean FDECL(msgtype_parse_add, (char *));
|
||||||
E int FDECL(msgtype_type, (const char *, BOOLEAN_P));
|
E int FDECL(msgtype_type, (const char *, BOOLEAN_P));
|
||||||
|
|||||||
@@ -1747,7 +1747,7 @@ char *tmpstr;
|
|||||||
|
|
||||||
boolean
|
boolean
|
||||||
get_menu_coloring(str, color, attr)
|
get_menu_coloring(str, color, attr)
|
||||||
char *str;
|
const char *str;
|
||||||
int *color, *attr;
|
int *color, *attr;
|
||||||
{
|
{
|
||||||
struct menucoloring *tmpmc;
|
struct menucoloring *tmpmc;
|
||||||
|
|||||||
@@ -32,9 +32,7 @@ extern "C" {
|
|||||||
extern "C" int qt_compact_mode;
|
extern "C" int qt_compact_mode;
|
||||||
// end temporary
|
// end temporary
|
||||||
|
|
||||||
#ifdef MENU_COLOR
|
|
||||||
extern "C" struct menucoloring *menu_colorings;
|
extern "C" struct menucoloring *menu_colorings;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace nethack_qt4 {
|
namespace nethack_qt4 {
|
||||||
|
|
||||||
@@ -42,8 +40,6 @@ namespace nethack_qt4 {
|
|||||||
void centerOnMain( QWidget* w );
|
void centerOnMain( QWidget* w );
|
||||||
// end temporary
|
// end temporary
|
||||||
|
|
||||||
static boolean get_menu_coloring(char const *str, int *color, int *attr);
|
|
||||||
|
|
||||||
QSize NetHackQtTextListBox::sizeHint() const
|
QSize NetHackQtTextListBox::sizeHint() const
|
||||||
{
|
{
|
||||||
QScrollBar *hscroll = horizontalScrollBar();
|
QScrollBar *hscroll = horizontalScrollBar();
|
||||||
@@ -194,39 +190,17 @@ void NetHackQtMenuWindow::AddMenu(int glyph, const ANY_P* identifier,
|
|||||||
+ str.mid(bracket+2);
|
+ str.mid(bracket+2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef MENU_COLOR
|
|
||||||
int mcolor, mattr;
|
int mcolor, mattr;
|
||||||
if (attr == 0
|
if (attr == 0
|
||||||
&& get_menu_coloring(str.toLatin1().constData(), &mcolor, &mattr)) {
|
&& get_menu_coloring(str.toLatin1().constData(), &mcolor, &mattr)) {
|
||||||
itemlist[itemcount].attr = mattr;
|
itemlist[itemcount].attr = mattr;
|
||||||
itemlist[itemcount].color = mcolor;
|
itemlist[itemcount].color = mcolor;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
++itemcount;
|
++itemcount;
|
||||||
|
|
||||||
if (glyph!=NO_GLYPH) has_glyphs=true;
|
if (glyph!=NO_GLYPH) has_glyphs=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MENU_COLOR
|
|
||||||
static boolean
|
|
||||||
get_menu_coloring(char const *str, int *color, int *attr)
|
|
||||||
{
|
|
||||||
struct menucoloring *tmpmc;
|
|
||||||
if (iflags.use_menu_color)
|
|
||||||
for (tmpmc = menu_colorings; tmpmc; tmpmc = tmpmc->next)
|
|
||||||
# ifdef MENU_COLOR_REGEX
|
|
||||||
if (re_search(&tmpmc->match, str, strlen(str), 0, 9999, 0) >= 0) {
|
|
||||||
# else
|
|
||||||
if (pmatch(tmpmc->match, str)) {
|
|
||||||
# endif
|
|
||||||
*color = tmpmc->color;
|
|
||||||
*attr = tmpmc->attr;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#endif /* MENU_COLOR */
|
|
||||||
|
|
||||||
void NetHackQtMenuWindow::EndMenu(const QString& p)
|
void NetHackQtMenuWindow::EndMenu(const QString& p)
|
||||||
{
|
{
|
||||||
prompt.setText(p);
|
prompt.setText(p);
|
||||||
@@ -417,11 +391,9 @@ void NetHackQtMenuWindow::AddRow(int row, const MenuItem& mi)
|
|||||||
table->item(row, 4)->setFlags(Qt::ItemIsEnabled);
|
table->item(row, 4)->setFlags(Qt::ItemIsEnabled);
|
||||||
WidenColumn(4, fm.width(text));
|
WidenColumn(4, fm.width(text));
|
||||||
|
|
||||||
#ifdef MENU_COLOR
|
|
||||||
if (mi.color != -1) {
|
if (mi.color != -1) {
|
||||||
twi->setForeground(colors[mi.color]);
|
twi->setForeground(colors[mi.color]);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
QFont itemfont(table->font());
|
QFont itemfont(table->font());
|
||||||
switch (mi.attr) {
|
switch (mi.attr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user