Skip to content

Commit

Permalink
feat: Add linefill stub
Browse files Browse the repository at this point in the history
  • Loading branch information
sibvic committed Oct 10, 2024
1 parent dfb17e2 commit 9821a42
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
4 changes: 0 additions & 4 deletions snippets/Objects/readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Objects snippets

## Table

Implementation of table similar to Pine

## Label

Pine script like implementation of label
Expand Down
7 changes: 7 additions & 0 deletions snippets/PineScript/Objects/LineFill.mqh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Linefill object
// v1.0

class LineFill
{
public:
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,23 @@ public:
static void Clear();
static void Add(Table* table);
static void Redraw();
static Table* Create(string prefix, string tableIndex, string position, int columns, int rows);
};

Table* TableManager::Create(string prefix, string tableIndex, string position, int columns, int rows)
{
string id = prefix + "_" + tableIndex;
int tablesCount = ArraySize(tables);
for (int i = 0; i < tablesCount; ++i)
{
if (tables[i].GetId() == id)
{
return tables[i];
}
}
return new Table(id, position, columns, rows);
}

Table* TableManager::tables[];
void TableManager::Clear()
{
Expand Down Expand Up @@ -72,10 +87,10 @@ class Table
int _rows;

int _borderWidth;
color _borderColor;
uint _borderColor;

int _frameWidth;
color _frameColor;
uint _frameColor;
Grid* _grid;
public:
Table(string prefix, string position, int columns, int rows)
Expand Down Expand Up @@ -111,8 +126,13 @@ public:
{
delete _grid;
}

string GetId()
{
return _prefix;
}

Table* SetBorderColor(color clr)
Table* SetBorderColor(uint clr)
{
_borderColor = clr;
return &this;
Expand All @@ -122,7 +142,7 @@ public:
_borderWidth = borderWidth;
return &this;
}
Table* SetBGColor(color clr)
Table* SetBGColor(uint clr)
{
for (int row = 0; row < _grid.GetRowsCount(); ++row)
{
Expand All @@ -136,7 +156,7 @@ public:
return &this;
}

Table* SetFrameColor(color clr)
Table* SetFrameColor(uint clr)
{
_frameColor = clr;
return &this;
Expand All @@ -163,15 +183,15 @@ public:
Redraw();
}
}
static void CellTextColor(Table* table, int column, int row, color clr)
static void CellTextColor(Table* table, int column, int row, uint clr)
{
if (table == NULL)
{
return;
}
table.CellTextColor(column, row, clr);
}
void CellTextColor(int column, int row, color clr)
void CellTextColor(int column, int row, uint clr)
{
Row* gridRow = _grid.GetRow(row);
LabelCell* cell = (LabelCell*)gridRow.GetCell(column);
Expand Down
9 changes: 9 additions & 0 deletions snippets/PineScript/Objects/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Objects

## LineFill

Line fill stub

## Table

Table object

0 comments on commit 9821a42

Please sign in to comment.