Рабочая версия на основе IUP библиотеки
This commit is contained in:
commit
acc51dfcfa
|
@ -0,0 +1,4 @@
|
|||
/Debug
|
||||
/.settings
|
||||
.project
|
||||
.cproject
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* arguments.c
|
||||
*
|
||||
* Created on: 6 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "arguments.h"
|
||||
|
||||
void settingsLoad()
|
||||
{
|
||||
settingsAddKey(PARAMETER_XFREERDP, "xfreerdp", false, true);
|
||||
settingsAddKey(PARAMETER_SERVER, "/v:", true, true);
|
||||
settingsAddKey(PARAMETER_USERNAME, "/u:", true, true);
|
||||
settingsAddKey(PARAMETER_PASSWORD, "/p:", true, true);
|
||||
settingsAddKey(PARAMETER_MULTIMONITOR, "/multimon", false, true);
|
||||
settingsAddKey(PARAMETER_FULLSCREEN, "/f", false, true);
|
||||
}
|
||||
|
||||
Arguments *buildArguments()
|
||||
{
|
||||
Arguments *args = (Arguments *)malloc(sizeof(Arguments));
|
||||
args->argc = settings.countEnable;
|
||||
args->argv = (char **)malloc(sizeof(char *) * settings.countEnable);
|
||||
Node *head = settings.next;
|
||||
|
||||
for (size_t i = 0; i < settings.countEnable; head = head->next)
|
||||
{
|
||||
if (head->enable)
|
||||
{
|
||||
if (head->data->isValue)
|
||||
{
|
||||
args->argv[i++] = head->data->fullArgument;
|
||||
}
|
||||
else
|
||||
{
|
||||
args->argv[i++] = head->data->key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
void freeArguments()
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* arguments.h
|
||||
*
|
||||
* Created on: 6 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#ifndef ARGUMENTS_H_
|
||||
#define ARGUMENTS_H_
|
||||
|
||||
#include "node_settings.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int argc;
|
||||
char **argv;
|
||||
} Arguments;
|
||||
|
||||
void settingsLoad();
|
||||
Arguments *buildArguments();
|
||||
void freeArguments();
|
||||
|
||||
#endif /* ARGUMENTS_H_ */
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* concat.c
|
||||
*
|
||||
* Created on: 6 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#include "concat.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char* concat(char *s1, char *s2)
|
||||
{
|
||||
size_t len1 = s1 ? strlen(s1) : 0;
|
||||
size_t len2 = s2 ? strlen(s2) : 0;
|
||||
|
||||
char *result = malloc(len1 + len2 + 1);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
fprintf(stderr, "malloc() failed: insufficient memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (s1)
|
||||
{
|
||||
memcpy(result, s1, len1);
|
||||
}
|
||||
if (s2)
|
||||
{
|
||||
memcpy(result + len1, s2, len2 + 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* concat.h
|
||||
*
|
||||
* Created on: 6 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#ifndef CONCAT_H_
|
||||
#define CONCAT_H_
|
||||
|
||||
char* concat(char *s1, char *s2);
|
||||
|
||||
#endif /* CONCAT_H_ */
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
* gui.c
|
||||
*
|
||||
* Created on: 6 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gui.h"
|
||||
#include "settings.h"
|
||||
#include "node_settings.h"
|
||||
#include "images.h"
|
||||
#include "arguments.h"
|
||||
|
||||
static int guiExit(Ihandle *self)
|
||||
{
|
||||
return IUP_CLOSE;
|
||||
}
|
||||
|
||||
static int guiConnect(Ihandle *self)
|
||||
{
|
||||
settingsSetValue(PARAMETER_SERVER, IupGetAttribute(IupGetDialogChild(self, "SERVER"), "LINEVALUE"));
|
||||
settingsSetValue(PARAMETER_USERNAME, IupGetAttribute(IupGetDialogChild(self, "USER"), "LINEVALUE"));
|
||||
settingsSetValue(PARAMETER_PASSWORD, IupGetAttribute(IupGetDialogChild(self, "PASSWORD"), "LINEVALUE"));
|
||||
|
||||
Arguments *args = buildArguments();
|
||||
for (int i = 0; i < args->argc; ++i)
|
||||
{
|
||||
printf("%s\n", args->argv[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
|
||||
// char *program = "xfreerdp";
|
||||
// char *domain = "/d:agrohold";
|
||||
// char *certignore = "/cert-ignore";
|
||||
//
|
||||
// char **argv = (char**) malloc(sizeof(char*) * 8);
|
||||
//
|
||||
// argv[0] = program;
|
||||
// argv[1] = server;
|
||||
// argv[2] = domain;
|
||||
// argv[3] = user;
|
||||
// argv[4] = password;
|
||||
// argv[5] = certignore;
|
||||
//
|
||||
// Ihandle *child = IupGetDialogChild(self, "SETTINGS_WINDOW");
|
||||
//
|
||||
// if (!strcmp(IupGetAttribute(IupGetDialogChild(child, "SETTINGS_FULLSCREEN"), "VALUE"), "ON"))
|
||||
// {
|
||||
// argv[6] = "/f\0";
|
||||
// }
|
||||
//
|
||||
// if (!strcmp(IupGetAttribute(IupGetDialogChild(child, "SETTINGS_MULTIMONITOR"), "VALUE"), "ON"))
|
||||
// {
|
||||
// argv[7] = "/multimon\0";
|
||||
// }
|
||||
//
|
||||
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
Ihandle* guiStart()
|
||||
{
|
||||
Ihandle *dlg;
|
||||
Ihandle *icon, *bgHead;
|
||||
Ihandle *vBoxMain, *hBoxServer, *hBoxUser, *hBoxPassword, *hBoxButtons; // Boxes
|
||||
Ihandle *labelImage;
|
||||
Ihandle *labelServer, *inputServer;
|
||||
Ihandle *labelUser, *inputUser;
|
||||
Ihandle *labelPassword, *inputPassword;
|
||||
Ihandle *btnConnect, *btnClose, *btnSettings;
|
||||
|
||||
icon = IupImageRGBA(64, 64, idata_icon);
|
||||
IupSetHandle("icon", icon);
|
||||
|
||||
labelImage = IupLabel(NULL);
|
||||
|
||||
bgHead = IupImageRGBA(405, 72, idata_head);
|
||||
IupSetAttributeHandle(labelImage, "IMAGE", bgHead);
|
||||
|
||||
labelServer = IupLabel("Компьютер:");
|
||||
IupSetAttribute(labelServer, "SIZE", "80x16");
|
||||
// IupSetAttribute(labelServer, "FONT", "Helvetica, 14");
|
||||
IupSetAttribute(labelServer, "ALIGNMENT", "ARIGHT:ACENTER");
|
||||
IupSetAttribute(labelServer, "PADDING", "5");
|
||||
inputServer = IupText(NULL);
|
||||
IupSetAttribute(inputServer, "NAME", "SERVER");
|
||||
// IupSetAttribute(inputServer, "BORDER", "NO");
|
||||
IupSetAttribute(inputServer, "SIZE", "100");
|
||||
// IupSetAttribute(inputServer, "PADDING", "10x");
|
||||
hBoxServer = IupHbox(labelServer, inputServer, NULL);
|
||||
IupSetAttribute(hBoxServer, "MARGIN", "10x10");
|
||||
|
||||
labelUser = IupLabel("Пользователь:");
|
||||
IupSetAttribute(labelUser, "SIZE", "80x16");
|
||||
IupSetAttribute(labelUser, "ALIGNMENT", "ARIGHT:ACENTER");
|
||||
IupSetAttribute(labelUser, "PADDING", "5");
|
||||
inputUser = IupText(NULL);
|
||||
IupSetAttribute(inputUser, "NAME", "USER");
|
||||
IupSetAttribute(inputUser, "SIZE", "100");
|
||||
// IupSetAttribute(inputUser, "PADDING", "10x10");
|
||||
hBoxUser = IupHbox(labelUser, inputUser, NULL);
|
||||
IupSetAttribute(hBoxUser, "MARGIN", "10x0");
|
||||
|
||||
labelPassword = IupLabel("Пароль:");
|
||||
IupSetAttribute(labelPassword, "SIZE", "80x16");
|
||||
IupSetAttribute(labelPassword, "ALIGNMENT", "ARIGHT:ACENTER");
|
||||
IupSetAttribute(labelPassword, "PADDING", "5");
|
||||
inputPassword = IupText(NULL);
|
||||
IupSetAttribute(inputPassword, "SIZE", "100");
|
||||
// IupSetAttribute(inputPassword, "PADDING", "10x10");
|
||||
IupSetAttribute(inputPassword, "NAME", "PASSWORD");
|
||||
IupSetAttribute(inputPassword, "PASSWORD", "YES");
|
||||
hBoxPassword = IupHbox(labelPassword, inputPassword, NULL);
|
||||
IupSetAttribute(hBoxPassword, "MARGIN", "10x10");
|
||||
|
||||
btnConnect = IupButton("Подключение", NULL);
|
||||
IupSetHandle("CONNECT", btnConnect);
|
||||
IupSetAttribute(btnConnect, "NAME", "CONNECT");
|
||||
btnClose = IupButton("Закрыть", NULL);
|
||||
IupSetHandle("CLOSE", btnClose);
|
||||
IupSetAttribute(btnClose, "NAME", "CLOSE");
|
||||
btnSettings = IupButton("Настройки", NULL);
|
||||
IupSetAttribute(btnSettings, "NAME", "SETTINGS");
|
||||
hBoxButtons = IupHbox(IupFill(), btnConnect, btnClose, btnSettings, IupFill(), NULL);
|
||||
IupSetAttribute(hBoxButtons, "ALIGNMENT", "ACENTER:ACENTER");
|
||||
IupSetAttribute(hBoxButtons, "GAP", "10");
|
||||
IupSetAttribute(hBoxButtons, "MARGIN", "10x10");
|
||||
|
||||
vBoxMain = IupVbox(labelImage, hBoxServer, hBoxUser, hBoxPassword, hBoxButtons, NULL);
|
||||
|
||||
IupSetCallback(btnConnect, "ACTION", (Icallback) guiConnect);
|
||||
IupSetCallback(btnClose, "ACTION", (Icallback) guiExit);
|
||||
IupSetCallback(btnSettings, "ACTION", (Icallback) settingsWindow);
|
||||
|
||||
dlg = IupDialog(vBoxMain);
|
||||
IupSetAttribute(dlg, "IMAGE", "BG_HEAD");
|
||||
IupSetAttribute(dlg, "ICON", "icon");
|
||||
IupSetAttribute(dlg, "TITLE", "GUI FreeRDP");
|
||||
IupSetAttribute(dlg, "RESIZE", "NO");
|
||||
IupSetAttribute(dlg, "PARENTDIALOG", "MAIN_WINDOW");
|
||||
IupSetAttribute(dlg, "DEFAULTENTER", "CONNECT");
|
||||
IupSetAttribute(dlg, "DEFAULTESC", "CLOSE");
|
||||
|
||||
return dlg;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* gui.h
|
||||
*
|
||||
* Created on: 6 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#ifndef GUI_H_
|
||||
#define GUI_H_
|
||||
|
||||
#include <iup.h>
|
||||
|
||||
Ihandle* guiStart();
|
||||
|
||||
#endif /* GUI_H_ */
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* image.h
|
||||
*
|
||||
* Created on: 5 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#ifndef IMAGE_H_
|
||||
#define IMAGE_H_
|
||||
|
||||
extern const unsigned char idata_head[];
|
||||
extern const unsigned char idata_icon[];
|
||||
|
||||
#endif /* IMAGE_H_ */
|
|
@ -0,0 +1,20 @@
|
|||
#include <stdlib.h>
|
||||
#include "gui.h"
|
||||
#include "node_settings.h"
|
||||
#include "arguments.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
settingsLoad();
|
||||
|
||||
IupOpen(&argc, &argv);
|
||||
|
||||
IupShowXY(guiStart(), IUP_CENTER, IUP_CENTER);
|
||||
IupMainLoop();
|
||||
|
||||
IupClose();
|
||||
|
||||
settingsFree();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* node_settings.c
|
||||
*
|
||||
* Created on: 6 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "node_settings.h"
|
||||
#include "concat.h"
|
||||
|
||||
HeadNode settings = {0, 0, NULL};
|
||||
|
||||
static Node* settingsCreateNode()
|
||||
{
|
||||
Node *node = (Node*) malloc(sizeof(Node));
|
||||
node->parameter = PARAMETER_NULL;
|
||||
node->next = NULL;
|
||||
node->data = (SettingsData*)malloc(sizeof(SettingsData));
|
||||
node->data->key = NULL;
|
||||
node->data->value = NULL;
|
||||
node->data->fullArgument = NULL;
|
||||
return node;
|
||||
}
|
||||
|
||||
/*
|
||||
* Если передан параметр PARAMETER_NULL, то возвращается последний действующий узел.
|
||||
* Если возврат NULL, то ни одного узла не существует.
|
||||
* Если передан параметр отличный от PARAMETER_NULL, то ищется существующий узел с этим параметром.
|
||||
* Если возврат NULL, то узла с таким параметром не найдено.
|
||||
*/
|
||||
Node *settingsGetNode(SettingsParameters parameter)
|
||||
{
|
||||
if (!settings.countAll)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Node *head = settings.next;
|
||||
|
||||
if (parameter == PARAMETER_NULL)
|
||||
{
|
||||
while (head->next)
|
||||
{
|
||||
head = head->next;
|
||||
}
|
||||
return head;
|
||||
}
|
||||
|
||||
for (; head; head = head->next)
|
||||
{
|
||||
if (head->parameter == parameter)
|
||||
{
|
||||
return head;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void settingsAddKey(SettingsParameters parameter, char *key, bool isValue, bool enable)
|
||||
{
|
||||
Node *newNode = settingsCreateNode();
|
||||
newNode->parameter = parameter;
|
||||
newNode->enable = enable;
|
||||
|
||||
SettingsData *data = newNode->data;
|
||||
data->isValue = isValue;
|
||||
size_t len = strlen(key);
|
||||
|
||||
data->key = (char *) malloc(sizeof(char) * (len + 1));
|
||||
memcpy(data->key, key, len);
|
||||
|
||||
Node *lastNode = settingsGetNode(PARAMETER_NULL);
|
||||
if (lastNode)
|
||||
{
|
||||
lastNode->next = newNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.next = newNode;
|
||||
}
|
||||
|
||||
if (enable)
|
||||
{
|
||||
++settings.countEnable;
|
||||
}
|
||||
++settings.countAll;
|
||||
}
|
||||
|
||||
void settingsSetValue(SettingsParameters parameter, char *value)
|
||||
{
|
||||
Node *currentNode = settingsGetNode(parameter);
|
||||
if (!currentNode || !currentNode->data->isValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strlen(value))
|
||||
{
|
||||
settingsSetEnable(parameter, false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsSetEnable(parameter, true);
|
||||
}
|
||||
|
||||
SettingsData *data = currentNode->data;
|
||||
if (data->value)
|
||||
{
|
||||
free(data->value);
|
||||
}
|
||||
if (data->fullArgument)
|
||||
{
|
||||
free(data->fullArgument);
|
||||
}
|
||||
size_t len = strlen(value);
|
||||
|
||||
data->value = (char *) malloc(sizeof(char) * (len + 1));
|
||||
memcpy(data->value, value, len);
|
||||
data->fullArgument = concat(data->key, value);
|
||||
}
|
||||
|
||||
void settingsSetEnable(SettingsParameters parameter, bool enable)
|
||||
{
|
||||
Node *currentNode = settingsGetNode(parameter);
|
||||
if (!currentNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (currentNode->enable && !enable)
|
||||
{
|
||||
--settings.countEnable;
|
||||
}
|
||||
else if (!currentNode->enable && enable)
|
||||
{
|
||||
++settings.countEnable;
|
||||
}
|
||||
currentNode->enable = enable;
|
||||
}
|
||||
|
||||
void settingsToggleEnable(SettingsParameters parameter)
|
||||
{
|
||||
Node *currentNode = settingsGetNode(parameter);
|
||||
if (!currentNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (currentNode->enable)
|
||||
{
|
||||
--settings.countEnable;
|
||||
}
|
||||
else
|
||||
{
|
||||
++settings.countEnable;
|
||||
}
|
||||
currentNode->enable = !currentNode->enable;
|
||||
}
|
||||
|
||||
bool settingsGetEnable(SettingsParameters parameter)
|
||||
{
|
||||
Node *currentNode = settingsGetNode(parameter);
|
||||
if (!currentNode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return currentNode->enable;
|
||||
}
|
||||
|
||||
static void settingsFreeData(SettingsData *data)
|
||||
{
|
||||
if (data->key)
|
||||
{
|
||||
free(data->key);
|
||||
}
|
||||
if (data->value)
|
||||
{
|
||||
free(data->value);
|
||||
}
|
||||
if (data->fullArgument)
|
||||
{
|
||||
free(data->fullArgument);
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
|
||||
void settingsFree()
|
||||
{
|
||||
if (!settings.countAll)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Node *head = settings.next;
|
||||
Node *current = NULL;
|
||||
|
||||
while (head->next)
|
||||
{
|
||||
current = head->next;
|
||||
settingsFreeData(head->data);
|
||||
free(head);
|
||||
head = current;
|
||||
}
|
||||
|
||||
settingsFreeData(head->data);
|
||||
free(head);
|
||||
|
||||
settings.next = NULL;
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* node_settings.h
|
||||
*
|
||||
* Created on: 6 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#ifndef NODE_SETTINGS_H_
|
||||
#define NODE_SETTINGS_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PARAMETER_NULL, PARAMETER_XFREERDP, PARAMETER_USERNAME, PARAMETER_SERVER, PARAMETER_PASSWORD, PARAMETER_MULTIMONITOR, PARAMETER_FULLSCREEN
|
||||
} SettingsParameters;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *key;
|
||||
char *value;
|
||||
char *fullArgument;
|
||||
bool isValue;
|
||||
} SettingsData;
|
||||
|
||||
typedef struct Node
|
||||
{
|
||||
SettingsParameters parameter;
|
||||
bool enable;
|
||||
SettingsData *data;
|
||||
struct Node *next;
|
||||
} Node;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t countAll;
|
||||
size_t countEnable;
|
||||
struct Node *next;
|
||||
} HeadNode;
|
||||
|
||||
extern HeadNode settings;
|
||||
|
||||
/*
|
||||
* Работа с Node
|
||||
*/
|
||||
|
||||
Node *settingsGetNode(SettingsParameters parameter);
|
||||
void settingsAddKey(SettingsParameters parameter, char *key, bool isValue, bool enable);
|
||||
void settingsSetValue(SettingsParameters parameter, char *value);
|
||||
void settingsSetEnable(SettingsParameters parameter, bool enable);
|
||||
void settingsToggleEnable(SettingsParameters parameter);
|
||||
bool settingsGetEnable(SettingsParameters parameter);
|
||||
void settingsFree();
|
||||
|
||||
#endif /* SETTINGS_H_ */
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* settings.c
|
||||
*
|
||||
* Created on: 6 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#include <iup.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "settings.h"
|
||||
#include "arguments.h"
|
||||
|
||||
static int settingsClose(Ihandle *bt_close)
|
||||
{
|
||||
IupSetAttribute(IupGetDialog(bt_close), "SIMULATEMODAL", "OFF");
|
||||
IupHide(IupGetDialog(bt_close));
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsSave(Ihandle *self)
|
||||
{
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglMultimonitor(Ihandle *self)
|
||||
{
|
||||
settingsToggleEnable(PARAMETER_MULTIMONITOR);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglFullscreen(Ihandle *self)
|
||||
{
|
||||
settingsToggleEnable(PARAMETER_FULLSCREEN);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
int settingsWindow(Ihandle *self)
|
||||
{
|
||||
Ihandle *dlg;
|
||||
Ihandle *vBoxMain, *hBoxToggles, *hSettingsBoxButtons;
|
||||
Ihandle *btnSettingsClose, *btnSettingsSave;
|
||||
Ihandle *tglMultimonitor, *tglFullscreen;
|
||||
|
||||
tglMultimonitor = IupToggle("Мультиэкран", NULL);
|
||||
IupSetAttribute(tglMultimonitor, "VALUE", (settingsGetEnable(PARAMETER_MULTIMONITOR) ? "ON" : "OFF"));
|
||||
IupSetAttribute(tglMultimonitor, "NAME", "SETTINGS_MULTIMONITOR");
|
||||
tglFullscreen = IupToggle("На весь экран", NULL);
|
||||
IupSetAttribute(tglFullscreen, "NAME", "SETTINGS_FULLSCREEN");
|
||||
IupSetAttribute(tglFullscreen, "VALUE", (settingsGetEnable(PARAMETER_FULLSCREEN) ? "ON" : "OFF"));
|
||||
hBoxToggles = IupHbox(IupFill(), tglFullscreen, tglMultimonitor, IupFill(), NULL);
|
||||
IupSetAttribute(hBoxToggles, "GAP", "10");
|
||||
IupSetAttribute(hBoxToggles, "MARGIN", "10x10");
|
||||
|
||||
btnSettingsSave = IupButton("Сохранить", NULL);
|
||||
IupSetAttribute(btnSettingsSave, "NAME", "SETTIGS_SAVE");
|
||||
btnSettingsClose = IupButton("Закрыть", NULL);
|
||||
IupSetHandle("SETTIGS_CLOSE", btnSettingsClose);
|
||||
IupSetAttribute(btnSettingsClose, "NAME", "SETTIGS_CLOSE");
|
||||
hSettingsBoxButtons = IupHbox(IupFill(), btnSettingsClose, btnSettingsSave, IupFill(), NULL);
|
||||
IupSetAttribute(hSettingsBoxButtons, "ALIGNMENT", "ACENTER:ACENTER");
|
||||
IupSetAttribute(hSettingsBoxButtons, "GAP", "10");
|
||||
IupSetAttribute(hSettingsBoxButtons, "MARGIN", "10x10");
|
||||
|
||||
vBoxMain = IupVbox(hBoxToggles, hSettingsBoxButtons, NULL);
|
||||
|
||||
dlg = IupDialog(vBoxMain);
|
||||
IupSetAttribute(dlg, "TITLE", "Настройки");
|
||||
IupSetAttribute(dlg, "ICON", "icon");
|
||||
IupSetAttribute(dlg, "DIALOGFRAME", "ON");
|
||||
IupSetAttribute(dlg, "SIMULATEMODAL", "ON");
|
||||
IupSetAttribute(dlg, "DEFAULTESC", "SETTIGS_CLOSE");
|
||||
IupSetAttribute(dlg, "TOPMOST", "YES");
|
||||
IupSetAttribute(dlg, "BRINGFRONT", "YES");
|
||||
IupSetAttribute(dlg, "NAME", "SETTINGS_WINDOW");
|
||||
|
||||
IupSetCallback(dlg, "CLOSE_CB", (Icallback) settingsClose);
|
||||
|
||||
// IupSetAttribute(dlg, "RESIZE", "NO");
|
||||
|
||||
IupSetCallback(btnSettingsClose, "ACTION", (Icallback) settingsClose);
|
||||
IupSetCallback(btnSettingsSave, "ACTION", (Icallback) settingsSave);
|
||||
IupSetCallback(tglFullscreen, "ACTION", (Icallback) settingsTglFullscreen);
|
||||
IupSetCallback(tglMultimonitor, "ACTION", (Icallback) settingsTglMultimonitor);
|
||||
|
||||
IupShowXY(dlg, IUP_CURRENT, IUP_CURRENT);
|
||||
|
||||
return IUP_DEFAULT;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* settings.h
|
||||
*
|
||||
* Created on: 6 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#ifndef SETTINGS_H_
|
||||
#define SETTINGS_H_
|
||||
|
||||
int settingsWindow(Ihandle *self);
|
||||
|
||||
#endif /* SETTINGS_H_ */
|
Loading…
Reference in New Issue