GUI-FreeRDP/gui.c

148 lines
5.8 KiB
C
Raw Normal View History

/*
* 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"
#include "db.h"
static int guiExit(Ihandle *self)
{
return IUP_CLOSE;
}
static int guiConnect(Ihandle *self)
{
setParameterValue(PARAMETER_SERVER, VALUE_SERVER, IupGetAttribute(IupGetDialogChild(self, "SERVER"), "LINEVALUE"));
dbSetValueCurrent(VALUE_SERVER, IupGetAttribute(IupGetDialogChild(self, "SERVER"), "LINEVALUE"));
setParameterValue(PARAMETER_USERNAME, VALUE_USERNAME, IupGetAttribute(IupGetDialogChild(self, "USER"), "LINEVALUE"));
dbSetValueCurrent(VALUE_USERNAME, IupGetAttribute(IupGetDialogChild(self, "USER"), "LINEVALUE"));
setParameterValue(PARAMETER_PASSWORD, VALUE_PASSWORD, IupGetAttribute(IupGetDialogChild(self, "PASSWORD"), "LINEVALUE"));
Arguments args;
buildArguments(&args);
for (int i = 0; i < args.argc; ++i)
{
printf("%s\n", args.argv[i]);
}
printf("\n");
freeArguments(&args);
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, "TIP", "IP-адрес или имя удаленного сервера (обязательно)");
IupSetAttribute(inputServer, "VALUE", getSetValueCurrent(PARAMETER_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, "TIP", "<домен>\\<имя пользователя> (обязательно)");
IupSetAttribute(inputUser, "VALUE", getSetValueCurrent(PARAMETER_USERNAME));
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, "TIP", "Пароль пользователя (необязательно)");
IupSetAttribute(inputPassword, "VALUE", getSetValueCurrent(PARAMETER_PASSWORD));
IupSetAttribute(inputPassword, "PASSWORD", "YES");
hBoxPassword = IupHbox(labelPassword, inputPassword, NULL);
IupSetAttribute(hBoxPassword, "MARGIN", "10x10");
btnConnect = IupButton("Подключение", NULL);
IupSetHandle("CONNECT", btnConnect);
IupSetAttribute(btnConnect, "NAME", "CONNECT");
IupSetAttribute(btnConnect, "TIP", "Выполнить подключение");
IupSetAttribute(btnConnect, "BGCOLOR", "0 179 0");
IupSetAttribute(btnConnect, "FGCOLOR", "255 255 255");
btnClose = IupButton("Закрыть", NULL);
IupSetHandle("CLOSE", btnClose);
IupSetAttribute(btnClose, "NAME", "CLOSE");
IupSetAttribute(btnClose, "TIP", "Закрыть FreeRDP");
IupSetAttribute(btnClose, "BGCOLOR", "204 0 0");
IupSetAttribute(btnClose, "FGCOLOR", "255 255 255");
btnSettings = IupButton("Настройки", NULL);
IupSetAttribute(btnSettings, "NAME", "SETTINGS");
IupSetAttribute(btnSettings, "TIP", "Перейти в настройки");
IupSetAttribute(btnSettings, "BGCOLOR", "0 136 204");
IupSetAttribute(btnSettings, "FGCOLOR", "255 255 255");
hBoxButtons = IupHbox(IupFill(), btnSettings, btnConnect, btnClose, 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) settingsMainWindow);
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;
}