|
6 | 6 |
|
7 | 7 | #define GET_s_header_row SHeaderRow *s_header_row =(SHeaderRow *)self->s_border.s_compound_widget.s_widget.s_widget |
8 | 8 |
|
9 | | -static PyObject *ue_PySHeaderRow_str(ue_PySButton *self) |
| 9 | +static PyObject *ue_PySHeaderRow_str(ue_PySHeaderRow *self) |
10 | 10 | { |
11 | | - return PyUnicode_FromFormat("<unreal_engine.SButton '%p'>", |
| 11 | + return PyUnicode_FromFormat("<unreal_engine.SHeaderRow '%p'>", |
12 | 12 | self->s_border.s_compound_widget.s_widget.s_widget); |
13 | 13 | } |
14 | 14 |
|
| 15 | +static PyObject *py_ue_sheader_row_add_column(ue_PySHeaderRow *self, PyObject * args, PyObject *kwargs) { |
| 16 | + |
| 17 | + int cell_h_align = 0; |
| 18 | + int cell_v_align = 0; |
| 19 | + char *column_id; |
| 20 | + char *default_label = nullptr; |
| 21 | + char *default_tooltip = nullptr; |
| 22 | + float fill_width = 0; |
| 23 | + |
| 24 | + |
| 25 | + char *kwlist[] = { |
| 26 | + (char *)"column_id", |
| 27 | + (char *)"cell_h_align", |
| 28 | + (char *)"cell_v_align", |
| 29 | + (char *)"default_label", |
| 30 | + (char *)"default_tooltip", |
| 31 | + (char *)"fill_width", |
| 32 | + nullptr |
| 33 | + }; |
| 34 | + |
| 35 | + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|iissf:add_column", kwlist, |
| 36 | + &column_id, |
| 37 | + &cell_h_align, |
| 38 | + &cell_v_align, |
| 39 | + &default_label, |
| 40 | + &default_tooltip, |
| 41 | + &fill_width)) { |
| 42 | + return NULL; |
| 43 | + } |
| 44 | + |
| 45 | + if (!default_label) |
| 46 | + default_label = column_id; |
| 47 | + |
| 48 | + if (!default_tooltip) |
| 49 | + default_tooltip = default_label; |
| 50 | + |
| 51 | + auto &column = SHeaderRow::Column(FName(UTF8_TO_TCHAR(column_id))) |
| 52 | + .DefaultLabel(FText::FromString(UTF8_TO_TCHAR(default_label))) |
| 53 | + .DefaultTooltip(FText::FromString(UTF8_TO_TCHAR(default_tooltip))) |
| 54 | + .HAlignCell((EHorizontalAlignment)cell_h_align) |
| 55 | + .VAlignCell((EVerticalAlignment)cell_v_align); |
| 56 | + |
| 57 | + if (fill_width) |
| 58 | + column.FillWidth(fill_width); |
| 59 | + |
| 60 | + |
| 61 | + GET_s_header_row; |
| 62 | + |
| 63 | + s_header_row->AddColumn(column); |
| 64 | + |
| 65 | + |
| 66 | + Py_INCREF(self); |
| 67 | + return (PyObject *)self; |
| 68 | +} |
15 | 69 |
|
16 | 70 | static PyMethodDef ue_PySHeaderRow_methods[] = { |
| 71 | +#pragma warning(suppress: 4191) |
| 72 | + { "add_column", (PyCFunction)py_ue_sheader_row_add_column, METH_VARARGS | METH_KEYWORDS, "" }, |
17 | 73 | { NULL } /* Sentinel */ |
18 | 74 | }; |
19 | 75 |
|
@@ -54,11 +110,11 @@ static int ue_py_sheader_row_init(ue_PySHeaderRow *self, PyObject *args, PyObjec |
54 | 110 | } |
55 | 111 |
|
56 | 112 | void ue_python_init_sheader_row(PyObject *ue_module) { |
57 | | - ue_PySButtonType.tp_new = PyType_GenericNew; |
| 113 | + ue_PySHeaderRowType.tp_new = PyType_GenericNew; |
58 | 114 |
|
59 | | - ue_PySButtonType.tp_init = (initproc)ue_py_sheader_row_init; |
| 115 | + ue_PySHeaderRowType.tp_init = (initproc)ue_py_sheader_row_init; |
60 | 116 |
|
61 | | - ue_PySButtonType.tp_base = &ue_PySBorderType; |
| 117 | + ue_PySHeaderRowType.tp_base = &ue_PySBorderType; |
62 | 118 |
|
63 | 119 | if (PyType_Ready(&ue_PySHeaderRowType) < 0) |
64 | 120 | return; |
|
0 commit comments