From f4f184530807cd99acd40148acee1fa712260ca4 Mon Sep 17 00:00:00 2001 From: cnmcdee Date: Sun, 29 Nov 2026 22:30:14 +0000 Subject: [PATCH] Group C getters/setters batch 16: IndVolumeDelta IndVolumeOscillator IndVolumePriceTrend IndVolumeRateOfChange IndVolumeWeightedMovingAverage IndVolumeZoneOscillator IndVortex IndWMA IndWaveTrend IndWeightedClose IndWilderVolatilitySystem IndWildersMA IndWilliamsAccumulationDistribution IndWilliamsR IndWoodiePivotPoints Expose draw() colours/constants as properties (bg/grid/axis, line width, grid divisions, candle colours, per-line colour) plus view/period accessors; defaults preserve the pre-pass render (verified pixel-identical vs pristine headers, setters exercised). --- .../IndVolumeDelta/IndVolumeDelta.h | 44 ++++++++++++--- .../IndVolumeOscillator/IndVolumeOscillator.h | 44 ++++++++++++--- .../IndVolumePriceTrend/IndVolumePriceTrend.h | 44 ++++++++++++--- .../IndVolumeRateOfChange.h | 44 ++++++++++++--- .../IndVolumeWeightedMovingAverage.h | 44 ++++++++++++--- .../IndVolumeZoneOscillator.h | 44 ++++++++++++--- widgets/components/IndVortex/IndVortex.h | 54 +++++++++++++++---- widgets/components/IndWMA/IndWMA.h | 54 +++++++++++++++---- .../components/IndWaveTrend/IndWaveTrend.h | 34 +++++++++--- .../IndWeightedClose/IndWeightedClose.h | 44 ++++++++++++--- .../IndWilderVolatilitySystem.h | 44 ++++++++++++--- .../components/IndWildersMA/IndWildersMA.h | 54 +++++++++++++++---- .../IndWilliamsAccumulationDistribution.h | 34 +++++++++--- .../components/IndWilliamsR/IndWilliamsR.h | 34 +++++++++--- .../IndWoodiePivotPoints.h | 44 ++++++++++++--- 15 files changed, 549 insertions(+), 111 deletions(-) diff --git a/widgets/components/IndVolumeDelta/IndVolumeDelta.h b/widgets/components/IndVolumeDelta/IndVolumeDelta.h index 4a8c99a..5485525 100644 --- a/widgets/components/IndVolumeDelta/IndVolumeDelta.h +++ b/widgets/components/IndVolumeDelta/IndVolumeDelta.h @@ -141,6 +141,15 @@ private: int cross_x_ = 0, cross_y_ = 0; int period_; double mult_; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{0, 150, 0}; + Srgb candle_down_color_ = Srgb{200, 30, 30}; + public: std::function on_view_change; IndVolumeDelta(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, @@ -164,6 +173,27 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)lines_.size()) lines_[(size_t)i].color = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)lines_.size()) return lines_[(size_t)i].color; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + double get_mult() { return mult_; } + void set_view_first(double v) { view_first_ = v; } + void set_zoom(double z) { zoom_ = z; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -189,9 +219,9 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 1e300, hi = -1e300; @@ -203,7 +233,7 @@ public: if (lo > hi) { lo = 0.0; hi = 1.0; } double pad = (hi - lo) * 0.06 + 1e-9; lo -= pad; hi += pad; int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = XGraph_nice_step(hi - lo, 6); + double step = XGraph_nice_step(hi - lo, grid_divisions_); double start = std::ceil(lo / step) * step; for (double v = start; v <= hi; v += step) { int gy = y_at(v, lo, hi); @@ -219,7 +249,7 @@ public: int cx = x_center(i); if (cx < px || cx > px + pw) continue; const OHLCV& b = series_[i]; - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 0 : 200, b.close >= b.open ? 150 : 30, b.close >= b.open ? 0 : 30); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi); @@ -230,7 +260,7 @@ public: for (auto& ln : lines_) { unsigned long col = styles_->get_color_Srgb(ln.color); XSetForeground(display_, gc_, col); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); std::vector pts; auto flush = [&]() { if (pts.size() > 1) XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); @@ -250,7 +280,7 @@ public: { int lx = px + 8, ly = py + 8; for (auto& ln : lines_) { XSetForeground(display_, gc_, styles_->get_color_Srgb(ln.color)); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last; diff --git a/widgets/components/IndVolumeOscillator/IndVolumeOscillator.h b/widgets/components/IndVolumeOscillator/IndVolumeOscillator.h index fcfe301..e6756a2 100644 --- a/widgets/components/IndVolumeOscillator/IndVolumeOscillator.h +++ b/widgets/components/IndVolumeOscillator/IndVolumeOscillator.h @@ -140,6 +140,15 @@ private: int cross_x_ = 0, cross_y_ = 0; int period_; double mult_; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{0, 150, 0}; + Srgb candle_down_color_ = Srgb{200, 30, 30}; + public: std::function on_view_change; IndVolumeOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, @@ -163,6 +172,27 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)lines_.size()) lines_[(size_t)i].color = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)lines_.size()) return lines_[(size_t)i].color; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + double get_mult() { return mult_; } + void set_view_first(double v) { view_first_ = v; } + void set_zoom(double z) { zoom_ = z; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -188,9 +218,9 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 1e300, hi = -1e300; @@ -202,7 +232,7 @@ public: if (lo > hi) { lo = 0.0; hi = 1.0; } double pad = (hi - lo) * 0.06 + 1e-9; lo -= pad; hi += pad; int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = XGraph_nice_step(hi - lo, 6); + double step = XGraph_nice_step(hi - lo, grid_divisions_); double start = std::ceil(lo / step) * step; for (double v = start; v <= hi; v += step) { int gy = y_at(v, lo, hi); @@ -218,7 +248,7 @@ public: int cx = x_center(i); if (cx < px || cx > px + pw) continue; const OHLCV& b = series_[i]; - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 0 : 200, b.close >= b.open ? 150 : 30, b.close >= b.open ? 0 : 30); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi); @@ -229,7 +259,7 @@ public: for (auto& ln : lines_) { unsigned long col = styles_->get_color_Srgb(ln.color); XSetForeground(display_, gc_, col); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); std::vector pts; auto flush = [&]() { if (pts.size() > 1) XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); @@ -249,7 +279,7 @@ public: { int lx = px + 8, ly = py + 8; for (auto& ln : lines_) { XSetForeground(display_, gc_, styles_->get_color_Srgb(ln.color)); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last; diff --git a/widgets/components/IndVolumePriceTrend/IndVolumePriceTrend.h b/widgets/components/IndVolumePriceTrend/IndVolumePriceTrend.h index 9f9d0c2..a45a0a5 100644 --- a/widgets/components/IndVolumePriceTrend/IndVolumePriceTrend.h +++ b/widgets/components/IndVolumePriceTrend/IndVolumePriceTrend.h @@ -142,6 +142,15 @@ private: int cross_x_ = 0, cross_y_ = 0; int period_; double mult_; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{0, 150, 0}; + Srgb candle_down_color_ = Srgb{200, 30, 30}; + public: std::function on_view_change; IndVolumePriceTrend(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, @@ -165,6 +174,27 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)lines_.size()) lines_[(size_t)i].color = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)lines_.size()) return lines_[(size_t)i].color; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + double get_mult() { return mult_; } + void set_view_first(double v) { view_first_ = v; } + void set_zoom(double z) { zoom_ = z; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -190,9 +220,9 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 1e300, hi = -1e300; @@ -204,7 +234,7 @@ public: if (lo > hi) { lo = 0.0; hi = 1.0; } double pad = (hi - lo) * 0.06 + 1e-9; lo -= pad; hi += pad; int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = XGraph_nice_step(hi - lo, 6); + double step = XGraph_nice_step(hi - lo, grid_divisions_); double start = std::ceil(lo / step) * step; for (double v = start; v <= hi; v += step) { int gy = y_at(v, lo, hi); @@ -220,7 +250,7 @@ public: int cx = x_center(i); if (cx < px || cx > px + pw) continue; const OHLCV& b = series_[i]; - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 0 : 200, b.close >= b.open ? 150 : 30, b.close >= b.open ? 0 : 30); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi); @@ -231,7 +261,7 @@ public: for (auto& ln : lines_) { unsigned long col = styles_->get_color_Srgb(ln.color); XSetForeground(display_, gc_, col); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); std::vector pts; auto flush = [&]() { if (pts.size() > 1) XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); @@ -251,7 +281,7 @@ public: { int lx = px + 8, ly = py + 8; for (auto& ln : lines_) { XSetForeground(display_, gc_, styles_->get_color_Srgb(ln.color)); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last; diff --git a/widgets/components/IndVolumeRateOfChange/IndVolumeRateOfChange.h b/widgets/components/IndVolumeRateOfChange/IndVolumeRateOfChange.h index 65d9274..d0cc6bf 100644 --- a/widgets/components/IndVolumeRateOfChange/IndVolumeRateOfChange.h +++ b/widgets/components/IndVolumeRateOfChange/IndVolumeRateOfChange.h @@ -138,6 +138,15 @@ private: int cross_x_ = 0, cross_y_ = 0; int period_; double mult_; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{0, 150, 0}; + Srgb candle_down_color_ = Srgb{200, 30, 30}; + public: std::function on_view_change; IndVolumeRateOfChange(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, @@ -161,6 +170,27 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)lines_.size()) lines_[(size_t)i].color = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)lines_.size()) return lines_[(size_t)i].color; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + double get_mult() { return mult_; } + void set_view_first(double v) { view_first_ = v; } + void set_zoom(double z) { zoom_ = z; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -186,9 +216,9 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 1e300, hi = -1e300; @@ -200,7 +230,7 @@ public: if (lo > hi) { lo = 0.0; hi = 1.0; } double pad = (hi - lo) * 0.06 + 1e-9; lo -= pad; hi += pad; int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = XGraph_nice_step(hi - lo, 6); + double step = XGraph_nice_step(hi - lo, grid_divisions_); double start = std::ceil(lo / step) * step; for (double v = start; v <= hi; v += step) { int gy = y_at(v, lo, hi); @@ -216,7 +246,7 @@ public: int cx = x_center(i); if (cx < px || cx > px + pw) continue; const OHLCV& b = series_[i]; - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 0 : 200, b.close >= b.open ? 150 : 30, b.close >= b.open ? 0 : 30); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi); @@ -227,7 +257,7 @@ public: for (auto& ln : lines_) { unsigned long col = styles_->get_color_Srgb(ln.color); XSetForeground(display_, gc_, col); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); std::vector pts; auto flush = [&]() { if (pts.size() > 1) XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); @@ -247,7 +277,7 @@ public: { int lx = px + 8, ly = py + 8; for (auto& ln : lines_) { XSetForeground(display_, gc_, styles_->get_color_Srgb(ln.color)); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last; diff --git a/widgets/components/IndVolumeWeightedMovingAverage/IndVolumeWeightedMovingAverage.h b/widgets/components/IndVolumeWeightedMovingAverage/IndVolumeWeightedMovingAverage.h index 861d24a..e07ff38 100644 --- a/widgets/components/IndVolumeWeightedMovingAverage/IndVolumeWeightedMovingAverage.h +++ b/widgets/components/IndVolumeWeightedMovingAverage/IndVolumeWeightedMovingAverage.h @@ -141,6 +141,15 @@ private: int cross_x_ = 0, cross_y_ = 0; int period_; double mult_; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{0, 150, 0}; + Srgb candle_down_color_ = Srgb{200, 30, 30}; + public: std::function on_view_change; IndVolumeWeightedMovingAverage(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, @@ -164,6 +173,27 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)lines_.size()) lines_[(size_t)i].color = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)lines_.size()) return lines_[(size_t)i].color; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + double get_mult() { return mult_; } + void set_view_first(double v) { view_first_ = v; } + void set_zoom(double z) { zoom_ = z; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -189,9 +219,9 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 1e300, hi = -1e300; @@ -203,7 +233,7 @@ public: if (lo > hi) { lo = 0.0; hi = 1.0; } double pad = (hi - lo) * 0.06 + 1e-9; lo -= pad; hi += pad; int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = XGraph_nice_step(hi - lo, 6); + double step = XGraph_nice_step(hi - lo, grid_divisions_); double start = std::ceil(lo / step) * step; for (double v = start; v <= hi; v += step) { int gy = y_at(v, lo, hi); @@ -219,7 +249,7 @@ public: int cx = x_center(i); if (cx < px || cx > px + pw) continue; const OHLCV& b = series_[i]; - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 0 : 200, b.close >= b.open ? 150 : 30, b.close >= b.open ? 0 : 30); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi); @@ -230,7 +260,7 @@ public: for (auto& ln : lines_) { unsigned long col = styles_->get_color_Srgb(ln.color); XSetForeground(display_, gc_, col); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); std::vector pts; auto flush = [&]() { if (pts.size() > 1) XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); @@ -250,7 +280,7 @@ public: { int lx = px + 8, ly = py + 8; for (auto& ln : lines_) { XSetForeground(display_, gc_, styles_->get_color_Srgb(ln.color)); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last; diff --git a/widgets/components/IndVolumeZoneOscillator/IndVolumeZoneOscillator.h b/widgets/components/IndVolumeZoneOscillator/IndVolumeZoneOscillator.h index ca48495..69837df 100644 --- a/widgets/components/IndVolumeZoneOscillator/IndVolumeZoneOscillator.h +++ b/widgets/components/IndVolumeZoneOscillator/IndVolumeZoneOscillator.h @@ -147,6 +147,15 @@ private: int cross_x_ = 0, cross_y_ = 0; int period_; double mult_; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{0, 150, 0}; + Srgb candle_down_color_ = Srgb{200, 30, 30}; + public: std::function on_view_change; IndVolumeZoneOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, @@ -170,6 +179,27 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)lines_.size()) lines_[(size_t)i].color = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)lines_.size()) return lines_[(size_t)i].color; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + double get_mult() { return mult_; } + void set_view_first(double v) { view_first_ = v; } + void set_zoom(double z) { zoom_ = z; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -195,9 +225,9 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 1e300, hi = -1e300; @@ -209,7 +239,7 @@ public: if (lo > hi) { lo = 0.0; hi = 1.0; } double pad = (hi - lo) * 0.06 + 1e-9; lo -= pad; hi += pad; int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = XGraph_nice_step(hi - lo, 6); + double step = XGraph_nice_step(hi - lo, grid_divisions_); double start = std::ceil(lo / step) * step; for (double v = start; v <= hi; v += step) { int gy = y_at(v, lo, hi); @@ -225,7 +255,7 @@ public: int cx = x_center(i); if (cx < px || cx > px + pw) continue; const OHLCV& b = series_[i]; - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 0 : 200, b.close >= b.open ? 150 : 30, b.close >= b.open ? 0 : 30); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi); @@ -236,7 +266,7 @@ public: for (auto& ln : lines_) { unsigned long col = styles_->get_color_Srgb(ln.color); XSetForeground(display_, gc_, col); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); std::vector pts; auto flush = [&]() { if (pts.size() > 1) XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); @@ -256,7 +286,7 @@ public: { int lx = px + 8, ly = py + 8; for (auto& ln : lines_) { XSetForeground(display_, gc_, styles_->get_color_Srgb(ln.color)); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last; diff --git a/widgets/components/IndVortex/IndVortex.h b/widgets/components/IndVortex/IndVortex.h index e72e999..c90dda0 100644 --- a/widgets/components/IndVortex/IndVortex.h +++ b/widgets/components/IndVortex/IndVortex.h @@ -223,6 +223,16 @@ private: int axis_w_ = 56; int axis_h_ = 20; int period_ = 14; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{228, 228, 228}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{150, 190, 150}; + Srgb candle_down_color_ = Srgb{210, 130, 130}; + int point_size_ = 5; + public: IndVortex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14) : display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles), @@ -240,6 +250,30 @@ public: void set_enabled(bool e) { enabled_ = e; } bool get_enabled() { return enabled_; } void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_point_size(int s) { if (s > 0) point_size_ = s; } + int get_point_size() { return point_size_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)line_colors_.size()) line_colors_[(size_t)i] = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)line_colors_.size()) return line_colors_[(size_t)i]; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + void set_axis_w(int w) { axis_w_ = w; } + int get_axis_w() { return axis_w_; } + void set_axis_h(int h) { axis_h_ = h; } + int get_axis_h() { return axis_h_; } SStyle style() { return styles_->resolve(style_name_); } const OHLCVSeries& series() const { return series_; } int bar_count() { return (int)series_.size(); } @@ -268,7 +302,7 @@ public: void draw_candles(double lo, double hi) { int bw = std::max(1, (int)(item_w() * 0.6)); for (size_t i = 0; i < series_.size(); ++i) { const auto& b = series_[i]; int cx = x_center((int)i); - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 150 : 210, b.close >= b.open ? 190 : 130, b.close >= b.open ? 150 : 130); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi), bot = y_at(std::min(b.open, b.close), lo, hi); @@ -277,14 +311,14 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(228, 228, 228); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 0.0, hi = 1.0; y_range(lo, hi); int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = (hi - lo) / 6.0; if (step <= 0) step = 1.0; - for (int g = 0; g <= 6; ++g) { double v = lo + step * g; int gy = y_at(v, lo, hi); + double step = (hi - lo) / (double)grid_divisions_; if (step <= 0) step = 1.0; + for (int g = 0; g <= grid_divisions_; ++g) { double v = lo + step * g; int gy = y_at(v, lo, hi); XSetForeground(display_, gc_, grid); XDrawLine(display_, window_, gc_, px, gy, px + pw, gy); xf::draw_text_at(display_, window_, gc_, st, px - xf::text_width(st, fmt(v)) - 6, gy + 4, fmt(v)); } if (!pane_) draw_candles(lo, hi); @@ -298,11 +332,11 @@ public: unsigned long col = styles_->get_color_Srgb(line_colors_[li]); std::vector pts; for (size_t i = 0; i < lines_[li].size(); ++i) { - if (!std::isfinite(lines_[li][i])) { if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, 2); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } pts.clear(); continue; } + if (!std::isfinite(lines_[li][i])) { if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, line_width_); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } pts.clear(); continue; } XPoint p; p.x = (short)x_center((int)i); p.y = (short)y_at(lines_[li][i], lo, hi); pts.push_back(p); } - if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, 2); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } - else if (pts.size() == 1) { XSetForeground(display_, gc_, col); XFillArc(display_, window_, gc_, pts[0].x - 2, pts[0].y - 2, 5, 5, 0, 360 * 64); } + if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, line_width_); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } + else if (pts.size() == 1) { XSetForeground(display_, gc_, col); XFillArc(display_, window_, gc_, pts[0].x - point_size_ / 2, pts[0].y - point_size_ / 2, point_size_, point_size_, 0, 360 * 64); } } if (selected_ >= 0 && selected_ < (int)series_.size()) { int cx = x_center(selected_); @@ -316,7 +350,7 @@ public: ly += 16; for (size_t li = 0; li < lines_.size(); ++li) { unsigned long col = styles_->get_color_Srgb(line_colors_[li]); - XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, 2); + XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last; for (size_t i = lines_[li].size(); i-- > 0;) if (std::isfinite(lines_[li][i])) { last = fmt(lines_[li][i]); break; } diff --git a/widgets/components/IndWMA/IndWMA.h b/widgets/components/IndWMA/IndWMA.h index f6e3ee5..d6b517a 100644 --- a/widgets/components/IndWMA/IndWMA.h +++ b/widgets/components/IndWMA/IndWMA.h @@ -222,6 +222,16 @@ private: int axis_w_ = 56; int axis_h_ = 20; int period_ = 14; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{228, 228, 228}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{150, 190, 150}; + Srgb candle_down_color_ = Srgb{210, 130, 130}; + int point_size_ = 5; + public: IndWMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14) : display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles), @@ -241,6 +251,30 @@ public: void set_enabled(bool e) { enabled_ = e; } bool get_enabled() { return enabled_; } void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_point_size(int s) { if (s > 0) point_size_ = s; } + int get_point_size() { return point_size_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)line_colors_.size()) line_colors_[(size_t)i] = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)line_colors_.size()) return line_colors_[(size_t)i]; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + void set_axis_w(int w) { axis_w_ = w; } + int get_axis_w() { return axis_w_; } + void set_axis_h(int h) { axis_h_ = h; } + int get_axis_h() { return axis_h_; } SStyle style() { return styles_->resolve(style_name_); } const OHLCVSeries& series() const { return series_; } int bar_count() { return (int)series_.size(); } @@ -269,7 +303,7 @@ public: void draw_candles(double lo, double hi) { int bw = std::max(1, (int)(item_w() * 0.6)); for (size_t i = 0; i < series_.size(); ++i) { const auto& b = series_[i]; int cx = x_center((int)i); - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 150 : 210, b.close >= b.open ? 190 : 130, b.close >= b.open ? 150 : 130); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi), bot = y_at(std::min(b.open, b.close), lo, hi); @@ -278,14 +312,14 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(228, 228, 228); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 0.0, hi = 1.0; y_range(lo, hi); int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = (hi - lo) / 6.0; if (step <= 0) step = 1.0; - for (int g = 0; g <= 6; ++g) { double v = lo + step * g; int gy = y_at(v, lo, hi); + double step = (hi - lo) / (double)grid_divisions_; if (step <= 0) step = 1.0; + for (int g = 0; g <= grid_divisions_; ++g) { double v = lo + step * g; int gy = y_at(v, lo, hi); XSetForeground(display_, gc_, grid); XDrawLine(display_, window_, gc_, px, gy, px + pw, gy); xf::draw_text_at(display_, window_, gc_, st, px - xf::text_width(st, fmt(v)) - 6, gy + 4, fmt(v)); } if (!pane_) draw_candles(lo, hi); @@ -299,11 +333,11 @@ public: unsigned long col = styles_->get_color_Srgb(line_colors_[li]); std::vector pts; for (size_t i = 0; i < lines_[li].size(); ++i) { - if (!std::isfinite(lines_[li][i])) { if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, 2); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } pts.clear(); continue; } + if (!std::isfinite(lines_[li][i])) { if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, line_width_); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } pts.clear(); continue; } XPoint p; p.x = (short)x_center((int)i); p.y = (short)y_at(lines_[li][i], lo, hi); pts.push_back(p); } - if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, 2); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } - else if (pts.size() == 1) { XSetForeground(display_, gc_, col); XFillArc(display_, window_, gc_, pts[0].x - 2, pts[0].y - 2, 5, 5, 0, 360 * 64); } + if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, line_width_); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } + else if (pts.size() == 1) { XSetForeground(display_, gc_, col); XFillArc(display_, window_, gc_, pts[0].x - point_size_ / 2, pts[0].y - point_size_ / 2, point_size_, point_size_, 0, 360 * 64); } } if (selected_ >= 0 && selected_ < (int)series_.size()) { int cx = x_center(selected_); @@ -317,7 +351,7 @@ public: ly += 16; for (size_t li = 0; li < lines_.size(); ++li) { unsigned long col = styles_->get_color_Srgb(line_colors_[li]); - XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, 2); + XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last; for (size_t i = lines_[li].size(); i-- > 0;) if (std::isfinite(lines_[li][i])) { last = fmt(lines_[li][i]); break; } diff --git a/widgets/components/IndWaveTrend/IndWaveTrend.h b/widgets/components/IndWaveTrend/IndWaveTrend.h index ada7917..1d76835 100644 --- a/widgets/components/IndWaveTrend/IndWaveTrend.h +++ b/widgets/components/IndWaveTrend/IndWaveTrend.h @@ -195,6 +195,13 @@ private: int cross_x_ = 0; int cross_y_ = 0; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 4; + public: IndWaveTrend(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int esa = 10, int d = 21) @@ -232,6 +239,21 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)line_colors_.size()) line_colors_[(size_t)i] = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)line_colors_.size()) return line_colors_[(size_t)i]; return Srgb{0, 0, 0}; } + void set_view_first(double v) { view_first_ = v; } + void set_view_count(double v) { view_count_ = v; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -246,9 +268,9 @@ public: { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); int px = x1_ + 56, py = y1_ + 6; @@ -276,8 +298,8 @@ public: hi += pad; auto yat = [&](double v) { return py + (int)((hi - v) / (hi - lo) * ph); }; auto xat = [&](int i) { return px + (int)(((double)i - view_first_) / get_view_count() * pw); }; - for (int g = 0; g <= 4; ++g) { - double v = lo + (hi - lo) * g / 4.0; + for (int g = 0; g <= grid_divisions_; ++g) { + double v = lo + (hi - lo) * g / (double)grid_divisions_; int gy = yat(v); XSetForeground(display_, gc_, grid); XDrawLine(display_, window_, gc_, px, gy, px + pw, gy); @@ -290,7 +312,7 @@ public: } for (std::size_t li = 0; li < lines_.size(); ++li) { XSetForeground(display_, gc_, styles_->get_color_Srgb(line_colors_[li])); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); for (int i = i0 + 1; i < i1; ++i) { if (i < 1 || i >= (int)lines_[li].size()) continue; double a = lines_[li][(std::size_t)(i - 1)], b = lines_[li][(std::size_t)i]; diff --git a/widgets/components/IndWeightedClose/IndWeightedClose.h b/widgets/components/IndWeightedClose/IndWeightedClose.h index 5a17a9c..1995dde 100644 --- a/widgets/components/IndWeightedClose/IndWeightedClose.h +++ b/widgets/components/IndWeightedClose/IndWeightedClose.h @@ -137,6 +137,15 @@ private: int cross_x_ = 0, cross_y_ = 0; int period_; double mult_; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{0, 150, 0}; + Srgb candle_down_color_ = Srgb{200, 30, 30}; + public: std::function on_view_change; IndWeightedClose(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, @@ -160,6 +169,27 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)lines_.size()) lines_[(size_t)i].color = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)lines_.size()) return lines_[(size_t)i].color; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + double get_mult() { return mult_; } + void set_view_first(double v) { view_first_ = v; } + void set_zoom(double z) { zoom_ = z; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -185,9 +215,9 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 1e300, hi = -1e300; @@ -199,7 +229,7 @@ public: if (lo > hi) { lo = 0.0; hi = 1.0; } double pad = (hi - lo) * 0.06 + 1e-9; lo -= pad; hi += pad; int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = XGraph_nice_step(hi - lo, 6); + double step = XGraph_nice_step(hi - lo, grid_divisions_); double start = std::ceil(lo / step) * step; for (double v = start; v <= hi; v += step) { int gy = y_at(v, lo, hi); @@ -215,7 +245,7 @@ public: int cx = x_center(i); if (cx < px || cx > px + pw) continue; const OHLCV& b = series_[i]; - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 0 : 200, b.close >= b.open ? 150 : 30, b.close >= b.open ? 0 : 30); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi); @@ -226,7 +256,7 @@ public: for (auto& ln : lines_) { unsigned long col = styles_->get_color_Srgb(ln.color); XSetForeground(display_, gc_, col); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); std::vector pts; auto flush = [&]() { if (pts.size() > 1) XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); @@ -246,7 +276,7 @@ public: { int lx = px + 8, ly = py + 8; for (auto& ln : lines_) { XSetForeground(display_, gc_, styles_->get_color_Srgb(ln.color)); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last; diff --git a/widgets/components/IndWilderVolatilitySystem/IndWilderVolatilitySystem.h b/widgets/components/IndWilderVolatilitySystem/IndWilderVolatilitySystem.h index 2d7f05b..99800b0 100644 --- a/widgets/components/IndWilderVolatilitySystem/IndWilderVolatilitySystem.h +++ b/widgets/components/IndWilderVolatilitySystem/IndWilderVolatilitySystem.h @@ -151,6 +151,15 @@ private: int cross_x_ = 0, cross_y_ = 0; int period_; double mult_; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{0, 150, 0}; + Srgb candle_down_color_ = Srgb{200, 30, 30}; + public: std::function on_view_change; IndWilderVolatilitySystem(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, @@ -174,6 +183,27 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)lines_.size()) lines_[(size_t)i].color = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)lines_.size()) return lines_[(size_t)i].color; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + double get_mult() { return mult_; } + void set_view_first(double v) { view_first_ = v; } + void set_zoom(double z) { zoom_ = z; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -199,9 +229,9 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 1e300, hi = -1e300; @@ -213,7 +243,7 @@ public: if (lo > hi) { lo = 0.0; hi = 1.0; } double pad = (hi - lo) * 0.06 + 1e-9; lo -= pad; hi += pad; int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = XGraph_nice_step(hi - lo, 6); + double step = XGraph_nice_step(hi - lo, grid_divisions_); double start = std::ceil(lo / step) * step; for (double v = start; v <= hi; v += step) { int gy = y_at(v, lo, hi); @@ -229,7 +259,7 @@ public: int cx = x_center(i); if (cx < px || cx > px + pw) continue; const OHLCV& b = series_[i]; - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 0 : 200, b.close >= b.open ? 150 : 30, b.close >= b.open ? 0 : 30); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi); @@ -240,7 +270,7 @@ public: for (auto& ln : lines_) { unsigned long col = styles_->get_color_Srgb(ln.color); XSetForeground(display_, gc_, col); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); std::vector pts; auto flush = [&]() { if (pts.size() > 1) XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); @@ -260,7 +290,7 @@ public: { int lx = px + 8, ly = py + 8; for (auto& ln : lines_) { XSetForeground(display_, gc_, styles_->get_color_Srgb(ln.color)); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last; diff --git a/widgets/components/IndWildersMA/IndWildersMA.h b/widgets/components/IndWildersMA/IndWildersMA.h index 3ad4295..8393691 100644 --- a/widgets/components/IndWildersMA/IndWildersMA.h +++ b/widgets/components/IndWildersMA/IndWildersMA.h @@ -222,6 +222,16 @@ private: int axis_w_ = 56; int axis_h_ = 20; int period_ = 14; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{228, 228, 228}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{150, 190, 150}; + Srgb candle_down_color_ = Srgb{210, 130, 130}; + int point_size_ = 5; + public: IndWildersMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14) : display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles), @@ -241,6 +251,30 @@ public: void set_enabled(bool e) { enabled_ = e; } bool get_enabled() { return enabled_; } void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_point_size(int s) { if (s > 0) point_size_ = s; } + int get_point_size() { return point_size_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)line_colors_.size()) line_colors_[(size_t)i] = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)line_colors_.size()) return line_colors_[(size_t)i]; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + void set_axis_w(int w) { axis_w_ = w; } + int get_axis_w() { return axis_w_; } + void set_axis_h(int h) { axis_h_ = h; } + int get_axis_h() { return axis_h_; } SStyle style() { return styles_->resolve(style_name_); } const OHLCVSeries& series() const { return series_; } int bar_count() { return (int)series_.size(); } @@ -269,7 +303,7 @@ public: void draw_candles(double lo, double hi) { int bw = std::max(1, (int)(item_w() * 0.6)); for (size_t i = 0; i < series_.size(); ++i) { const auto& b = series_[i]; int cx = x_center((int)i); - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 150 : 210, b.close >= b.open ? 190 : 130, b.close >= b.open ? 150 : 130); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi), bot = y_at(std::min(b.open, b.close), lo, hi); @@ -278,14 +312,14 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(228, 228, 228); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 0.0, hi = 1.0; y_range(lo, hi); int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = (hi - lo) / 6.0; if (step <= 0) step = 1.0; - for (int g = 0; g <= 6; ++g) { double v = lo + step * g; int gy = y_at(v, lo, hi); + double step = (hi - lo) / (double)grid_divisions_; if (step <= 0) step = 1.0; + for (int g = 0; g <= grid_divisions_; ++g) { double v = lo + step * g; int gy = y_at(v, lo, hi); XSetForeground(display_, gc_, grid); XDrawLine(display_, window_, gc_, px, gy, px + pw, gy); xf::draw_text_at(display_, window_, gc_, st, px - xf::text_width(st, fmt(v)) - 6, gy + 4, fmt(v)); } if (!pane_) draw_candles(lo, hi); @@ -299,11 +333,11 @@ public: unsigned long col = styles_->get_color_Srgb(line_colors_[li]); std::vector pts; for (size_t i = 0; i < lines_[li].size(); ++i) { - if (!std::isfinite(lines_[li][i])) { if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, 2); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } pts.clear(); continue; } + if (!std::isfinite(lines_[li][i])) { if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, line_width_); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } pts.clear(); continue; } XPoint p; p.x = (short)x_center((int)i); p.y = (short)y_at(lines_[li][i], lo, hi); pts.push_back(p); } - if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, 2); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } - else if (pts.size() == 1) { XSetForeground(display_, gc_, col); XFillArc(display_, window_, gc_, pts[0].x - 2, pts[0].y - 2, 5, 5, 0, 360 * 64); } + if (pts.size() > 1) { XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, line_width_); XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); xf::set_line_width(display_, gc_, 1); } + else if (pts.size() == 1) { XSetForeground(display_, gc_, col); XFillArc(display_, window_, gc_, pts[0].x - point_size_ / 2, pts[0].y - point_size_ / 2, point_size_, point_size_, 0, 360 * 64); } } if (selected_ >= 0 && selected_ < (int)series_.size()) { int cx = x_center(selected_); @@ -317,7 +351,7 @@ public: ly += 16; for (size_t li = 0; li < lines_.size(); ++li) { unsigned long col = styles_->get_color_Srgb(line_colors_[li]); - XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, 2); + XSetForeground(display_, gc_, col); xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last; for (size_t i = lines_[li].size(); i-- > 0;) if (std::isfinite(lines_[li][i])) { last = fmt(lines_[li][i]); break; } diff --git a/widgets/components/IndWilliamsAccumulationDistribution/IndWilliamsAccumulationDistribution.h b/widgets/components/IndWilliamsAccumulationDistribution/IndWilliamsAccumulationDistribution.h index edc1026..e7390a4 100644 --- a/widgets/components/IndWilliamsAccumulationDistribution/IndWilliamsAccumulationDistribution.h +++ b/widgets/components/IndWilliamsAccumulationDistribution/IndWilliamsAccumulationDistribution.h @@ -198,6 +198,13 @@ private: int cross_x_ = 0; int cross_y_ = 0; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 4; + public: IndWilliamsAccumulationDistribution(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int dummy = 0) @@ -235,6 +242,21 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)line_colors_.size()) line_colors_[(size_t)i] = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)line_colors_.size()) return line_colors_[(size_t)i]; return Srgb{0, 0, 0}; } + void set_view_first(double v) { view_first_ = v; } + void set_view_count(double v) { view_count_ = v; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -249,9 +271,9 @@ public: { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); int px = x1_ + 56, py = y1_ + 6; @@ -279,8 +301,8 @@ public: hi += pad; auto yat = [&](double v) { return py + (int)((hi - v) / (hi - lo) * ph); }; auto xat = [&](int i) { return px + (int)(((double)i - view_first_) / get_view_count() * pw); }; - for (int g = 0; g <= 4; ++g) { - double v = lo + (hi - lo) * g / 4.0; + for (int g = 0; g <= grid_divisions_; ++g) { + double v = lo + (hi - lo) * g / (double)grid_divisions_; int gy = yat(v); XSetForeground(display_, gc_, grid); XDrawLine(display_, window_, gc_, px, gy, px + pw, gy); @@ -293,7 +315,7 @@ public: } for (std::size_t li = 0; li < lines_.size(); ++li) { XSetForeground(display_, gc_, styles_->get_color_Srgb(line_colors_[li])); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); for (int i = i0 + 1; i < i1; ++i) { if (i < 1 || i >= (int)lines_[li].size()) continue; double a = lines_[li][(std::size_t)(i - 1)], b = lines_[li][(std::size_t)i]; diff --git a/widgets/components/IndWilliamsR/IndWilliamsR.h b/widgets/components/IndWilliamsR/IndWilliamsR.h index 611d52c..d60b7f7 100644 --- a/widgets/components/IndWilliamsR/IndWilliamsR.h +++ b/widgets/components/IndWilliamsR/IndWilliamsR.h @@ -195,6 +195,13 @@ private: int cross_x_ = 0; int cross_y_ = 0; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 4; + public: IndWilliamsR(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14) @@ -232,6 +239,21 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)line_colors_.size()) line_colors_[(size_t)i] = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)line_colors_.size()) return line_colors_[(size_t)i]; return Srgb{0, 0, 0}; } + void set_view_first(double v) { view_first_ = v; } + void set_view_count(double v) { view_count_ = v; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -246,9 +268,9 @@ public: { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); int px = x1_ + 56, py = y1_ + 6; @@ -276,8 +298,8 @@ public: hi += pad; auto yat = [&](double v) { return py + (int)((hi - v) / (hi - lo) * ph); }; auto xat = [&](int i) { return px + (int)(((double)i - view_first_) / get_view_count() * pw); }; - for (int g = 0; g <= 4; ++g) { - double v = lo + (hi - lo) * g / 4.0; + for (int g = 0; g <= grid_divisions_; ++g) { + double v = lo + (hi - lo) * g / (double)grid_divisions_; int gy = yat(v); XSetForeground(display_, gc_, grid); XDrawLine(display_, window_, gc_, px, gy, px + pw, gy); @@ -290,7 +312,7 @@ public: } for (std::size_t li = 0; li < lines_.size(); ++li) { XSetForeground(display_, gc_, styles_->get_color_Srgb(line_colors_[li])); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); for (int i = i0 + 1; i < i1; ++i) { if (i < 1 || i >= (int)lines_[li].size()) continue; double a = lines_[li][(std::size_t)(i - 1)], b = lines_[li][(std::size_t)i]; diff --git a/widgets/components/IndWoodiePivotPoints/IndWoodiePivotPoints.h b/widgets/components/IndWoodiePivotPoints/IndWoodiePivotPoints.h index a6d2ebe..8e69dbf 100644 --- a/widgets/components/IndWoodiePivotPoints/IndWoodiePivotPoints.h +++ b/widgets/components/IndWoodiePivotPoints/IndWoodiePivotPoints.h @@ -146,6 +146,15 @@ private: int cross_x_ = 0, cross_y_ = 0; int period_; double mult_; + // Getter/setter pass (Group C): render state exposed as properties. + Srgb bg_color_ = Srgb{255, 255, 255}; + Srgb grid_color_ = Srgb{225, 225, 225}; + Srgb axis_color_ = Srgb{150, 150, 150}; + int line_width_ = 2; + int grid_divisions_ = 6; + Srgb candle_up_color_ = Srgb{0, 150, 0}; + Srgb candle_down_color_ = Srgb{200, 30, 30}; + public: std::function on_view_change; IndWoodiePivotPoints(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, @@ -171,6 +180,27 @@ public: void set_style_name(std::string s) { style_name_ = s; } void set_text(std::string t) { text_ = t; } std::string get_text() { return text_; } + // Render properties (getter/setter pass, Group C): defaults preserve pre-pass rendering. + void set_bg_color(Srgb c) { bg_color_ = c; } + Srgb get_bg_color() { return bg_color_; } + void set_grid_color(Srgb c) { grid_color_ = c; } + Srgb get_grid_color() { return grid_color_; } + void set_axis_color(Srgb c) { axis_color_ = c; } + Srgb get_axis_color() { return axis_color_; } + void set_line_width(int w) { line_width_ = w; } + int get_line_width() { return line_width_; } + void set_grid_divisions(int n) { if (n > 0) grid_divisions_ = n; } + int get_grid_divisions() { return grid_divisions_; } + void set_candle_up_color(Srgb c) { candle_up_color_ = c; } + Srgb get_candle_up_color() { return candle_up_color_; } + void set_candle_down_color(Srgb c) { candle_down_color_ = c; } + Srgb get_candle_down_color() { return candle_down_color_; } + void set_line_color(int i, Srgb c) { if (i >= 0 && i < (int)lines_.size()) lines_[(size_t)i].color = c; } + Srgb get_line_color(int i) { if (i >= 0 && i < (int)lines_.size()) return lines_[(size_t)i].color; return Srgb{0, 0, 0}; } + int get_period() { return period_; } + double get_mult() { return mult_; } + void set_view_first(double v) { view_first_ = v; } + void set_zoom(double z) { zoom_ = z; } SStyle style() { return styles_->resolve(style_name_); } int item_count() { return (int)series_.size(); } int line_count() { return (int)lines_.size(); } @@ -196,9 +226,9 @@ public: void draw() { if (!visible_) return; SStyle st = style(); - unsigned long white = styles_->get_color_rgb(255, 255, 255); - unsigned long grid = styles_->get_color_rgb(225, 225, 225); - unsigned long axis_col = styles_->get_color_rgb(150, 150, 150); + unsigned long white = styles_->get_color_Srgb(bg_color_); + unsigned long grid = styles_->get_color_Srgb(grid_color_); + unsigned long axis_col = styles_->get_color_Srgb(axis_color_); XSetForeground(display_, gc_, white); XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height()); double lo = 1e300, hi = -1e300; @@ -210,7 +240,7 @@ public: if (lo > hi) { lo = 0.0; hi = 1.0; } double pad = (hi - lo) * 0.06 + 1e-9; lo -= pad; hi += pad; int px = plot_x(), py = plot_y(), pw = plot_w(), ph = plot_h(); - double step = XGraph_nice_step(hi - lo, 6); + double step = XGraph_nice_step(hi - lo, grid_divisions_); double start = std::ceil(lo / step) * step; for (double v = start; v <= hi; v += step) { int gy = y_at(v, lo, hi); @@ -226,7 +256,7 @@ public: int cx = x_center(i); if (cx < px || cx > px + pw) continue; const OHLCV& b = series_[i]; - unsigned long c = styles_->get_color_rgb(b.close >= b.open ? 0 : 200, b.close >= b.open ? 150 : 30, b.close >= b.open ? 0 : 30); + unsigned long c = styles_->get_color_Srgb(b.close >= b.open ? candle_up_color_ : candle_down_color_); XSetForeground(display_, gc_, c); XDrawLine(display_, window_, gc_, cx, y_at(b.high, lo, hi), cx, y_at(b.low, lo, hi)); int top = y_at(std::max(b.open, b.close), lo, hi); @@ -237,7 +267,7 @@ public: for (auto& ln : lines_) { unsigned long col = styles_->get_color_Srgb(ln.color); XSetForeground(display_, gc_, col); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); std::vector pts; auto flush = [&]() { if (pts.size() > 1) XDrawLines(display_, window_, gc_, pts.data(), (int)pts.size(), CoordModeOrigin); @@ -257,7 +287,7 @@ public: { int lx = px + 8, ly = py + 8; for (auto& ln : lines_) { XSetForeground(display_, gc_, styles_->get_color_Srgb(ln.color)); - xf::set_line_width(display_, gc_, 2); + xf::set_line_width(display_, gc_, line_width_); XDrawLine(display_, window_, gc_, lx, ly + 4, lx + 18, ly + 4); xf::set_line_width(display_, gc_, 1); std::string last;