Merge pull request #497 from denizzzka/again_adding_WIDGET_STYLE_CONSOLE

Separates BACKEND_CONSOLE flag and console-style widgets flag, second attempt
This commit is contained in:
Vadim Lopatin 2017-10-24 19:56:07 +03:00 committed by GitHub
commit fcb5565f4c
14 changed files with 91 additions and 76 deletions

View File

@ -70,7 +70,7 @@
{ {
"name": "external", "name": "external",
"versions": ["USE_EXTERNAL"], "versions": ["USE_EXTERNAL"],
"excludedSourceFiles": ["3rdparty/*"] "excludedSourceFiles": ["3rdparty/fontconfig/*"]
}, },
{ {
"name": "minimal", "name": "minimal",

View File

@ -10,6 +10,8 @@ version(USE_CONSOLE) {
enum ENABLE_OPENGL = false; enum ENABLE_OPENGL = false;
enum ENABLE_FREETYPE = false; enum ENABLE_FREETYPE = false;
enum BACKEND_CONSOLE = true; enum BACKEND_CONSOLE = true;
/// Tweaking widgets to console style drawing
enum WIDGET_STYLE_CONSOLE = true;
enum BACKEND_GUI = false; enum BACKEND_GUI = false;
enum BACKEND_SDL = false; enum BACKEND_SDL = false;
enum BACKEND_X11 = false; enum BACKEND_X11 = false;
@ -17,9 +19,15 @@ version(USE_CONSOLE) {
enum BACKEND_WIN32 = false; enum BACKEND_WIN32 = false;
enum BACKEND_ANDROID = false; enum BACKEND_ANDROID = false;
} else { } else {
version(USE_EXTERNAL) {} version(USE_EXTERNAL) {
// Use this file to define any enums that is need for the external backend
mixin(import("external_cfg.d"));
}
else else
{
enum BACKEND_GUI = true; enum BACKEND_GUI = true;
enum WIDGET_STYLE_CONSOLE = false;
}
version (NO_FREETYPE) { version (NO_FREETYPE) {
enum ENABLE_FREETYPE = false; enum ENABLE_FREETYPE = false;

View File

@ -315,7 +315,7 @@ private __gshared int PRIVATE_SCREEN_DPI_OVERRIDE = 0;
/// call to disable automatic screen DPI detection, use provided one instead (pass 0 to disable override and use value detected by platform) /// call to disable automatic screen DPI detection, use provided one instead (pass 0 to disable override and use value detected by platform)
@property void overrideScreenDPI(int dpi = 96) { @property void overrideScreenDPI(int dpi = 96) {
static if (BACKEND_CONSOLE) { static if (WIDGET_STYLE_CONSOLE) {
} else { } else {
if ((dpi >= 72 && dpi <= 500) || dpi == 0) if ((dpi >= 72 && dpi <= 500) || dpi == 0)
PRIVATE_SCREEN_DPI_OVERRIDE = dpi; PRIVATE_SCREEN_DPI_OVERRIDE = dpi;
@ -324,7 +324,7 @@ private __gshared int PRIVATE_SCREEN_DPI_OVERRIDE = 0;
/// set screen DPI detected by platform /// set screen DPI detected by platform
@property void SCREEN_DPI(int dpi) { @property void SCREEN_DPI(int dpi) {
static if (BACKEND_CONSOLE) { static if (WIDGET_STYLE_CONSOLE) {
PRIVATE_SCREEN_DPI = dpi; PRIVATE_SCREEN_DPI = dpi;
} else { } else {
if (dpi >= 72 && dpi <= 500) { if (dpi >= 72 && dpi <= 500) {

View File

@ -503,7 +503,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
sz.y = fnt.height; sz.y = fnt.height;
return sz; return sz;
} }
if (BACKEND_CONSOLE) if (WIDGET_STYLE_CONSOLE)
return Point(0, 0); return Point(0, 0);
else { else {
DrawableRef icon = rowIcon(row); DrawableRef icon = rowIcon(row);
@ -526,7 +526,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
Align ha = Align.Left; Align ha = Align.Left;
//if (sz.y < rc.height) //if (sz.y < rc.height)
// applyAlign(rc, sz, ha, Align.VCenter); // applyAlign(rc, sz, ha, Align.VCenter);
int offset = BACKEND_CONSOLE ? 0 : 1; int offset = WIDGET_STYLE_CONSOLE ? 0 : 1;
uint cl = _fileList.textColor; uint cl = _fileList.textColor;
if (_entries[row].isDir) if (_entries[row].isDir)
cl = style.customColor("file_dialog_dir_name_color", cl); cl = style.customColor("file_dialog_dir_name_color", cl);
@ -550,7 +550,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
WidgetListAdapter adapter = new WidgetListAdapter(); WidgetListAdapter adapter = new WidgetListAdapter();
foreach(ref RootEntry root; _roots) { foreach(ref RootEntry root; _roots) {
ImageTextButton btn = new ImageTextButton(null, root.icon, root.label); ImageTextButton btn = new ImageTextButton(null, root.icon, root.label);
static if (BACKEND_CONSOLE) btn.margins = Rect(1, 1, 0, 0); static if (WIDGET_STYLE_CONSOLE) btn.margins = Rect(1, 1, 0, 0);
btn.orientation = Orientation.Vertical; btn.orientation = Orientation.Vertical;
btn.styleId = STYLE_TRANSPARENT_BUTTON_BACKGROUND; btn.styleId = STYLE_TRANSPARENT_BUTTON_BACKGROUND;
btn.focusable = false; btn.focusable = false;
@ -715,7 +715,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
override void initialize() { override void initialize() {
_roots = getRootPaths() ~ getBookmarkPaths(); _roots = getRootPaths() ~ getBookmarkPaths();
layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).minWidth(BACKEND_CONSOLE ? 50 : 600); layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).minWidth(WIDGET_STYLE_CONSOLE ? 50 : 600);
//minHeight = 400; //minHeight = 400;
LinearLayout content = new HorizontalLayout("dlgcontent"); LinearLayout content = new HorizontalLayout("dlgcontent");
@ -725,10 +725,10 @@ class FileDialog : Dialog, CustomGridCellAdapter {
//leftPanel = new VerticalLayout("places"); //leftPanel = new VerticalLayout("places");
//leftPanel.addChild(createRootsList()); //leftPanel.addChild(createRootsList());
//leftPanel.layoutHeight(FILL_PARENT).minWidth(BACKEND_CONSOLE ? 7 : 40); //leftPanel.layoutHeight(FILL_PARENT).minWidth(WIDGET_STYLE_CONSOLE ? 7 : 40);
leftPanel = createRootsList(); leftPanel = createRootsList();
leftPanel.minWidth(BACKEND_CONSOLE ? 7 : 40.pointsToPixels); leftPanel.minWidth(WIDGET_STYLE_CONSOLE ? 7 : 40.pointsToPixels);
rightPanel = new VerticalLayout("main"); rightPanel = new VerticalLayout("main");
rightPanel.layoutHeight(FILL_PARENT).layoutWidth(FILL_PARENT); rightPanel.layoutHeight(FILL_PARENT).layoutWidth(FILL_PARENT);
@ -1161,7 +1161,7 @@ class FileNameEditLine : HorizontalLayout {
super(ID); super(ID);
_caption = UIString.fromId("TITLE_OPEN_FILE"c).value; _caption = UIString.fromId("TITLE_OPEN_FILE"c).value;
_edFileName = new EditLine("FileNameEditLine_edFileName"); _edFileName = new EditLine("FileNameEditLine_edFileName");
_edFileName.minWidth(BACKEND_CONSOLE ? 16 : 200); _edFileName.minWidth(WIDGET_STYLE_CONSOLE ? 16 : 200);
_edFileName.layoutWidth = FILL_PARENT; _edFileName.layoutWidth = FILL_PARENT;
_btn = new Button("FileNameEditLine_btnFile", "..."d); _btn = new Button("FileNameEditLine_btnFile", "..."d);
_btn.styleId = STYLE_BUTTON_NOMARGINS; _btn.styleId = STYLE_BUTTON_NOMARGINS;

View File

@ -139,7 +139,7 @@ class DummyIconProvider : IconProviderBase
} }
} }
static if (!BACKEND_CONSOLE) { static if (!WIDGET_STYLE_CONSOLE) {
version(Windows) version(Windows)
{ {
import core.sys.windows.windows; import core.sys.windows.windows;
@ -484,28 +484,30 @@ static if (!BACKEND_CONSOLE) {
DrawBufRef getIconFromTheme(string name, string context = null) DrawBufRef getIconFromTheme(string name, string context = null)
{ {
auto found = name in _cache; static if (!WIDGET_STYLE_CONSOLE) {
if (found) { auto found = name in _cache;
return *found; if (found) {
} return *found;
string iconPath; }
try { string iconPath;
if (context.length) { try {
iconPath = findClosestIcon!(subdir => subdir.context == context)(name, 32, _iconThemes, _baseIconDirs); if (context.length) {
} else { iconPath = findClosestIcon!(subdir => subdir.context == context)(name, 32, _iconThemes, _baseIconDirs);
iconPath = findClosestIcon(name, 32, _iconThemes, _baseIconDirs); } else {
iconPath = findClosestIcon(name, 32, _iconThemes, _baseIconDirs);
}
} catch(Exception e) {
Log.e("Error while searching for icon", name);
Log.e(e);
} }
} catch(Exception e) {
Log.e("Error while searching for icon", name);
Log.e(e);
}
if (iconPath.length) { if (iconPath.length) {
auto image = DrawBufRef(loadImage(iconPath)); auto image = DrawBufRef(loadImage(iconPath));
_cache[name] = image; _cache[name] = image;
return image; return image;
} else { } else {
_cache[name] = DrawBufRef(null); _cache[name] = DrawBufRef(null);
}
} }
return DrawBufRef(null); return DrawBufRef(null);
} }

View File

@ -216,7 +216,7 @@ EmbeddedResource[] embedResources(string[] resourceNames)() {
/// embed all resources from list /// embed all resources from list
EmbeddedResource[] embedResourcesFromList(string resourceList)() { EmbeddedResource[] embedResourcesFromList(string resourceList)() {
static if (BACKEND_CONSOLE) { static if (WIDGET_STYLE_CONSOLE) {
return embedResources!(splitLines(import("console_" ~ resourceList)))(); return embedResources!(splitLines(import("console_" ~ resourceList)))();
} else { } else {
return embedResources!(splitLines(import(resourceList)))(); return embedResources!(splitLines(import(resourceList)))();
@ -523,7 +523,7 @@ static uint decodeAngle(string s) {
return ((angle % 360) + 360) % 360; return ((angle % 360) + 360) % 360;
} }
static if (BACKEND_CONSOLE) { static if (WIDGET_STYLE_CONSOLE) {
/** /**
Sample format: Sample format:
{ {
@ -610,7 +610,7 @@ static Drawable createColorDrawable(string s) {
return new EmptyDrawable(); // invalid format - just return empty drawable return new EmptyDrawable(); // invalid format - just return empty drawable
} }
static if (BACKEND_CONSOLE) { static if (WIDGET_STYLE_CONSOLE) {
/** /**
Text image drawable. Text image drawable.
Resource file extension: .tim Resource file extension: .tim
@ -630,8 +630,13 @@ static if (BACKEND_CONSOLE) {
{'' ' ' '' bc 0x000080 tc 0xFF0000 ninepatch 1 1 1 1} {'' ' ' '' bc 0x000080 tc 0xFF0000 ninepatch 1 1 1 1}
*/ */
abstract class ConsoleDrawBuf : DrawBuf
{
abstract void drawChar(int x, int y, dchar ch, uint color, uint bgcolor);
}
class TextDrawable : Drawable { class TextDrawable : Drawable {
import dlangui.platforms.console.consoleapp : ConsoleDrawBuf;
private int _width; private int _width;
private int _height; private int _height;
private dchar[] _text; private dchar[] _text;
@ -1541,7 +1546,7 @@ class DrawableCache {
foreach(string path; _resourcePaths) { foreach(string path; _resourcePaths) {
string fn; string fn;
fn = checkFileName(path, id, ".xml"); fn = checkFileName(path, id, ".xml");
if (fn is null && BACKEND_CONSOLE) if (fn is null && WIDGET_STYLE_CONSOLE)
fn = checkFileName(path, id, ".tim"); fn = checkFileName(path, id, ".tim");
if (fn is null) if (fn is null)
fn = checkFileName(path, id, ".png"); fn = checkFileName(path, id, ".png");
@ -1601,7 +1606,7 @@ private Drawable makeDrawableFromId(in string id, in bool tiled, ColorTransform
return d; return d;
} }
} else if (id.endsWith(".tim") || id.endsWith(".TIM")) { } else if (id.endsWith(".tim") || id.endsWith(".TIM")) {
static if (BACKEND_CONSOLE) { static if (WIDGET_STYLE_CONSOLE) {
try { try {
// .tim (text image) drawables support // .tim (text image) drawables support
string s = cast(string)loadResourceBytes(id); string s = cast(string)loadResourceBytes(id);
@ -1620,7 +1625,7 @@ private Drawable makeDrawableFromId(in string id, in bool tiled, ColorTransform
return createColorDrawable(id); return createColorDrawable(id);
} else if (id.startsWith("{")) { } else if (id.startsWith("{")) {
// json in {} with text drawable description // json in {} with text drawable description
static if (BACKEND_CONSOLE) { static if (WIDGET_STYLE_CONSOLE) {
return createTextDrawable(id); return createTextDrawable(id);
} }
} else { } else {

View File

@ -1,4 +1,4 @@
module dlangui.platforms.console.consoleapp; module dlangui.platforms.ansi_console.consoleapp;
public import dlangui.core.config; public import dlangui.core.config;
static if (BACKEND_CONSOLE): static if (BACKEND_CONSOLE):
@ -9,8 +9,8 @@ import dlangui.graphics.drawbuf;
import dlangui.graphics.fonts; import dlangui.graphics.fonts;
import dlangui.widgets.styles; import dlangui.widgets.styles;
import dlangui.widgets.widget; import dlangui.widgets.widget;
import dlangui.platforms.console.consolefont; import dlangui.platforms.ansi_console.consolefont;
private import dlangui.platforms.console.dconsole; private import dlangui.platforms.ansi_console.dconsole;
class ConsoleWindow : Window { class ConsoleWindow : Window {
ConsolePlatform _platform; ConsolePlatform _platform;
@ -84,7 +84,7 @@ class ConsolePlatform : Platform {
@property Console console() { return _console; } @property Console console() { return _console; }
protected ConsoleDrawBuf _drawBuf; protected ANSIConsoleDrawBuf _drawBuf;
this() { this() {
_console = new Console(); _console = new Console();
_console.batchMode = true; _console.batchMode = true;
@ -95,7 +95,7 @@ class ConsolePlatform : Platform {
_console.init(); _console.init();
_console.setCursorType(ConsoleCursorType.Invisible); _console.setCursorType(ConsoleCursorType.Invisible);
_uiDialogDisplayMode = DialogDisplayMode.allTypesOfDialogsInPopup; _uiDialogDisplayMode = DialogDisplayMode.allTypesOfDialogsInPopup;
_drawBuf = new ConsoleDrawBuf(_console); _drawBuf = new ANSIConsoleDrawBuf(_console);
} }
~this() { ~this() {
//Log.d("Destroying console"); //Log.d("Destroying console");
@ -279,7 +279,7 @@ class ConsolePlatform : Platform {
} }
/// drawing buffer - image container which allows to perform some drawing operations /// drawing buffer - image container which allows to perform some drawing operations
class ConsoleDrawBuf : DrawBuf { class ANSIConsoleDrawBuf : ConsoleDrawBuf {
protected Console _console; protected Console _console;
@property Console console() { return _console; } @property Console console() { return _console; }
@ -439,7 +439,7 @@ class ConsoleDrawBuf : DrawBuf {
// TODO // TODO
} }
void drawChar(int x, int y, dchar ch, uint color, uint bgcolor) { override void drawChar(int x, int y, dchar ch, uint color, uint bgcolor) {
if (x < _clipRect.left || x >= _clipRect.right || y < _clipRect.top || y >= _clipRect.bottom) if (x < _clipRect.left || x >= _clipRect.right || y < _clipRect.top || y >= _clipRect.bottom)
return; return;
ubyte tc = toConsoleColor(color, false); ubyte tc = toConsoleColor(color, false);

View File

@ -1,4 +1,4 @@
module dlangui.platforms.console.consolefont; module dlangui.platforms.ansi_console.consolefont;
public import dlangui.core.config; public import dlangui.core.config;
@ -129,9 +129,9 @@ class ConsoleFont : Font {
override void drawText(DrawBuf drawBuf, int x, int y, const dchar[] text, uint color, int tabSize = 4, int tabOffset = 0, uint textFlags = 0) { override void drawText(DrawBuf drawBuf, int x, int y, const dchar[] text, uint color, int tabSize = 4, int tabOffset = 0, uint textFlags = 0) {
if (text.length == 0) if (text.length == 0)
return; // nothing to draw - empty text return; // nothing to draw - empty text
import dlangui.platforms.console.consoleapp; import dlangui.platforms.ansi_console.consoleapp;
import dlangui.platforms.console.dconsole; import dlangui.platforms.ansi_console.dconsole;
ConsoleDrawBuf buf = cast(ConsoleDrawBuf)drawBuf; ANSIConsoleDrawBuf buf = cast(ANSIConsoleDrawBuf)drawBuf;
if (!buf) if (!buf)
return; return;
if (_textSizeBuffer.length < text.length) if (_textSizeBuffer.length < text.length)
@ -146,7 +146,7 @@ class ConsoleFont : Font {
bool underline = (textFlags & TextFlag.Underline) != 0; bool underline = (textFlags & TextFlag.Underline) != 0;
int underlineHeight = 1; int underlineHeight = 1;
int underlineY = y + _baseline + underlineHeight * 2; int underlineY = y + _baseline + underlineHeight * 2;
buf.console.textColor = ConsoleDrawBuf.toConsoleColor(color); buf.console.textColor = ANSIConsoleDrawBuf.toConsoleColor(color);
buf.console.backgroundColor = CONSOLE_TRANSPARENT_BACKGROUND; buf.console.backgroundColor = CONSOLE_TRANSPARENT_BACKGROUND;
//Log.d("drawText: (", x, ',', y, ") '", text, "', color=", buf.console.textColor); //Log.d("drawText: (", x, ',', y, ") '", text, "', color=", buf.console.textColor);
foreach(int i; 0 .. charsMeasured) { foreach(int i; 0 .. charsMeasured) {
@ -200,9 +200,9 @@ class ConsoleFont : Font {
if (text.length == 0) if (text.length == 0)
return; // nothing to draw - empty text return; // nothing to draw - empty text
import dlangui.platforms.console.consoleapp; import dlangui.platforms.ansi_console.consoleapp;
import dlangui.platforms.console.dconsole; import dlangui.platforms.ansi_console.dconsole;
ConsoleDrawBuf buf = cast(ConsoleDrawBuf)drawBuf; ANSIConsoleDrawBuf buf = cast(ANSIConsoleDrawBuf)drawBuf;
if (_textSizeBuffer.length < text.length) if (_textSizeBuffer.length < text.length)
_textSizeBuffer.length = text.length; _textSizeBuffer.length = text.length;
@ -221,7 +221,7 @@ class ConsoleFont : Font {
foreach(int i; 0 .. charsMeasured) { foreach(int i; 0 .. charsMeasured) {
dchar ch = text[i]; dchar ch = text[i];
uint color = i < charProps.length ? charProps[i].color : charProps[$ - 1].color; uint color = i < charProps.length ? charProps[i].color : charProps[$ - 1].color;
buf.console.textColor = ConsoleDrawBuf.toConsoleColor(color); buf.console.textColor = ANSIConsoleDrawBuf.toConsoleColor(color);
customizedTextFlags = (i < charProps.length ? charProps[i].textFlags : charProps[$ - 1].textFlags) | textFlags; customizedTextFlags = (i < charProps.length ? charProps[i].textFlags : charProps[$ - 1].textFlags) | textFlags;
underline = (customizedTextFlags & TextFlag.Underline) != 0; underline = (customizedTextFlags & TextFlag.Underline) != 0;
// turn off underline after hot key // turn off underline after hot key

View File

@ -1,4 +1,4 @@
module dlangui.platforms.console.dconsole; module dlangui.platforms.ansi_console.dconsole;
public import dlangui.core.config; public import dlangui.core.config;

View File

@ -1947,7 +1947,7 @@ class Platform {
void onThemeChanged() { void onThemeChanged() {
// override and call dispatchThemeChange for all windows // override and call dispatchThemeChange for all windows
drawableCache.clear(); drawableCache.clear();
static if (!BACKEND_CONSOLE) { static if (!WIDGET_STYLE_CONSOLE) {
imageCache.checkpoint(); imageCache.checkpoint();
imageCache.cleanup(); imageCache.cleanup();
} }

View File

@ -309,9 +309,9 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
protected uint _caretColorReplace = 0x808080FF; protected uint _caretColorReplace = 0x808080FF;
protected uint _matchingBracketHightlightColor = 0x60FFE0B0; protected uint _matchingBracketHightlightColor = 0x60FFE0B0;
protected uint _iconsPaneWidth = BACKEND_CONSOLE ? 1 : 16; protected uint _iconsPaneWidth = WIDGET_STYLE_CONSOLE ? 1 : 16;
protected uint _foldingPaneWidth = BACKEND_CONSOLE ? 1 : 12; protected uint _foldingPaneWidth = WIDGET_STYLE_CONSOLE ? 1 : 12;
protected uint _modificationMarksPaneWidth = BACKEND_CONSOLE ? 1 : 4; protected uint _modificationMarksPaneWidth = WIDGET_STYLE_CONSOLE ? 1 : 4;
/// when true, call measureVisibileText on next layout /// when true, call measureVisibileText on next layout
protected bool _contentChanged = true; protected bool _contentChanged = true;
@ -415,7 +415,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
} }
_leftPaneWidth = _lineNumbersWidth + _modificationMarksWidth + _foldingWidth + _iconsWidth; _leftPaneWidth = _lineNumbersWidth + _modificationMarksWidth + _foldingWidth + _iconsWidth;
if (_leftPaneWidth) if (_leftPaneWidth)
_leftPaneWidth += BACKEND_CONSOLE ? 1 : 3; _leftPaneWidth += WIDGET_STYLE_CONSOLE ? 1 : 3;
} }
protected void drawLeftPaneFolding(DrawBuf buf, Rect rc, int line) { protected void drawLeftPaneFolding(DrawBuf buf, Rect rc, int line) {
@ -573,7 +573,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
buf.fillRect(rc, _leftPaneBackgroundColor); buf.fillRect(rc, _leftPaneBackgroundColor);
//buf.fillRect(Rect(rc.right - 2, rc.top, rc.right - 1, rc.bottom), _leftPaneBackgroundColor2); //buf.fillRect(Rect(rc.right - 2, rc.top, rc.right - 1, rc.bottom), _leftPaneBackgroundColor2);
//buf.fillRect(Rect(rc.right - 1, rc.top, rc.right - 0, rc.bottom), _leftPaneBackgroundColor3); //buf.fillRect(Rect(rc.right - 1, rc.top, rc.right - 0, rc.bottom), _leftPaneBackgroundColor3);
rc.right -= BACKEND_CONSOLE ? 1 : 3; rc.right -= WIDGET_STYLE_CONSOLE ? 1 : 3;
if (_foldingWidth) { if (_foldingWidth) {
Rect rc2 = rc; Rect rc2 = rc;
rc.right = rc2.left = rc2.right - _foldingWidth; rc.right = rc2.left = rc2.right - _foldingWidth;
@ -1039,7 +1039,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
protected void startCaretBlinking() { protected void startCaretBlinking() {
if (window) { if (window) {
static if (BACKEND_CONSOLE) { static if (WIDGET_STYLE_CONSOLE) {
window.caretRect = caretRect; window.caretRect = caretRect;
window.caretReplace = _replaceMode; window.caretReplace = _replaceMode;
} else { } else {
@ -1059,7 +1059,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
protected void stopCaretBlinking() { protected void stopCaretBlinking() {
if (window) { if (window) {
static if (BACKEND_CONSOLE) { static if (WIDGET_STYLE_CONSOLE) {
window.caretRect = Rect.init; window.caretRect = Rect.init;
} else { } else {
if (_caretTimerId) { if (_caretTimerId) {

View File

@ -1649,7 +1649,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
if (!colVisible(x)) if (!colVisible(x))
continue; continue;
Rect cellRect = cellRectScroll(x, y); Rect cellRect = cellRectScroll(x, y);
if (BACKEND_CONSOLE && phase == 1) { if (WIDGET_STYLE_CONSOLE && phase == 1) {
cellRect.right--; cellRect.right--;
} }
Rect clippedCellRect = cellRect; Rect clippedCellRect = cellRect;
@ -1703,7 +1703,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
protected Point measureCell(int x, int y) { protected Point measureCell(int x, int y) {
// override it! // override it!
return Point(BACKEND_CONSOLE ? 5 : 80, BACKEND_CONSOLE ? 1 : 20); return Point(WIDGET_STYLE_CONSOLE ? 5 : 80, WIDGET_STYLE_CONSOLE ? 1 : 20);
} }
protected int measureColWidth(int x) { protected int measureColWidth(int x) {
@ -1741,7 +1741,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
} }
void autoFitColumnWidth(int i) { void autoFitColumnWidth(int i) {
_colWidths[i] = (i < _headerCols && !_showRowHeaders) ? 0 : measureColWidth(i) + (BACKEND_CONSOLE ? 1 : 3.pointsToPixels); _colWidths[i] = (i < _headerCols && !_showRowHeaders) ? 0 : measureColWidth(i) + (WIDGET_STYLE_CONSOLE ? 1 : 3.pointsToPixels);
_changedSize = true; _changedSize = true;
} }
@ -1765,7 +1765,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
} }
void autoFitRowHeight(int i) { void autoFitRowHeight(int i) {
_rowHeights[i] = (i < _headerRows && !_showColHeaders) ? 0 : measureRowHeight(i) + (BACKEND_CONSOLE ? 0 : 2); _rowHeights[i] = (i < _headerRows && !_showColHeaders) ? 0 : measureRowHeight(i) + (WIDGET_STYLE_CONSOLE ? 0 : 2);
_changedSize = true; _changedSize = true;
} }
@ -1785,8 +1785,8 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
_headerCols = 1; _headerCols = 1;
_headerRows = 1; _headerRows = 1;
_selection = new RedBlackTree!Point(); _selection = new RedBlackTree!Point();
_defRowHeight = BACKEND_CONSOLE ? 1 : pointsToPixels(16); _defRowHeight = WIDGET_STYLE_CONSOLE ? 1 : pointsToPixels(16);
_defColumnWidth = BACKEND_CONSOLE ? 7 : 100; _defColumnWidth = WIDGET_STYLE_CONSOLE ? 7 : 100;
_showColHeaders = true; _showColHeaders = true;
_showRowHeaders = true; _showRowHeaders = true;
@ -1964,7 +1964,7 @@ class StringGridWidget : StringGridWidgetBase {
Align ha = Align.Left; Align ha = Align.Left;
//if (sz.y < rc.height) //if (sz.y < rc.height)
// applyAlign(rc, sz, ha, Align.VCenter); // applyAlign(rc, sz, ha, Align.VCenter);
int offset = BACKEND_CONSOLE ? 0 : 1; int offset = WIDGET_STYLE_CONSOLE ? 0 : 1;
fnt.drawText(buf, rc.left + offset, rc.top + offset, txt, textColor); fnt.drawText(buf, rc.left + offset, rc.top + offset, txt, textColor);
} }
@ -1989,7 +1989,7 @@ class StringGridWidget : StringGridWidgetBase {
//if (row < 0) //if (row < 0)
// ha = Align.HCenter; // ha = Align.HCenter;
applyAlign(rc, sz, ha, Align.VCenter); applyAlign(rc, sz, ha, Align.VCenter);
int offset = BACKEND_CONSOLE ? 0 : 1; int offset = WIDGET_STYLE_CONSOLE ? 0 : 1;
uint cl = textColor; uint cl = textColor;
cl = style.customColor("grid_cell_text_color_header", cl); cl = style.customColor("grid_cell_text_color_header", cl);
fnt.drawText(buf, rc.left + offset, rc.top + offset, txt, cl); fnt.drawText(buf, rc.left + offset, rc.top + offset, txt, cl);

View File

@ -65,8 +65,8 @@ class StatusLineTextAndIconPanel : StatusLineTextPanel {
this(string ID) { this(string ID) {
super(ID); super(ID);
_icon = new ImageWidget(null); _icon = new ImageWidget(null);
_icon.minWidth = BACKEND_CONSOLE ? 1 : 20; _icon.minWidth = WIDGET_STYLE_CONSOLE ? 1 : 20;
_icon.minHeight = BACKEND_CONSOLE ? 1 : 20; _icon.minHeight = WIDGET_STYLE_CONSOLE ? 1 : 20;
_icon.alignment = Align.Center; _icon.alignment = Align.Center;
addChild(_icon); addChild(_icon);
} }

View File

@ -1187,7 +1187,7 @@ Theme createDefaultTheme() {
res.fontFace = "Verdana"; res.fontFace = "Verdana";
} }
//res.fontFace = "Arial Narrow"; //res.fontFace = "Arial Narrow";
static if (BACKEND_CONSOLE) { static if (WIDGET_STYLE_CONSOLE) {
res.fontSize = 1; res.fontSize = 1;
res.textColor = 0xFFFFFF; res.textColor = 0xFFFFFF;
Style button = res.createSubstyle(STYLE_BUTTON).backgroundColor(0x808080).alignment(Align.Center).setMargins(0, 0, 0, 0).textColor(0x000000); Style button = res.createSubstyle(STYLE_BUTTON).backgroundColor(0x808080).alignment(Align.Center).setMargins(0, 0, 0, 0).textColor(0x000000);
@ -1690,7 +1690,7 @@ bool loadTheme(Theme theme, string resourceId, int level = 0) {
string filename; string filename;
try { try {
filename = drawableCache.findResource(BACKEND_CONSOLE ? "console_" ~ resourceId : resourceId); filename = drawableCache.findResource(WIDGET_STYLE_CONSOLE ? "console_" ~ resourceId : resourceId);
if (!filename || !filename.endsWith(".xml")) if (!filename || !filename.endsWith(".xml"))
return false; return false;
string s = cast(string)loadResourceBytes(filename); string s = cast(string)loadResourceBytes(filename);