GUI-FreeRDP/gui.c

126 lines
4.5 KiB
C
Raw Permalink 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"
static int guiExit(Ihandle *self)
{
return IUP_CLOSE;
}
static int guiConnect(Ihandle *self)
{
setParameterValue(PARAMETER_SERVER, VALUE_SERVER, IupGetAttribute(IupGetDialogChild(self, "SERVER"), "LINEVALUE"));
setParameterValue(PARAMETER_USERNAME, 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, "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) 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;
}