Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_SystemX11.cpp
| Show First 20 Lines • Show All 2,170 Lines • ▼ Show 20 Lines | public: | ||||
| uint button_text_offset_y; | uint button_text_offset_y; | ||||
| /* Construct a new DialogData with the default settings */ | /* Construct a new DialogData with the default settings */ | ||||
| DialogData() | DialogData() | ||||
| : width(640), | : width(640), | ||||
| height(175), | height(175), | ||||
| padding_x(10), | padding_x(10), | ||||
| padding_y(5), | padding_y(5), | ||||
| button_width(50), | button_width(130), | ||||
| button_height(24), | button_height(24), | ||||
| button_inset_x(10), | button_inset_x(10), | ||||
| button_border_size(1), | button_border_size(1), | ||||
| line_height(16) | line_height(16) | ||||
| { | { | ||||
| button_text_offset_y = button_height - line_height; | button_text_offset_y = button_height - line_height; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | static void split(const char *text, const char *seps, char ***str, int *count) | ||||
| *str = (char **)malloc((size_t)(*count) * sizeof(char *)); | *str = (char **)malloc((size_t)(*count) * sizeof(char *)); | ||||
| for (i = 0, tok = strtok(data, seps); tok != NULL; tok = strtok(NULL, seps), i++) | for (i = 0, tok = strtok(data, seps); tok != NULL; tok = strtok(NULL, seps), i++) | ||||
| (*str)[i] = strdup(tok); | (*str)[i] = strdup(tok); | ||||
| free(data); | free(data); | ||||
| } | } | ||||
| GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title, | GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title, | ||||
| const char *message, | const char *message, | ||||
| const char *help_label, | |||||
| const char *continue_label, | |||||
| const char *link, | const char *link, | ||||
| GHOST_DialogOptions) const | GHOST_DialogOptions) const | ||||
| { | { | ||||
| char **text_splitted = NULL; | char **text_splitted = NULL; | ||||
| int textLines = 0; | int textLines = 0; | ||||
| split(message, "\n", &text_splitted, &textLines); | split(message, "\n", &text_splitted, &textLines); | ||||
| DialogData dialog_data; | DialogData dialog_data; | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | if (e.type == Expose) { | ||||
| XDrawString(m_display, | XDrawString(m_display, | ||||
| window, | window, | ||||
| DefaultGC(m_display, screen), | DefaultGC(m_display, screen), | ||||
| dialog_data.padding_x, | dialog_data.padding_x, | ||||
| dialog_data.padding_x + (i + 1) * dialog_data.line_height, | dialog_data.padding_x + (i + 1) * dialog_data.line_height, | ||||
| text_splitted[i], | text_splitted[i], | ||||
| (int)strlen(text_splitted[i])); | (int)strlen(text_splitted[i])); | ||||
| } | } | ||||
| dialog_data.drawButton(m_display, window, buttonBorderGC, buttonGC, 1, "Ok"); | dialog_data.drawButton(m_display, window, buttonBorderGC, buttonGC, 1, continue_label); | ||||
| if (strlen(link)) { | if (strlen(link)) { | ||||
| dialog_data.drawButton(m_display, window, buttonBorderGC, buttonGC, 2, "Help"); | dialog_data.drawButton(m_display, window, buttonBorderGC, buttonGC, 2, help_label); | ||||
| } | } | ||||
| } | } | ||||
| else if (e.type == ButtonRelease) { | else if (e.type == ButtonRelease) { | ||||
| if (dialog_data.isInsideButton(e, 1)) { | if (dialog_data.isInsideButton(e, 1)) { | ||||
| break; | break; | ||||
| } | } | ||||
| else if (strlen(link) && dialog_data.isInsideButton(e, 2)) { | else if (dialog_data.isInsideButton(e, 2)) { | ||||
| if (strlen(link)) { | |||||
| string cmd = "xdg-open \"" + string(link) + "\""; | string cmd = "xdg-open \"" + string(link) + "\""; | ||||
| if (system(cmd.c_str()) != 0) { | if (system(cmd.c_str()) != 0) { | ||||
| GHOST_PRINTF("GHOST_SystemX11::showMessageBox: Unable to run system command [%s]", cmd); | GHOST_PRINTF("GHOST_SystemX11::showMessageBox: Unable to run system command [%s]", | ||||
| cmd); | |||||
| } | |||||
| } | } | ||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (int i = 0; i < textLines; i++) { | for (int i = 0; i < textLines; i++) { | ||||
| free(text_splitted[i]); | free(text_splitted[i]); | ||||
| } | } | ||||
| free(text_splitted); | free(text_splitted); | ||||
| ▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines | |||||