diff options
Diffstat (limited to 'iup/test')
55 files changed, 10269 insertions, 0 deletions
diff --git a/iup/test/bigtest.c b/iup/test/bigtest.c new file mode 100755 index 0000000..713e752 --- /dev/null +++ b/iup/test/bigtest.c @@ -0,0 +1,194 @@ +#if 0 +/* To check for memory leaks */ +#define VLD_MAX_DATA_DUMP 80 +#include <vld.h> +#endif + +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" +#include "iupcontrols.h" +#include "iupkey.h" + +/* Must define BIG_TEST on the Project and include in the build all test files */ +#ifdef BIG_TEST +void ButtonTest(void); +void CanvasScrollbarTest(void); +void CanvasTest(void); +void CanvasCDDBufferTest(void); +void CanvasCDSimpleTest(void); +void DialogTest(void); +void FrameTest(void); +void TabsTest(void); +void SysInfoTest(void); +void GetColorTest(void); +#ifdef USE_OPENGL +void GLCanvasTest(void); +void GLCanvasCubeTest(void); +#endif +void HboxTest(void); +void IdleTest(void); +void LabelTest(void); +void ListTest(void); +void MatrixTest(void); +void MatrixCbModeTest(void); +void MatrixCbsTest(void); +void MdiTest(void); +void VboxTest(void); +void MenuTest(void); +void ColorBrowserTest(void); +void ColorbarTest(void); +void CellsNumberingTest(void); +void DialTest(void); +void GaugeTest(void); +void CellsDegradeTest(void); +void CellsCheckboardTest(void); +void ValTest(void); +void TreeTest(void); +void TrayTest(void); +void ToggleTest(void); +void TimerTest(void); +void TextSpinTest(void); +void TextTest(void); +void SpinTest(void); +void SampleTest(void); +void ProgressbarTest(void); +void PreDialogsTest(void); +#ifdef PPLOT_TEST +void PPlotTest(void); +#endif +void GetParamTest(void); +void ConfTest(void); +void ZboxTest(void); +void ScanfTest(void); +void SboxTest(void); +void ClipboardTest(void); + +void HelpTest(void) +{ + IupHelp("http://www.tecgraf.puc-rio.br/iup"); + //IupHelp("..\\html\\index.html"); +} + +typedef struct _TestItems{ + char* title; + void (*func)(void); +}TestItems; + +static TestItems test_list[] = { + {"Button", ButtonTest}, + {"Canvas", CanvasTest}, + {"CanvasCDSimpleTest", CanvasCDSimpleTest}, + {"CanvasCDDBuffer", CanvasCDDBufferTest}, + {"CanvasScrollbar", CanvasScrollbarTest}, + {"CellsCheckboard", CellsCheckboardTest}, + {"CellsDegrade", CellsDegradeTest}, + {"CellsNumbering", CellsNumberingTest}, + {"Class Conference", ConfTest}, + {"Clipboard", ClipboardTest}, + {"ColorBrowser", ColorBrowserTest}, + {"Colorbar", ColorbarTest}, + {"Dial", DialTest}, + {"Dialog", DialogTest}, + {"Frame", FrameTest}, +#ifdef USE_OPENGL + {"GLCanvas", GLCanvasTest}, + {"GLCanvasCube", GLCanvasCubeTest}, +#endif + {"Gauge", GaugeTest}, + {"GetColor", GetColorTest}, + {"GetParam", GetParamTest}, + {"Help", HelpTest}, + {"Hbox", HboxTest}, + {"Idle", IdleTest}, + {"Label", LabelTest}, + {"List", ListTest}, + {"Matrix", MatrixTest}, + {"MatrixCbMode", MatrixCbModeTest}, + {"MatrixCbs", MatrixCbsTest}, + {"Mdi", MdiTest}, + {"Menu", MenuTest}, +#ifdef PPLOT_TEST + {"PPlot", PPlotTest}, +#endif + {"PreDialogs", PreDialogsTest}, + {"Progressbar", ProgressbarTest}, + {"Sample", SampleTest}, + {"Sbox", SboxTest}, + {"Scanf", ScanfTest}, + {"Spin", SpinTest}, + {"SysInfo", SysInfoTest}, + {"Tabs", TabsTest}, + {"Text", TextTest}, + {"TextSpin", TextSpinTest}, + {"Timer", TimerTest}, + {"Toggle", ToggleTest}, + {"Tray", TrayTest}, + {"Tree", TreeTest}, + {"Val", ValTest}, + {"Vbox", VboxTest}, + {"Zbox", ZboxTest}, +}; + +static int k_enter_cb(Ihandle*ih) +{ + int pos = IupGetInt(ih, "VALUE"); + if (pos > 0) + test_list[pos-1].func(); + return IUP_DEFAULT; +} + +static int button_cb(Ihandle *ih,int but,int pressed,int x,int y,char* status) +{ + (void)pressed; + if (but==IUP_BUTTON1 && iup_isdouble(status)) + { + int pos = IupConvertXYToPos(ih, x, y); + test_list[pos-1].func(); + return IUP_IGNORE; + } + return IUP_DEFAULT; +} + +static int close_cb(Ihandle *ih) +{ + (void)ih; + return IUP_CLOSE; +} + +int main(int argc, char* argv[]) +{ + int i, count = sizeof(test_list)/sizeof(TestItems); + char str[50]; + Ihandle *dlg, *list; + + IupOpen(&argc, &argv); + IupControlsOpen(); +// IupOldValOpen(); +// IupOldTabsOpen(); + + dlg = IupDialog(IupVbox(list = IupList(NULL), NULL)); + IupSetAttribute(dlg, "MARGIN", "10x10"); + IupSetAttribute(dlg, "TITLE", "IupTests"); + IupSetCallback(dlg, "CLOSE_CB", close_cb); + + IupSetAttribute(list, "VISIBLELINES", "15"); + IupSetAttribute(list, "EXPAND", "YES"); + IupSetCallback(list, "BUTTON_CB", (Icallback)button_cb); + IupSetCallback(list, "K_CR", k_enter_cb); + + for (i=0; i<count; i++) + { + sprintf(str, "%d", i+1); + IupSetAttribute(list, str, test_list[i].title); + } + + IupShowXY(dlg, 100, IUP_CENTER); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/button.c b/iup/test/button.c new file mode 100755 index 0000000..da2906d --- /dev/null +++ b/iup/test/button.c @@ -0,0 +1,411 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" +#include "iupkey.h" + +#define TEST_IMAGE_SIZE 20 + +static Ihandle* load_image_FileSave(void) +{ + unsigned char imgdata[] = { + 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 183, 182, 245, 255, 183, 182, 245, 255, 179, 178, 243, 255, 174, 173, 241, 255, 168, 167, 238, 255, 162, 161, 234, 255, 155, 154, 231, 255, 148, 147, 228, 255, 143, 142, 224, 255, 136, 135, 221, 255, 129, 128, 218, 255, 123, 122, 214, 255, 117, 116, 211, 255, 112, 111, 209, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 179, 178, 243, 255, 190, 189, 255, 255, 147, 146, 248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 75, 88, 190, 255, 89, 88, 176, 255, 89, 88, 176, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 173, 172, 240, 255, 190, 189, 255, 255, 138, 137, 239, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 234, 238, 246, 255, 63, 82, 184, 255, 51, 51, 103, 255, 86, 85, 170, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 167, 166, 237, 255, 190, 189, 255, 255, 129, 128, 230, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 234, 238, 246, 255, 222, 229, 240, 255, 52, 77, 179, 255, 122, 121, 223, 255, 83, 82, 164, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 159, 158, 233, 255, 190, 189, 255, 255, 119, 118, 220, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 234, 238, 246, 255, 222, 229, 240, 255, 210, 219, 234, 255, 40, 71, 173, 255, 114, 113, 215, 255, 80, 79, 159, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 152, 151, 229, 255, 190, 189, 255, 255, 110, 109, 211, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 234, 238, 246, 255, 222, 229, 240, 255, 210, 219, 234, 255, 198, 209, 229, 255, 28, 65, 167, 255, 103, 103, 204, 255, 77, 77, 154, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 146, 145, 226, 255, 190, 189, 255, 255, 103, 102, 204, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 234, 238, 246, 255, 222, 229, 240, 255, 210, 219, 234, 255, 198, 209, 229, 255, 189, 202, 225, 255, 17, 59, 161, 255, 92, 93, 194, 255, 74, 74, 148, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 139, 138, 223, 255, 188, 187, 255, 255, 183, 182, 255, 255, 96, 99, 201, 255, 86, 94, 196, 255, 75, 88, 190, 255, 63, 82, 184, 255, 52, 77, 179, 255, 40, 71, 173, 255, 28, 65, 167, 255, 17, 59, 161, 255, 92, 93, 193, 255, 84, 86, 186, 255, 71, 71, 143, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 132, 131, 219, 255, 180, 179, 255, 255, 174, 173, 255, 255, 164, 163, 252, 255, 143, 142, 244, 255, 135, 134, 236, 255, 129, 128, 230, 255, 122, 121, 223, 255, 114, 113, 215, 255, 108, 107, 209, 255, 92, 93, 193, 255, 84, 86, 186, 255, 76, 80, 178, 255, 68, 68, 137, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 124, 123, 215, 255, 170, 169, 255, 255, 160, 159, 251, 255, 148, 147, 245, 255, 75, 91, 113, 255, 75, 91, 113, 255, 75, 91, 113, 255, 75, 91, 113, 255, 82, 98, 118, 255, 91, 106, 125, 255, 84, 86, 186, 255, 76, 79, 178, 255, 68, 73, 170, 255, 65, 65, 131, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 118, 117, 212, 255, 160, 159, 255, 255, 145, 144, 245, 255, 135, 134, 236, 255, 75, 91, 113, 255, 0, 0, 0, 255, 52, 60, 71, 255, 206, 217, 233, 255, 212, 221, 236, 255, 103, 116, 133, 255, 67, 75, 174, 255, 68, 73, 170, 255, 60, 66, 163, 255, 62, 62, 125, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 112, 111, 209, 255, 154, 153, 255, 255, 135, 134, 236, 255, 129, 128, 230, 255, 75, 91, 113, 255, 52, 60, 71, 255, 104, 120, 141, 255, 216, 224, 237, 255, 224, 231, 241, 255, 115, 127, 143, 255, 53, 65, 163, 255, 60, 66, 162, 255, 53, 61, 156, 255, 60, 59, 120, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 108, 107, 207, 255, 143, 142, 243, 255, 129, 128, 230, 255, 36, 68, 170, 255, 33, 50, 71, 255, 171, 180, 195, 255, 179, 187, 198, 255, 188, 193, 202, 255, 196, 200, 206, 255, 72, 77, 86, 255, 51, 62, 158, 255, 54, 61, 156, 255, 49, 57, 152, 255, 57, 57, 114, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 108, 107, 207, 84, 101, 100, 195, 255, 86, 85, 170, 255, 83, 82, 164, 255, 80, 79, 159, 255, 77, 77, 154, 255, 74, 74, 148, 255, 71, 71, 143, 255, 68, 68, 137, 255, 65, 65, 131, 255, 60, 59, 120, 255, 60, 59, 120, 255, 57, 57, 114, 255, 55, 54, 110, 255, 255, 0, 255, 255, + 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255}; + + Ihandle* image = IupImageRGBA(16, 16, imgdata); + return image; +} + +static unsigned char image_data_8 [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE] = +{ + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +}; + +static unsigned char image_data_8_pressed [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE] = +{ + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,5,1,1,1,1,1,2,2,2,2,2,5,0,0,0,5, + 5,0,0,0,1,5,1,1,1,1,2,2,2,2,5,2,0,0,0,5, + 5,0,0,0,1,1,5,1,1,1,2,2,2,5,2,2,0,0,0,5, + 5,0,0,0,1,1,1,5,1,1,2,2,5,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,5,1,2,5,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,5,5,2,2,2,2,2,0,0,0,5, + 5,0,0,0,3,3,3,3,3,5,5,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,5,3,4,5,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,5,3,3,4,4,5,4,4,4,0,0,0,5, + 5,0,0,0,3,3,5,3,3,3,4,4,4,5,4,4,0,0,0,5, + 5,0,0,0,3,5,3,3,3,3,4,4,4,4,5,4,0,0,0,5, + 5,0,0,0,5,3,3,3,3,3,4,4,4,4,4,5,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +}; + +static unsigned char image_data_8_inactive [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE] = +{ + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,5,5,1,1,1,1,1,1,1,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,1,1,1,1,1,1,1,5,5,5,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +}; + +static unsigned char image_data_24 [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE*3] = +{ + 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, +}; + +static unsigned char image_data_32 [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE*4] = +{ + 000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255, +}; + +static char* get_name(Ihandle* ih) +{ + return IupGetAttribute(ih, "NAME"); +} + +static int action_cb(Ihandle *ih) +{ + printf("ACTION(%s)\n", get_name(ih)); + return IUP_DEFAULT; +} + +static int getfocus_cb(Ihandle *ih) +{ + printf("GETFOCUS_CB(%s)\n", get_name(ih)); + return IUP_DEFAULT; +} + +static int help_cb(Ihandle* ih) +{ + printf("HELP_CB(%s)\n", get_name(ih)); + return IUP_DEFAULT; +} + +static int killfocus_cb(Ihandle *ih) +{ + printf("KILLFOCUS_CB(%s)\n", get_name(ih)); + return IUP_DEFAULT; +} + +static int leavewindow_cb(Ihandle *ih) +{ + printf("LEAVEWINDOW_CB(%s)\n", get_name(ih)); + return IUP_DEFAULT; +} + +static int enterwindow_cb(Ihandle *ih) +{ + printf("ENTERWINDOW_CB(%s)\n", get_name(ih)); + return IUP_DEFAULT; +} + +static int button_cb(Ihandle *ih,int but,int pressed,int x,int y,char* status) +{ + printf("BUTTON_CB(%s, but=%c (%d), x=%d, y=%d [%s])\n", get_name(ih),(char)but,pressed,x,y, status); + return IUP_DEFAULT; +} + +char *iupKeyCodeToName(int code); + +static int k_any(Ihandle *ih, int c) +{ + if (iup_isprint(c)) + printf("K_ANY(%s, %d = %s \'%c\')\n", get_name(ih), c, iupKeyCodeToName(c), (char)c); + else + printf("K_ANY(%s, %d = %s)\n", get_name(ih), c, iupKeyCodeToName(c)); + printf(" MODKEYSTATE(%s)\n", IupGetGlobal("MODKEYSTATE")); + return IUP_DEFAULT; +} + +static int active_cb(Ihandle *ih) +{ + static int active = 1; + Ihandle* dlg = IupGetDialog(ih); + Ihandle* box = IupGetChild(dlg, 0); + if (active) + IupSetAttribute(box, "ACTIVE", "NO"); + else + IupSetAttribute(box, "ACTIVE", "YES"); + active = !active; + IupSetAttribute(ih, "ACTIVE", "YES"); + return IUP_DEFAULT; +} + +static void set_callbacks(Ihandle* button) +{ + IupSetCallback(button, "ACTION", action_cb); +// IupSetCallback(button, "BUTTON_CB", (Icallback)button_cb); + + IupSetCallback(button, "K_ANY", (Icallback)k_any); + IupSetCallback(button, "HELP_CB", (Icallback)help_cb); + +// IupSetCallback(button, "GETFOCUS_CB", (Icallback)getfocus_cb); +// IupSetCallback(button, "KILLFOCUS_CB", (Icallback)killfocus_cb); +// IupSetCallback(button, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); +// IupSetCallback(button, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); +} + +static int show_cb(Ihandle *ih, int state) +{ + char* state_str[5] ={ + "SHOW", + "RESTORE", + "MINIMIZE", + "MAXIMIZE", + "HIDE" + }; + printf("SHOW_CB(%s, %s)\n", IupGetAttribute(ih, "TESTTITLE"), state_str[state]); + return IUP_DEFAULT; +} + +void ButtonTest(void) +{ + Ihandle *dlg, *button, *label, *image1, *image1i, *image1p, *image2, *image3, + *box1, *box2; + + /* IupImageLibOpen(); */ + + box1 = IupVbox(NULL); + IupSetAttribute(box1, "MARGIN", "5x5"); + IupSetAttribute(box1, "GAP", "5"); +// IupSetAttribute(box1, "BGCOLOR", "75 150 170"); +// IupSetAttribute(box1, "PADDING", "15x15"); + + button = IupButton("ACTIVE", NULL); + IupSetAttribute(button, "TITLE", "Button Text"); + IupSetCallback(button, "ACTION", active_cb); + IupAppend(box1, button); + + button = IupButton(NULL, NULL); + IupSetAttribute(button, "TITLE", "Text (ηγν)"); +// IupSetAttribute(button, "TITLE", "Text"); + //IupSetAttribute(button, "TITLE", "Text &Button\nSecond Line"); + IupSetAttribute(button, "TIP", "Button Tip"); + //IupSetAttribute(button, "PADDING", "15x15"); + //IupSetAttribute(button, "BGCOLOR", "128 128 255"); + IupSetAttribute(button, "SIZE", "40"); +// IupSetAttribute(button, "FGCOLOR", "0 0 255"); +// IupSetAttribute(button, "RASTERSIZE", "200x100"); + IupSetAttribute(button, "ALIGNMENT", "ACENTER:ACENTER"); +// IupSetAttribute(button, "ALIGNMENT", "ALEFT:ATOP"); + IupSetAttribute(button, "NAME", "button1"); + set_callbacks(button); + IupAppend(box1, button); + + button = IupButton(NULL, NULL); + IupSetAttribute(button, "TITLE", "Text Button\nSecond Line"); + IupSetAttribute(button, "RASTERSIZE", "200x100"); + IupSetAttribute(button, "ALIGNMENT", "ACENTER:ACENTER"); + IupSetAttribute(button, "FONT", "Helvetica, 14"); + IupSetAttribute(button, "FLAT", "YES"); + IupSetAttribute(button, "NAME", "button2"); + set_callbacks(button); + IupAppend(box1, button); + + button = IupButton(NULL, NULL); + IupSetAttribute(button, "TITLE", "Text Button\n<b>Second Line</b>"); + IupSetAttribute(button, "RASTERSIZE", "200x100"); + IupSetAttribute(button, "ALIGNMENT", "ARIGHT:ABOTTOM"); + IupSetAttribute(button, "MARKUP", "YES"); + IupSetAttribute(button, "NAME", "button3"); + IupSetAttribute(button, "CANFOCUS", "NO"); + set_callbacks(button); + IupAppend(box1, button); + + box2 = IupVbox(NULL); + IupSetAttribute(box2, "MARGIN", "5x5"); + IupSetAttribute(box2, "GAP", "5"); +// IupSetAttribute(box2, "BGCOLOR", "75 150 170"); +// IupSetAttribute(box2, "PADDING", "15x15"); + + image1 = IupImage(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_8); + IupSetAttribute(image1, "0", "BGCOLOR"); + IupSetAttribute(image1, "1", "255 0 0"); + IupSetAttribute(image1, "2", "0 255 0"); + IupSetAttribute(image1, "3", "0 0 255"); + IupSetAttribute(image1, "4", "255 255 255"); + IupSetAttribute(image1, "5", "0 0 0"); + + image1i = IupImage(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_8_inactive); + IupSetAttribute(image1i, "0", "BGCOLOR"); + IupSetAttribute(image1i, "1", "255 0 0"); + IupSetAttribute(image1i, "2", "0 255 0"); + IupSetAttribute(image1i, "3", "0 0 255"); + IupSetAttribute(image1i, "4", "255 255 255"); + IupSetAttribute(image1i, "5", "0 0 0"); + + image1p = IupImage(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_8_pressed); + IupSetAttribute(image1p, "0", "BGCOLOR"); + IupSetAttribute(image1p, "1", "255 0 0"); + IupSetAttribute(image1p, "2", "0 255 0"); + IupSetAttribute(image1p, "3", "0 0 255"); + IupSetAttribute(image1p, "4", "255 255 255"); + IupSetAttribute(image1p, "5", "0 0 0"); + + image2 = IupImageRGB(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_24); + + image3 = IupImageRGBA(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_32); + + button = IupButton(NULL, NULL); + IupSetAttribute(button, "TITLE", "Images"); + IupSetAttributeHandle(button, "IMAGE", load_image_FileSave()); + IupAppend(box2, button); + + button = IupButton(NULL, NULL); +// IupSetAttribute(button, "ALIGNMENT", "ALEFT:ATOP"); +// IupSetAttribute(button, "RASTERSIZE", "200x100"); +// IupSetAttribute(button, "IMAGEPOSITION", "BOTTOM"); + IupSetAttribute(button, "PADDING", "5x5"); +// IupSetAttribute(button, "TITLE", "Text1"); + IupSetAttribute(button, "FONT", "Helvetica, 14"); +// IupSetAttribute(button, "IMAGE", "IUP_Tecgraf"); + IupSetAttributeHandle(button, "IMAGE", image1); +// IupSetAttributeHandle(button, "IMINACTIVE", image1i); +// IupSetAttributeHandle(button, "XXX__IMPRESS", image1p); + IupSetAttribute(button, "TIP", "Image Label"); + IupSetAttribute(button, "NAME", "button4"); + set_callbacks(button); + IupAppend(box2, button); + + button = IupButton(NULL, NULL); + IupSetAttributeHandle(button, "IMAGE", image2); + IupSetAttribute(button, "TITLE", "Text2"); +// IupSetAttribute(button, "IMAGEPOSITION", "TOP"); +// IupSetAttribute(button, "SPACING", "30"); +// IupSetAttribute(button, "ALIGNMENT", "ALEFT"); +// IupSetAttribute(button, "RASTERSIZE", "200x100"); + IupSetAttribute(button, "FLAT", "YES"); + IupSetAttribute(button, "FOCUSONCLICK", "NO"); + IupSetAttribute(button, "NAME", "button5"); + set_callbacks(button); + IupAppend(box2, button); + + button = IupButton(NULL, NULL); + IupSetAttributeHandle(button, "IMAGE", image3); + IupSetAttribute(button, "TITLE", "Text3"); +// IupSetAttribute(button, "RASTERSIZE", "200x100"); +// IupSetAttribute(button, "ALIGNMENT", "ARIGHT"); + IupSetAttribute(button, "NAME", "button6"); + set_callbacks(button); + IupAppend(box2, button); + + label = IupLabel(NULL); + IupSetAttribute(label, "SEPARATOR", "VERTICAL"); + + dlg = IupDialog(IupHbox(box1, label, box2, NULL)); + IupSetAttribute(dlg, "TITLE", "IupButton Test"); +// IupSetAttribute(box1, "BGCOLOR", "128 0 0"); +// IupSetAttribute(dlg, "BGCOLOR", "0 128 0"); +// IupSetAttribute(dlg, "BACKGROUND", "0 0 128"); +// IupSetAttributeHandle(dlg, "BACKGROUND", image2); + + IupSetAttributeHandle(dlg, "STARTFOCUS", button); + + IupShow(dlg); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + ButtonTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/canvas.c b/iup/test/canvas.c new file mode 100755 index 0000000..d13945c --- /dev/null +++ b/iup/test/canvas.c @@ -0,0 +1,346 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" +#include "iupkey.h" + +static unsigned char matrx_img_cur_excel[15*15] = + { + 0,0,0,0,1,1,1,1,1,1,0,0,0,0,0, + 0,0,0,0,1,2,2,2,2,1,1,0,0,0,0, + 0,0,0,0,1,2,2,2,2,1,1,0,0,0,0, + 0,0,0,0,1,2,2,2,2,1,1,0,0,0,0, + 1,1,1,1,1,2,2,2,2,1,1,1,1,1,0, + 1,2,2,2,2,2,2,2,2,2,2,2,2,1,1, + 1,2,2,2,2,2,2,2,2,2,2,2,2,1,1, + 1,2,2,2,2,2,2,2,2,2,2,2,2,1,1, + 1,1,1,1,1,2,2,2,2,1,1,1,1,1,1, + 0,1,1,1,1,2,2,2,2,1,1,1,1,1,1, + 0,0,0,0,1,2,2,2,2,1,1,0,0,0,0, + 0,0,0,0,1,2,2,2,2,1,1,0,0,0,0, + 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0, + 0,0,0,0,0,1,1,1,1,1,1,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + }; + +static unsigned char pixmap_cursor [ ] = +{ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,2,2,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,2,0,0,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +} ; + +//#define USE_GTK + +/* draw a rectangle that has w=600 always, white background and a red X */ +#ifdef USE_GTK +#include <gtk/gtk.h> +static void drawTest(Ihandle *ih, int posx) +{ + GtkWidget* widget = (GtkWidget*)IupGetAttribute(ih, "WID"); + gdk_draw_arc (widget->window, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + TRUE, + 0, 0, widget->allocation.width, widget->allocation.height, + 0, 64 * 360); +} +#else +#ifdef WIN32 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0500 +#include <windows.h> +static void drawTest(Ihandle *ih, int posx) +{ + RECT rect; + int w, h; + HWND hWnd = (HWND)IupGetAttribute(ih, "HWND"); + HDC hDC = GetDC(hWnd); + + IupGetIntInt(ih, "DRAWSIZE", &w, &h); + + SetRect(&rect, 0, 0, w, h); + FillRect(hDC, &rect, GetStockObject(WHITE_BRUSH)); + + SelectObject(hDC, GetStockObject(DC_PEN)); + SetDCPenColor(hDC, RGB(255, 0, 0)); + + w = 600; /* virtual size */ + MoveToEx(hDC, -posx, 0, NULL); + LineTo(hDC, w-posx, h); + MoveToEx(hDC, -posx, h, NULL); + LineTo(hDC, w-posx, 0); + + ReleaseDC(hWnd, hDC); +} +#else +#include <X11/Xlib.h> + +#define xCOLOR8TO16(_x) (_x*257) /* 65535/255 = 257 */ +static unsigned long xGetPixel(Display* dpy, unsigned char cr, unsigned char cg, unsigned char cb) +{ + XColor xc; + xc.red = xCOLOR8TO16(cr); + xc.green = xCOLOR8TO16(cg); + xc.blue = xCOLOR8TO16(cb); + xc.flags = DoRed | DoGreen | DoBlue; + + XAllocColor(dpy, DefaultColormap(dpy, XDefaultScreen(dpy)), &xc); + return xc.pixel; +} + +static void drawTest(Ihandle *ih, int posx) +{ + int w, h; + Display* dpy = (Display*)IupGetAttribute(ih, "XDISPLAY"); /* works for Motif and GTK */ + Drawable wnd = (Drawable)IupGetAttribute(ih, "XWINDOW"); + GC gc = XCreateGC(dpy, wnd, 0, NULL); + + IupGetIntInt(ih, "DRAWSIZE", &w, &h); + + XSetForeground(dpy, gc, xGetPixel(dpy, 255, 255, 255)); + XFillRectangle(dpy, wnd, gc, 0, 0, w, h); + + XSetForeground(dpy, gc, xGetPixel(dpy, 255, 0, 0)); + + w = 600; /* virtual size */ + XDrawLine(dpy, wnd, gc, -posx, 0, w-posx, h); + XDrawLine(dpy, wnd, gc, -posx, h, w-posx, 0); + + XFreeGC(dpy, gc); +} +#endif +#endif + +static int map_cb(Ihandle *ih) +{ + printf("MAP_CB()\n"); + return IUP_DEFAULT; +} + +static int action(Ihandle *ih, float posx, float posy) +{ + printf("ACTION(posx=%.2f, posy=%.2f)\n", posx, posy); + drawTest(ih, (int)posx); + return IUP_DEFAULT; +} + +static int scroll_cb(Ihandle *ih, int op, float posx, float posy) +{ + char* op2str[12] = {"SBUP", "SBDN", "SBPGUP", "SBPGDN", "SBPOSV", "SBDRAGV", + "SBLEFT", "SBRIGHT", "SBPGLEFT", "SBPGRIGHT", "SBPOSH", "SBDRAGH"}; + printf("SCROLL_CB(%s, posx=%.2f, posy=%.2f)\n", op2str[op], posx, posy); + IupRedraw(ih, 0); + return IUP_DEFAULT; +} + +static int dropfiles_cb(Ihandle *ih, const char* filename, int num, int x, int y) +{ + printf("DROPFILES_CB(%s, %d, x=%d, y=%d)\n", filename, num, x, y); + return IUP_DEFAULT; +} + +static int resize_cb(Ihandle *ih, int w, int h) +{ + printf("RESIZE_CB(%d, %d) RASTERSIZE=%s CLIENTSIZE=%s\n", w, h, IupGetAttribute(ih, "RASTERSIZE"), IupGetAttribute(ih, "CLIENTSIZE")); + + /* update page size */ + IupSetfAttribute(ih, "DX", "%d", w); + + return IUP_DEFAULT; +} + +static int getfocus_cb(Ihandle *ih) +{ + printf("GETFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int help_cb(Ihandle* ih) +{ + printf("HELP_CB()\n"); + return IUP_DEFAULT; +} + +static int killfocus_cb(Ihandle *ih) +{ + printf("KILLFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int focus_cb(Ihandle *ih, int focus) +{ + printf("FOCUS_CB(%d)\n", focus); + return IUP_DEFAULT; +} + +static int leavewindow_cb(Ihandle *ih) +{ + printf("LEAVEWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +static int enterwindow_cb(Ihandle *ih) +{ + printf("ENTERWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +static int button_cb(Ihandle *ih,int but,int pressed,int x,int y,char* status) +{ + if (but==IUP_BUTTON1 && pressed) + IupSetAttribute(ih, "CURSOR", "CROSS"); + if (but==IUP_BUTTON1 && !pressed) + IupSetAttribute(ih, "CURSOR", NULL); + printf("BUTTON_CB(but=%c (%d), x=%d, y=%d [%s])\n",(char)but,pressed,x,y, status); + return IUP_DEFAULT; +} + +static int wheel_cb(Ihandle *ih,float delta,int x,int y,char* status) +{ + printf("WHEEL_CB(delta=%.2f, x=%d, y=%d [%s])\n",delta,x,y, status); + return IUP_DEFAULT; +} + +static int motion_cb(Ihandle *ih,int x,int y,char* status) +{ + printf("MOTION_CB(x=%d, y=%d [%s])\n",x,y, status); + return IUP_DEFAULT; +} + +char *iupKeyCodeToName(int code); + +static int k_any(Ihandle *ih, int c) +{ + if (c == K_a) + IupSetAttribute(ih, "POSX", "100"); + + if (iup_isprint(c)) + printf("K_ANY(%d = %s \'%c\')\n", c, iupKeyCodeToName(c), (char)c); + else + printf("K_ANY(%d = %s)\n", c, iupKeyCodeToName(c)); + printf(" MODKEYSTATE(%s)\n", IupGetGlobal("MODKEYSTATE")); + return IUP_DEFAULT; +} + +static int keypress_cb(Ihandle *ih, int c, int pressed) +{ + if (iup_isprint(c)) + printf("KEYPRESS_CB(%d = %s \'%c\' (%d))\n", c, iupKeyCodeToName(c), (char)c, pressed); + else + printf("KEYPRESS_CB(%d = %s (%d))\n", c, iupKeyCodeToName(c), pressed); + return IUP_DEFAULT; +} + +void CanvasTest(void) +{ + Ihandle *dlg, *canvas, *box, *image; + + //image = IupImage(32, 32, pixmap_cursor); + //IupSetAttribute(image, "1", "255 0 0"); + //IupSetAttribute(image, "2", "128 0 0"); + //IupSetAttribute(image, "HOTSPOT", "21:10"); + + image = IupImage(15,15, matrx_img_cur_excel); + IupSetAttribute (image, "0", "BGCOLOR"); + IupSetAttribute (image, "1", "0 0 0"); + IupSetAttribute (image, "2", "255 255 255"); + IupSetAttribute (image, "HOTSPOT", "7:7"); + + box = IupVbox(NULL); + IupSetAttribute(box, "MARGIN", "5x5"); + + canvas = IupCanvas(NULL); + IupAppend(box, canvas); + IupSetAttribute(canvas, "RASTERSIZE", "300x200"); + IupSetAttribute(canvas, "TIP", "Canvas Tip"); + IupSetAttribute(canvas, "SCROLLBAR", "YES"); +// IupSetAttribute(canvas, "XAUTOHIDE", "NO"); + IupSetAttribute(canvas, "XMAX", "600"); + IupSetAttribute(canvas, "DX", "300"); /* use a 1x1 scale, this value is updated in RESIZE_CB, + so when the canvas is larger than 600 + it will hide the scrollbar */ + IupSetAttributeHandle(canvas, "CURSOR", image); + +// IupSetAttribute(canvas, "BORDER", "NO"); +// IupSetAttribute(canvas, "CURSOR", "CROSS"); + + IupSetCallback(canvas, "MAP_CB", (Icallback)map_cb); + + IupSetCallback(canvas, "KEYPRESS_CB", (Icallback)keypress_cb); + IupSetCallback(canvas, "K_ANY", (Icallback)k_any); + IupSetCallback(canvas, "HELP_CB", (Icallback)help_cb); + + IupSetCallback(canvas, "GETFOCUS_CB", (Icallback)getfocus_cb); + IupSetCallback(canvas, "KILLFOCUS_CB", (Icallback)killfocus_cb); + IupSetCallback(canvas, "FOCUS_CB", (Icallback)focus_cb); + IupSetCallback(canvas, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); + IupSetCallback(canvas, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); + + IupSetCallback(canvas, "BUTTON_CB", (Icallback)button_cb); +// IupSetCallback(canvas, "MOTION_CB", (Icallback)motion_cb); + IupSetCallback(canvas, "SCROLL_CB", (Icallback)scroll_cb); +// IupSetCallback(canvas, "WHEEL_CB", (Icallback)wheel_cb); + + IupSetCallback(canvas, "RESIZE_CB", (Icallback)resize_cb); +// IupSetAttribute(canvas, "BGCOLOR", "255 128 128"); + IupSetCallback(canvas, "ACTION", (Icallback)action); + + // Windows and GTK Only + IupSetCallback(canvas, "DROPFILES_CB", (Icallback)dropfiles_cb); + +//{ +// Ihandle* cnv = IupCanvas(NULL); +// IupAppend(box, cnv); +// IupSetAttribute(cnv, "RASTERSIZE", "300x200"); +// IupSetAttribute(cnv, "CURSOR", "NONE"); +//} + + dlg = IupDialog(box); + IupSetAttribute(dlg, "TITLE", "IupCanvas Test"); + + IupShow(dlg); + IupSetAttribute(canvas, "RASTERSIZE", NULL); /* release the minimum limitation */ +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + CanvasTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/canvas_cddbuffer.c b/iup/test/canvas_cddbuffer.c new file mode 100755 index 0000000..dd7ce3e --- /dev/null +++ b/iup/test/canvas_cddbuffer.c @@ -0,0 +1,124 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" +#include "cd.h" +#include "cdiup.h" +#include "cddbuf.h" + + +static void appUpdateRender(cdCanvas *cddbuffer) +{ + int width, height; + + cdCanvasBackground(cddbuffer, CD_WHITE); + cdCanvasClear(cddbuffer); + + cdCanvasForeground(cddbuffer, CD_RED); + cdCanvasGetSize(cddbuffer, &width, &height, NULL, NULL); + cdCanvasLine(cddbuffer, 0, 0, width-1, height-1); + cdCanvasLine(cddbuffer, 0, height-1, width-1, 0); +} + +static int redraw_cb(Ihandle *ih) +{ + cdCanvas *cddbuffer = (cdCanvas*)IupGetAttribute(ih, "_APP_CDDBUFFER"); + if (!cddbuffer) + return IUP_DEFAULT; + + /* update display */ + cdCanvasFlush(cddbuffer); + return IUP_DEFAULT; +} + +static int resize_cb(Ihandle *ih) +{ + cdCanvas *cddbuffer = (cdCanvas*)IupGetAttribute(ih, "_APP_CDDBUFFER"); + if (!cddbuffer) + { + cdCanvas *cdcanvas = (cdCanvas*)IupGetAttribute(ih, "_APP_CDCANVAS"); + + /* update canvas size */ + cdCanvasActivate(cdcanvas); + + /* this can fail if canvas size is zero */ + cddbuffer = cdCreateCanvas(CD_DBUFFER, cdcanvas); + } + + if (!cddbuffer) + return IUP_DEFAULT; + + /* update size */ + cdCanvasActivate(cddbuffer); + + /* update render */ + appUpdateRender(cddbuffer); + + return IUP_DEFAULT; +} + +static int map_cb(Ihandle *ih) +{ + cdCanvas *cddbuffer, *cdcanvas; + + cdcanvas = cdCreateCanvas(CD_IUP, ih); + if (!cdcanvas) + return IUP_DEFAULT; + + /* this can fail if canvas size is zero */ + cddbuffer = cdCreateCanvas(CD_DBUFFER, cdcanvas); + + IupSetAttribute(ih, "_APP_CDCANVAS", (char*)cdcanvas); + IupSetAttribute(ih, "_APP_CDDBUFFER", (char*)cddbuffer); + + return IUP_DEFAULT; +} + +static int unmap_cb(Ihandle *ih) +{ + cdCanvas *cddbuffer = (cdCanvas*)IupGetAttribute(ih, "_APP_CDDBUFFER"); + cdCanvas *cdcanvas = (cdCanvas*)IupGetAttribute(ih, "_APP_CDCANVAS"); + + if (cddbuffer) + cdKillCanvas(cddbuffer); + + if (cdcanvas) + cdKillCanvas(cdcanvas); + + return IUP_DEFAULT; +} + +void CanvasCDDBufferTest(void) +{ + Ihandle *dlg, *canvas; + + canvas = IupCanvas(NULL); + IupSetAttribute(canvas, "RASTERSIZE", "300x200"); /* initial size */ + + IupSetCallback(canvas, "RESIZE_CB", (Icallback)resize_cb); + IupSetCallback(canvas, "ACTION", (Icallback)redraw_cb); + IupSetCallback(canvas, "MAP_CB", (Icallback)map_cb); + IupSetCallback(canvas, "UNMAP_CB", (Icallback)unmap_cb); + + dlg = IupDialog(canvas); + IupSetAttribute(dlg, "TITLE", "CD Double Buffer Test"); + + IupMap(dlg); + IupSetAttribute(canvas, "RASTERSIZE", NULL); /* release the minimum limitation */ + + IupShowXY(dlg,IUP_CENTER,IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + CanvasCDDBufferTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/canvas_cdsimple.c b/iup/test/canvas_cdsimple.c new file mode 100755 index 0000000..3a73c22 --- /dev/null +++ b/iup/test/canvas_cdsimple.c @@ -0,0 +1,91 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" +#include "cd.h" +#include "cdiup.h" +#include "cddbuf.h" + + +static int redraw_cb(Ihandle *ih) +{ + int width, height; + cdCanvas *cdcanvas = (cdCanvas*)IupGetAttribute(ih, "_APP_CDCANVAS"); + + cdCanvasBackground(cdcanvas, CD_WHITE); + cdCanvasClear(cdcanvas); + + cdCanvasForeground(cdcanvas, CD_RED); + cdCanvasGetSize(cdcanvas, &width, &height, NULL, NULL); + cdCanvasLine(cdcanvas, 0, 0, width-1, height-1); + cdCanvasLine(cdcanvas, 0, height-1, width-1, 0); + return IUP_DEFAULT; +} + +static int resize_cb(Ihandle *ih) +{ + cdCanvas *cdcanvas = (cdCanvas*)IupGetAttribute(ih, "_APP_CDCANVAS"); + + /* update canvas size */ + cdCanvasActivate(cdcanvas); + + return IUP_DEFAULT; +} + +static int map_cb(Ihandle *ih) +{ + cdCanvas *cdcanvas; + + cdcanvas = cdCreateCanvas(CD_IUP, ih); + if (!cdcanvas) + return IUP_DEFAULT; + + IupSetAttribute(ih, "_APP_CDCANVAS", (char*)cdcanvas); + + return IUP_DEFAULT; +} + +static int unmap_cb(Ihandle *ih) +{ + cdCanvas *cdcanvas = (cdCanvas*)IupGetAttribute(ih, "_APP_CDCANVAS"); + + if (cdcanvas) + cdKillCanvas(cdcanvas); + + return IUP_DEFAULT; +} + +void CanvasCDSimpleTest(void) +{ + Ihandle *dlg, *canvas; + + canvas = IupCanvas(NULL); + IupSetAttribute(canvas, "RASTERSIZE", "300x200"); /* initial size */ + + IupSetCallback(canvas, "RESIZE_CB", (Icallback)resize_cb); + IupSetCallback(canvas, "ACTION", (Icallback)redraw_cb); + IupSetCallback(canvas, "MAP_CB", (Icallback)map_cb); + IupSetCallback(canvas, "UNMAP_CB", (Icallback)unmap_cb); + + dlg = IupDialog(canvas); + IupSetAttribute(dlg, "TITLE", "CD Simple Buffer Test"); + + IupMap(dlg); + IupSetAttribute(canvas, "RASTERSIZE", NULL); /* release the minimum limitation */ + + IupShowXY(dlg,IUP_CENTER,IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + CanvasCDSimpleTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/canvas_scrollbar.c b/iup/test/canvas_scrollbar.c new file mode 100755 index 0000000..72749de --- /dev/null +++ b/iup/test/canvas_scrollbar.c @@ -0,0 +1,191 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" +#include "cd.h" +#include "cdiup.h" +#include "wd.h" + + +/* World: (0-600)x(0-400) + The canvas will be a window into that space. + If canvas is smaller than the virtual space, scrollbars are active. + The drawing is a red X connecting the corners of the world. +*/ +#define WORLD_W 600 +#define WORLD_H 400 +static int scale = 1; + +static void update_scrollbar(Ihandle* ih, int canvas_w, int canvas_h) +{ + /* update page size, it is always the client size of the canvas, + but must convert it to world coordinates. + If you change canvas size or scale must call this function. */ + double ww, wh; + if (scale > 0) + { + ww = (double)canvas_w/scale; + wh = (double)canvas_h/scale; + } + else + { + ww = canvas_w*abs(scale); + wh = canvas_h*abs(scale); + } + IupSetfAttribute(ih, "DX", "%f", ww); + IupSetfAttribute(ih, "DY", "%f", wh); +} + +static void update_viewport(Ihandle* ih, cdCanvas *canvas, float posx, float posy) +{ + int view_x, view_y, view_w, view_h; + + /* The CD viewport is the same area represented by the virtual space of the scrollbar, + but not using the same coordinates. */ + + /* posy is top-bottom, CD is bottom-top. + invert posy reference (YMAX-DY - POSY) */ + posy = WORLD_H-IupGetFloat(ih, "DY") - posy; + if (posy < 0) posy = 0; + + if (scale > 0) + { + view_w = WORLD_W*scale; + view_h = WORLD_H*scale; + view_x = (int)(posx*scale); + view_y = (int)(posy*scale); + } + else + { + view_w = WORLD_W/abs(scale); + view_h = WORLD_H/abs(scale); + view_x = (int)(posx/abs(scale)); + view_y = (int)(posy/abs(scale)); + } + + wdCanvasViewport(canvas, -view_x, view_w-1 - view_x, -view_y, view_h-1 - view_y); +} + +/************************************************************************************/ + +static int action(Ihandle *ih) +{ + cdCanvas *canvas = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS"); + + cdCanvasClear(canvas); + + cdCanvasForeground(canvas, CD_RED); + wdCanvasLine(canvas, 0, 0, WORLD_W, WORLD_H); + wdCanvasLine(canvas, 0, WORLD_H, WORLD_W, 0); + wdCanvasArc(canvas, WORLD_W/2, WORLD_H/2+WORLD_H/10, WORLD_W/10, WORLD_H/10, 0, 360); + + return IUP_DEFAULT; +} + +static int resize_cb(Ihandle *ih, int canvas_w, int canvas_h) +{ + cdCanvas *canvas = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS"); + + /* update CD canvas */ + cdCanvasActivate(canvas); + + update_scrollbar(ih, canvas_w, canvas_h); + update_viewport(ih, canvas, IupGetFloat(ih, "POSX"), IupGetFloat(ih, "POSY")); + return IUP_DEFAULT; +} + +static int scroll_cb(Ihandle *ih, int op, float posx, float posy) +{ + cdCanvas *canvas = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS"); + update_viewport(ih, canvas, posx, posy); + IupRedraw(ih, 0); + (void)op; + return IUP_DEFAULT; +} + +static int wheel_cb(Ihandle *ih,float delta,int x,int y,char* status) +{ + int canvas_w, canvas_h; + cdCanvas *canvas = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS"); + (void)x; + (void)y; + (void)status; + + if (scale+delta==0) /* skip 0 */ + { + if (scale > 0) + scale = -1; + else + scale = 1; + } + else + scale += (int)delta; + + cdCanvasGetSize(canvas, &canvas_w, &canvas_h, NULL, NULL); + update_scrollbar(ih, canvas_w, canvas_h); + update_viewport(ih, canvas, IupGetFloat(ih, "POSX"), IupGetFloat(ih, "POSY")); + IupRedraw(ih, 0); + return IUP_DEFAULT; +} + +static int map_cb(Ihandle *ih) +{ + cdCanvas *canvas = cdCreateCanvas(CD_IUP, ih); + + /* World size is fixed */ + wdCanvasWindow(canvas, 0, WORLD_W, 0, WORLD_H); + + /* handle scrollbar in world coordinates, so we only have to update DX/DY */ + IupSetAttribute(ih, "XMIN", "0"); + IupSetAttribute(ih, "YMIN", "0"); + IupSetfAttribute(ih, "XMAX", "%d", WORLD_W); + IupSetfAttribute(ih, "YMAX", "%d", WORLD_H); + + return IUP_DEFAULT; +} + +static int unmap_cb(Ihandle *ih) +{ + cdCanvas *canvas = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS"); + cdKillCanvas(canvas); + return IUP_DEFAULT; +} + +void CanvasScrollbarTest(void) +{ + Ihandle *dlg, *cnv; + + cnv = IupCanvas(NULL); + IupSetAttribute(cnv, "RASTERSIZE", "300x200"); /* initial size */ + IupSetAttribute(cnv, "SCROLLBAR", "YES"); + + IupSetCallback(cnv, "RESIZE_CB", (Icallback)resize_cb); + IupSetCallback(cnv, "ACTION", (Icallback)action); + IupSetCallback(cnv, "MAP_CB", (Icallback)map_cb); + IupSetCallback(cnv, "UNMAP_CB", (Icallback)unmap_cb); + IupSetCallback(cnv, "WHEEL_CB", (Icallback)wheel_cb); + IupSetCallback(cnv, "SCROLL_CB", (Icallback)scroll_cb); + + dlg = IupDialog(IupVbox(cnv, NULL)); + IupSetAttribute(dlg, "TITLE", "Scrollbar Test"); + IupSetAttribute(dlg, "MARGIN", "10x10"); + + IupMap(dlg); + IupSetAttribute(cnv, "RASTERSIZE", NULL); /* release the minimum limitation */ + + IupShowXY(dlg,IUP_CENTER,IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + CanvasScrollbarTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/cells_checkboard.c b/iup/test/cells_checkboard.c new file mode 100755 index 0000000..40cc0ef --- /dev/null +++ b/iup/test/cells_checkboard.c @@ -0,0 +1,83 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "iup.h" +#include "cd.h" +#include "iupcontrols.h" + + +static int nlines_cb(Ihandle* ih) +{ + return 8; +} + +static int ncols_cb(Ihandle* ih) +{ + return 8; +} + +static int height_cb(Ihandle* ih, int i) +{ + return 50; +} + +static int width_cb(Ihandle* ih, int j) +{ + return 50; +} + +static int draw_cb(Ihandle* ih, int i, int j, int xmin, int xmax, int ymin, int ymax) +{ + if (((i%2) && (j%2)) || (((i+1)%2) && ((j+1)%2))) + cdForeground(CD_WHITE); + else + cdForeground(CD_BLACK); + + cdBox(xmin, xmax, ymin, ymax); + return IUP_DEFAULT; +} + +static Ihandle* create(void) +{ + Ihandle* cells = IupCells(); + + IupSetCallback(cells, "DRAW_CB", (Icallback)draw_cb); + IupSetCallback(cells, "WIDTH_CB", (Icallback)width_cb); + IupSetCallback(cells, "HEIGHT_CB", (Icallback)height_cb); + IupSetCallback(cells, "NLINES_CB", (Icallback)nlines_cb); + IupSetCallback(cells, "NCOLS_CB", (Icallback)ncols_cb); + + return cells; +} + +void CellsCheckboardTest(void) +{ + Ihandle* dlg = NULL; + Ihandle* cells = NULL; + + cells = create(); + dlg = IupDialog(cells); + + IupSetAttribute(dlg, "RASTERSIZE", "400x400"); + IupSetAttribute(dlg, "TITLE", "IupCells"); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER) ; + IupSetAttribute(dlg, "RASTERSIZE", NULL); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupControlsOpen(); + + CellsCheckboardTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/cells_degrade.c b/iup/test/cells_degrade.c new file mode 100755 index 0000000..30e969b --- /dev/null +++ b/iup/test/cells_degrade.c @@ -0,0 +1,150 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "iup.h" +#include "cd.h" +#include "iupcontrols.h" + + +static int nlines_cb(Ihandle* ih) +{ + return 7; +} + +static int ncols_cb(Ihandle* ih) +{ + return 7; +} + +static int height_cb(Ihandle* ih, int i) +{ + return (int)(30 + i * 1.5); +} + +static int width_cb(Ihandle* ih, int j) +{ + return (int)(50 + j * 1.5); +} + +static int mouseclick_cb(Ihandle* ih, int b, char* m, int i, int j, int x, int y, char* r) +{ + printf("CLICK: %d: (%02d, %02d)\n", b, i, j); + return IUP_DEFAULT; +} + +static int scrolling_cb(Ihandle* ih, int i, int j) +{ + printf("SCROLL: (%02d, %02d)\n", i, j); + return IUP_DEFAULT; +} + +static int vspan_cb(Ihandle* ih, int i, int j) +{ + if (i == 1 && j == 1) + return 2; + + if (i == 5 && j == 5) + return 2; + + return 1; +} + +static int hspan_cb(Ihandle* ih, int i, int j) +{ + if (i == 1 && j == 1) + return 2; + + if (i == 5 && j == 5) + return 2; + + return 1; +} + +static int draw_cb(Ihandle* ih, int i, int j, int xmin, int xmax, int ymin, int ymax) +{ + static char buffer[64]; + int xm = (xmax + xmin) / 2; + int ym = (ymax + ymin) / 2; + + if (i == 1 && j == 2) + return IUP_DEFAULT; + if (i == 2 && j == 1) + return IUP_DEFAULT; + if (i == 2 && j == 2) + return IUP_DEFAULT; + if (i == 5 && j == 6) + return IUP_DEFAULT; + if (i == 6 && j == 5) + return IUP_DEFAULT; + if (i == 6 && j == 6) + return IUP_DEFAULT; + + if (i == 1 && j == 1) + cdForeground(CD_WHITE); + else + cdForeground(cdEncodeColor((unsigned char)(i*20), (unsigned char)(j*100), (unsigned char)(i+100))); + + cdBox(xmin, xmax, ymin, ymax); + cdTextAlignment(CD_CENTER); + cdForeground(CD_BLACK); + sprintf(buffer, "(%02d, %02d)", i, j); + cdText(xm, ym, buffer); + + return IUP_DEFAULT; +} + +static Ihandle* create(void) +{ + Ihandle* cells = IupCells(); + + IupSetCallback(cells, "MOUSECLICK_CB", (Icallback)mouseclick_cb); + IupSetCallback(cells, "DRAW_CB", (Icallback)draw_cb); + IupSetCallback(cells, "WIDTH_CB", (Icallback)width_cb); + IupSetCallback(cells, "HEIGHT_CB", (Icallback)height_cb); + IupSetCallback(cells, "NLINES_CB", (Icallback)nlines_cb); + IupSetCallback(cells, "NCOLS_CB", (Icallback)ncols_cb); + IupSetCallback(cells, "HSPAN_CB", (Icallback)hspan_cb); + IupSetCallback(cells, "VSPAN_CB", (Icallback)vspan_cb); + IupSetCallback(cells, "SCROLLING_CB", (Icallback)scrolling_cb); + + IupSetAttribute(cells, "BOXED", "NO"); + IupSetAttribute(cells, "RASTERSIZE", "395x255"); + + return cells; +} + +void CellsDegradeTest(void) +{ + Ihandle* dlg = NULL; + Ihandle* cells = NULL; + Ihandle* box = NULL; + + cells = create(); + + box = IupVbox(cells, NULL); + IupSetAttribute(box, "MARGIN", "10x10"); + + dlg = IupDialog(box); + + IupSetAttribute(dlg, "TITLE", "IupCells"); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER) ; + IupSetAttribute(cells, "RASTERSIZE", NULL); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupControlsOpen(); + + CellsDegradeTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/cells_numbering.c b/iup/test/cells_numbering.c new file mode 100755 index 0000000..7cb303f --- /dev/null +++ b/iup/test/cells_numbering.c @@ -0,0 +1,102 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "iup.h" +#include "cd.h" +#include "iupcontrols.h" + + +static int nlines_cb(Ihandle* ih) +{ + return 20; +} + +static int ncols_cb(Ihandle* ih) +{ + return 50; +} + +static int height_cb(Ihandle* ih, int i) +{ + return 30; +} + +static int width_cb(Ihandle* ih, int j) +{ + return 70; +} + +static int mouseclick_cb(Ihandle* ih, int b, char* m, int i, int j, int x, int y, char* r) +{ + static char buffer[128]; + sprintf(buffer, "CLICK: %d: (%02d, %02d)\n", b, i, j); + + IupMessage("Hi!", buffer); + return IUP_DEFAULT; +} + +static int draw_cb(Ihandle* ih, int i, int j, int xmin, int xmax, int ymin, int ymax) +{ + static char buffer[64]; + int xm = (xmax + xmin) / 2; + int ym = (ymax + ymin) / 2; + + cdForeground(cdEncodeColor((unsigned char)(i*20), (unsigned char)(j*100), (unsigned char)(i+100))); + + cdBox(xmin, xmax, ymin, ymax); + cdTextAlignment(CD_CENTER); + cdForeground(CD_BLACK); + sprintf(buffer, "(%02d, %02d)", i, j); + cdText(xm, ym, buffer); + + return IUP_DEFAULT; +} + +static Ihandle* create(void) +{ + Ihandle* cells = IupCells(); + + IupSetCallback(cells, "MOUSECLICK_CB", (Icallback)mouseclick_cb); + IupSetCallback(cells, "DRAW_CB", (Icallback)draw_cb); + IupSetCallback(cells, "WIDTH_CB", (Icallback)width_cb); + IupSetCallback(cells, "HEIGHT_CB", (Icallback)height_cb); + IupSetCallback(cells, "NLINES_CB", (Icallback)nlines_cb); + IupSetCallback(cells, "NCOLS_CB", (Icallback)ncols_cb); + + IupSetAttribute(cells, "BOXED", "NO"); + + return cells; +} + +void CellsNumberingTest(void) +{ + Ihandle* dlg = NULL; + Ihandle* cells = NULL; + + IupControlsOpen(); + + cells = create(); + dlg = IupDialog(cells); + + IupSetAttribute(cells, "RASTERSIZE", "500x500"); + IupSetAttribute(dlg, "TITLE", "IupCells"); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER) ; + IupSetAttribute(cells, "RASTERSIZE", NULL); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + CellsNumberingTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/class_conf.c b/iup/test/class_conf.c new file mode 100755 index 0000000..4e73f3d --- /dev/null +++ b/iup/test/class_conf.c @@ -0,0 +1,278 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <iup.h> + +#include "../src/iup_class.h" +#include "../src/iup_register.h" + +#define MAX_ITEMS 200 + +char* callback_str[] = {"idle", "", "Ii", "ccc", "d", "iiiic", + "ff", "fiis", "i", "iff", "ii", "iic", + "iiIII", "iii", "iiii", "iiiiii", "iiiiiis", + "iiiis", "iinsii", "iis", "is", "nii", + "nn", "s", "sii", "siii", "ss", "i=s", "ii=s", + "iiiiiiv"}; + +char currentClassName[256]; + +int compare(const void *a, const void *b) +{ + return strcmp( * ( char** ) a, * ( char** ) b ); +} + +/* Update callback labels */ +static int callbacksList_ActionCB (Ihandle *ih, char *callName, int pos, int state) +{ + char* temp; + char params[256], copy[2]; + int i = 0; + int returns = 0; + + if(!callName) + return 0; + + temp = iupClassGetDefaultAttribute(currentClassName, callName); + + copy[1] = '\0'; + sprintf(params, "%s", "Ihandle*"); + + IupSetAttribute(IupGetHandle("labelCallback"), "TITLE", callName); + + while(i < (int)strlen(temp)) + { + strncpy(copy, temp+i, 1); + + if(!strcmp(copy, "i")) + sprintf(params, "%s, %s", params, "int"); + else if(!strcmp(copy, "c")) + sprintf(params, "%s, %s", params, "unsigned char"); + else if(!strcmp(copy, "s")) + sprintf(params, "%s, %s", params, "char*"); + else if(!strcmp(copy, "f")) + sprintf(params, "%s, %s", params, "float"); + else if(!strcmp(copy, "d")) + sprintf(params, "%s, %s", params, "double"); + else if(!strcmp(copy, "I")) + sprintf(params, "%s, %s", params, "int*"); + else if(!strcmp(copy, "n")) + sprintf(params, "%s, %s", params, "Ihandle*"); + else if(!strcmp(copy, "v")) + sprintf(params, "%s, %s", params, "cdCanvas*"); + else if(!strcmp(copy, "=")) + { + returns = 1; + break; + } + + i++; + } + + if(returns) + sprintf(params, "%s (= char*)", params); + else if(!strcmp(callName, "HELP_CB")) + sprintf(params, "%s (= void)", params); + else + sprintf(params, "%s (= int)", params); + + if(!strcmp(temp, "idle")) + IupSetAttribute(IupGetHandle("labelParams"), "TITLE", "void"); + else + IupSetAttribute(IupGetHandle("labelParams"), "TITLE", params); + + (void)ih; + (void)pos; + (void)state; + + return IUP_DEFAULT; +} + +/* Update attribute labels */ +static int attributesList_ActionCB (Ihandle *ih, char *attribName, int pos, int state) +{ + char* temp; + + if(!attribName) + return 0; + + temp = iupClassGetDefaultAttribute(currentClassName, attribName); + + IupSetAttribute(IupGetHandle("labelAttribute"), "TITLE", attribName); + + if(!temp) + IupSetAttribute(IupGetHandle("labelDefault"), "TITLE", "NULL"); + else + IupSetAttribute(IupGetHandle("labelDefault"), "TITLE", temp); + + (void)ih; + (void)pos; + (void)state; + + return IUP_DEFAULT; +} + +static int classesList_ActionCB (Ihandle *ih, char *className, int pos, int state) +{ + int i, j, n; + char* temp; + char **names = (char **) malloc(MAX_ITEMS * sizeof(char *)); + int call_str = sizeof(callback_str) / sizeof(char*); + + n = IupGetClassAttributes(className, names, MAX_ITEMS); + + /* Sort names */ + qsort(names, n, sizeof(char*), compare); + + /* Clear lists */ + IupSetAttribute(IupGetHandle("listAttributes"), "REMOVEITEM", NULL); + IupSetAttribute(IupGetHandle("listCallbacks"), "REMOVEITEM", NULL); + + /* Populate attribute and callback lists */ + for (i = 0; i < n; i++) + { + temp = iupClassGetDefaultAttribute(className, names[i]); + + if(!temp) + { + /* No default value */ + IupSetAttribute(IupGetHandle("listAttributes"), "APPENDITEM", names[i]); + } + else + { + for(j = 0; j < call_str; j++) + { + /* callback attribute */ + if(!strcmp(temp, callback_str[j])) + { + IupSetAttribute(IupGetHandle("listCallbacks"), "APPENDITEM", names[i]); + break; + } + } + + if(j == call_str) + { + /* attribute w/ default value */ + IupSetAttribute(IupGetHandle("listAttributes"), "APPENDITEM", names[i]); + } + } + } + + /* Update labels (values) */ + IupSetAttribute(IupGetHandle("labelClass"), "TITLE", className); + strcpy(currentClassName, className); + + IupSetAttribute(IupGetHandle("labelAttribute"), "TITLE", NULL); + IupSetAttribute(IupGetHandle("labelDefault"), "TITLE", NULL); + IupSetAttribute(IupGetHandle("labelCallback"), "TITLE", NULL); + IupSetAttribute(IupGetHandle("labelParams"), "TITLE", NULL); + + + (void)ih; + (void)pos; + (void)state; + + return IUP_DEFAULT; +} + +void PopulateListOfClasses(void) +{ + int i, n; + char **list = (char **) malloc(MAX_ITEMS * sizeof(char *)); + + n = iupRegisterGetClasses(list, MAX_ITEMS); + + qsort(list, n, sizeof(char*), compare); + + for(i = 0; i < n; i++) + IupSetAttribute(IupGetHandle("listClasses"), "APPENDITEM", list[i]); +} + +void ConfTest(void) +{ + Ihandle *dialog, *box, *lists, *listClasses, *listAttributes, *listCallbacks; + Ihandle *labelAttribute, *labelDefault, *labelCallback, *labelParams, *labelClass; + + listClasses = IupList(NULL); /* list of registered classes */ + listAttributes = IupList(NULL); /* list of attributes of the selected class */ + listCallbacks = IupList(NULL); /* list of callbacks of the selected class */ + + labelClass = IupLabel(NULL); + + labelAttribute = IupLabel(NULL); + labelDefault = IupLabel(NULL); + labelCallback = IupLabel(NULL); + labelParams = IupLabel(NULL); + + IupSetAttributes(listClasses, "EDITBOX=NO, DROPDOWN=NO, NAME=listClasses, SIZE= 70x85"); + IupSetAttributes(listAttributes, "EDITBOX=NO, DROPDOWN=NO, NAME=listAttributes, SIZE=120x85"); + IupSetAttributes(listCallbacks, "EDITBOX=NO, DROPDOWN=NO, NAME=listCallbacks, SIZE=120x85"); + + IupSetAttribute(labelClass, "FONTSTYLE", "Bold"); + IupSetAttribute(labelClass, "FGCOLOR", "255 0 0"); + + IupSetAttribute(labelClass, "SIZE", "100x"); + IupSetAttribute(labelAttribute, "SIZE", "100x"); + IupSetAttribute(labelDefault, "SIZE", "100x"); + IupSetAttribute(labelCallback, "SIZE", "100x"); + IupSetAttribute(labelParams, "SIZE", "280x"); + + IupSetCallback(listClasses, "ACTION", (Icallback) classesList_ActionCB); + IupSetCallback(listAttributes, "ACTION", (Icallback) attributesList_ActionCB); + IupSetCallback(listCallbacks, "ACTION", (Icallback) callbacksList_ActionCB); + + IupSetHandle("listClasses", listClasses); + IupSetHandle("listAttributes", listAttributes); + IupSetHandle("listCallbacks", listCallbacks); + + IupSetHandle("labelClass", labelClass); + IupSetHandle("labelAttribute", labelAttribute); + IupSetHandle("labelDefault", labelDefault); + IupSetHandle("labelCallback", labelCallback); + IupSetHandle("labelParams", labelParams); + + lists = IupVbox( + IupHbox( + IupSetAttributes(IupFrame(IupVbox(listClasses, NULL)), "TITLE=CLASSES"), + IupSetAttributes(IupFrame(IupVbox(listAttributes, NULL)), "TITLE=ATTRIBUTES"), + IupSetAttributes(IupFrame(IupVbox(listCallbacks, NULL)), "TITLE=CALLBACKS"), + NULL), + IupHbox( + IupSetAttributes(IupFrame(IupHbox(IupVbox(IupLabel("Class: "), IupLabel("Attribute: "), + IupLabel("Default: "), IupLabel("Callback: "), + IupLabel("Parameters: "), NULL), + IupVbox(labelClass, labelAttribute, + labelDefault, labelCallback, + labelParams, NULL), + NULL)), "TITLE=DETAILS"), + NULL), + NULL); + + box = IupHbox(lists, NULL); + + IupSetAttributes(lists,"MARGIN=10x10, GAP=10"); + + dialog = IupDialog(box); + + IupSetAttribute(dialog, "TITLE", "Class Conference and Documentation"); + + IupShowXY(dialog, IUP_CENTER, IUP_CENTER); + + PopulateListOfClasses(); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + ConfTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/clipboard.c b/iup/test/clipboard.c new file mode 100755 index 0000000..e4ea8c8 --- /dev/null +++ b/iup/test/clipboard.c @@ -0,0 +1,53 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "iup.h" +#include "iupkey.h" + + +static int copy_cb(Ihandle* ih) +{ + Ihandle* text = IupGetDialogChild(ih, "text"); + Ihandle* clipboard = IupClipboard(); + IupSetAttribute(clipboard, "TEXT", IupGetAttribute(text, "VALUE")); + IupDestroy(clipboard); + return IUP_DEFAULT; +} + +static int paste_cb(Ihandle* ih) +{ + Ihandle* text = IupGetDialogChild(ih, "text"); + Ihandle* clipboard = IupClipboard(); + IupSetAttribute(text, "VALUE", IupGetAttribute(clipboard, "TEXT")); + IupDestroy(clipboard); + return IUP_DEFAULT; +} + +void ClipboardTest(void) +{ + Ihandle *dlg = IupDialog(IupVbox( + IupSetAttributes(IupText(NULL), "SIZE=80x60, MULTILINE=YES, NAME=text, EXPAND=YES"), + IupSetCallbacks(IupButton("Copy", NULL), "ACTION", copy_cb, NULL), + IupSetCallbacks(IupButton("Paste", NULL), "ACTION", paste_cb, NULL), + NULL)); + IupSetAttribute(dlg, "GAP", "10"); + IupSetAttribute(dlg, "MARGIN", "20x20"); + + IupSetAttribute(dlg, "TITLE", "Clipboard Test"); + IupShow(dlg); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + ClipboardTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/colorbar.c b/iup/test/colorbar.c new file mode 100755 index 0000000..a24bbb1 --- /dev/null +++ b/iup/test/colorbar.c @@ -0,0 +1,162 @@ + +#include <stdio.h> +#include <stdlib.h> + +#include "iup.h" +#include "cd.h" +#include "cdiup.h" +#include "iupcontrols.h" + +static Ihandle *canvas = NULL; +static cdCanvas *cdcanvas = NULL; + +static int redraw_cb(Ihandle* ih) +{ + if (!cdcanvas) + return IUP_DEFAULT; + + /* Activates canvas cdcanvas */ + cdActivate(cdcanvas); + cdClear(); + + /* Draws a rectangle on the canvas */ + cdBegin(CD_FILL); + cdVertex(50, 50); + cdVertex(150, 50); + cdVertex(100, 150); + cdEnd(); + + /* Function executed sucessfully */ + return IUP_DEFAULT; +} + +static int extended_cb(Ihandle* ih, int cell) +{ + printf("extended_cb(%d)\n", cell); + return IUP_DEFAULT; +} + +static char* cell_cb(Ihandle* ih, int cell) +{ + int ri, gi, bi; + static char str[30]; + + sprintf(str, "CELL%d", cell); + sscanf(IupGetAttribute(ih, str), "%d %d %d", &ri, &gi, &bi); + printf("cell_cb(%d): %d, %d, %d\n", cell, ri, gi, bi); + +/* + unsigned char r, g, b; + r = (unsigned char)ri; + g = (unsigned char)gi; + b = (unsigned char)bi; + if (IupGetColor(IUP_MOUSEPOS, IUP_MOUSEPOS, &r, &g, &b)) + { + sprintf(str, "%d %d %d", (int)r, (int)g, (int)b); + cdActivate( cdcanvas ) ; + cdForeground(cdEncodeColor(r, g, b)); + redraw_cb(canvas); + return str; + } +*/ + return NULL; +} + +static int select_cb(Ihandle* ih, int cell, int type) +{ + long cd_color; + char str[30]; + int ri, gi, bi; + + sprintf(str, "CELL%d", cell); + sscanf(IupGetAttribute(ih, str), "%d %d %d", &ri, &gi, &bi); + printf("select_cb(%d, %d): %d, %d, %d\n", cell, type, ri, gi, bi); + + cd_color = cdEncodeColor((unsigned char)ri,(unsigned char)gi,(unsigned char)bi); + + if (!cdcanvas) + return IUP_DEFAULT; + + cdActivate( cdcanvas ) ; + if (type == -1) + cdForeground(cd_color); + else + cdBackground(cd_color); + + redraw_cb(canvas); + + return IUP_DEFAULT; +} + +static int switch_cb(Ihandle* ih, int primcell, int seccell) +{ + long fgcolor; + if (!cdcanvas) + return IUP_DEFAULT; + printf("switch_cb(%d, %d)\n", primcell, seccell); + cdActivate(cdcanvas) ; + fgcolor = cdForeground(CD_QUERY); + cdForeground(cdBackground(CD_QUERY)); + cdBackground(fgcolor); + redraw_cb(canvas); + return IUP_DEFAULT; +} + +void ColorbarTest(void) +{ + Ihandle *dlg, *cb; + + IupControlsOpen(); + + /* Creates a canvas associated with the redraw action */ + canvas = IupCanvas(NULL) ; + IupSetCallback(canvas, "ACTION", (Icallback)redraw_cb); + IupSetAttribute(canvas, "RASTERSIZE", "200x300"); + + cb = IupColorbar(); + IupSetAttribute(cb, "RASTERSIZE", "70x"); + IupSetAttribute(cb, "EXPAND", "VERTICAL"); + IupSetAttribute(cb, "NUM_PARTS", "2"); + IupSetAttribute(cb, "SHOW_SECONDARY", "YES"); + IupSetAttribute(cb, "PREVIEW_SIZE", "60"); +// IupSetAttribute(cb, "ACTIVE", "NO"); +// IupSetAttribute(cb, "BGCOLOR", "128 0 255"); + + IupSetCallback(cb, "SELECT_CB", (Icallback)select_cb); + IupSetCallback(cb, "CELL_CB", (Icallback)cell_cb); + IupSetCallback(cb, "SWITCH_CB", (Icallback)switch_cb); + IupSetCallback(cb, "EXTENDED_CB", (Icallback)extended_cb); + + dlg = IupDialog(IupHbox(canvas, cb, NULL)); + IupSetAttribute(dlg, "MARGIN", "5x5"); + + IupSetAttribute(dlg, "TITLE", "IupColorbar"); + + /* Maps the dlg. This must be done before the creation of the CD canvas. + Could also use MAP_CB callback. */ + IupMap(dlg); + + cdcanvas = cdCreateCanvas(CD_IUP, canvas); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); + + IupMainLoop(); + + IupDestroy(dlg); + IupClose(); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + ColorbarTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/colorbrowser.c b/iup/test/colorbrowser.c new file mode 100755 index 0000000..9ee594a --- /dev/null +++ b/iup/test/colorbrowser.c @@ -0,0 +1,91 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "iup.h" +#include "iupcontrols.h" + +static Ihandle *label_red, *label_green, *label_blue, *label_color; + +static void clrbrwsr_update_text(unsigned char r, unsigned char g, unsigned char b, char* hsi) +{ + float h, s, i; + sscanf(hsi, "%f %f %f", &h, &s, &i); + IupSetfAttribute(label_red, "TITLE", "R:%3d H:%3.0f", (int)r, (double)h); + IupSetfAttribute(label_green, "TITLE", "G:%3d S:%1.2f", (int)g, (double)s); + IupSetfAttribute(label_blue, "TITLE", "B:%3d I:%1.2f", (int)b, (double)i); + IupSetfAttribute(label_color, "BGCOLOR", "%d %d %d", (int)r, (int)g, (int)b); +} + +static int clrbrwsr_drag_cb(Ihandle* ih, unsigned char r, unsigned char g, unsigned char b) +{ + (void)ih; + printf("DRAG_CB(%d, %d, %d)\n", (int)r, (int)g, (int)b); + clrbrwsr_update_text(r, g, b, IupGetAttribute(ih, "HSI")); + return IUP_DEFAULT; +} + +static int clrbrwsr_change_cb(Ihandle* ih, unsigned char r, unsigned char g, unsigned char b) +{ + (void)ih; + printf("CHANGE_CB(%d, %d, %d)\n", (int)r, (int)g, (int)b); + clrbrwsr_update_text(r, g, b, IupGetAttribute(ih, "HSI")); + return IUP_DEFAULT; +} + +void ColorBrowserTest(void) +{ + Ihandle *dlg, *hbox_final, *vbox, *clrbrwsr; + + label_red = IupLabel(NULL); + IupSetAttribute(label_red, "SIZE", "100x10"); + IupSetAttribute(label_red, "FONT", "Courier, 12"); + label_green = IupLabel(NULL); + IupSetAttribute(label_green, "SIZE", "100x10"); + IupSetAttribute(label_green, "FONT", "Courier, 12"); + label_blue = IupLabel(NULL); + IupSetAttribute(label_blue, "SIZE", "100x10"); + IupSetAttribute(label_blue, "FONT", "Courier, 12"); + + label_color = IupLabel(NULL); + IupSetAttribute(label_color, "RASTERSIZE", "50x50"); + + clrbrwsr = IupColorBrowser(); +// IupSetAttribute(clrbrwsr, "ACTIVE", "NO"); +// IupSetAttribute(clrbrwsr, "BGCOLOR", "128 128 255"); + IupSetAttribute(clrbrwsr, "EXPAND", "YES"); + IupSetAttribute(clrbrwsr, "RGB", "128 0 128"); + clrbrwsr_update_text(128, 0, 128, IupGetAttribute(clrbrwsr, "HSI")); + + IupSetCallback(clrbrwsr, "CHANGE_CB", (Icallback)clrbrwsr_change_cb); + IupSetCallback(clrbrwsr, "DRAG_CB", (Icallback)clrbrwsr_drag_cb); + + vbox = IupVbox( + label_red, + label_green, + label_blue, + label_color, + NULL); + + hbox_final = IupHbox (clrbrwsr, vbox, NULL); + IupSetAttribute(hbox_final, "MARGIN", "10x10"); + + dlg = IupDialog (hbox_final); + IupSetAttribute(dlg, "TITLE", "IupColorBrowser Test"); + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupControlsOpen(); + + ColorBrowserTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/config.mak b/iup/test/config.mak new file mode 100755 index 0000000..2764e6c --- /dev/null +++ b/iup/test/config.mak @@ -0,0 +1,115 @@ +APPNAME = iuptest +APPTYPE = CONSOLE + +INCLUDES = ../include + +ifdef USE_GTK + ifndef GTK_DEFAULT + # Build GTK version in IRIX,SunOS,AIX,Win32 + APPNAME = iuptestgtk + endif +else + ifdef GTK_DEFAULT + # Build Motif version in Linux,Darwin,FreeBSD + USE_MOTIF = Yes + APPNAME = iuptestmot + endif +endif + +USE_IUP3 = Yes +USE_STATIC = Yes +IUP = .. + +#TEC_UNAME_DIR = Win32.$(TEC_UNAME) +#DBG = Yes + +# Must uncomment all SRC lines +DEFINES = BIG_TEST +SRC += bigtest.c + +SRC += tray.c +SRC += dialog.c +SRC += predialogs.c +SRC += timer.c +SRC += label.c +SRC += canvas.c +SRC += frame.c +SRC += idle.c +SRC += button.c +SRC += toggle.c +SRC += vbox.c +SRC += hbox.c +SRC += progressbar.c +SRC += text.c +SRC += val.c +SRC += tabs.c +SRC += sample.c +SRC += menu.c +SRC += spin.c +SRC += text_spin.c +SRC += list.c +SRC += sysinfo.c +SRC += mdi.c +SRC += getparam.c +SRC += getcolor.c +SRC += class_conf.c +SRC += tree.c +SRC += zbox.c +SRC += scanf.c +SRC += sbox.c +SRC += clipboard.c + + +#ifneq ($(findstring Win, $(TEC_SYSNAME)), ) +# LIBS += iupimglib +#else +# SLIB += $(IUP)/lib/$(TEC_UNAME)/libiupimglib.a +#endif + +USE_CD = Yes +SRC += canvas_scrollbar.c +SRC += canvas_cddbuffer.c +SRC += canvas_cdsimple.c + +USE_OPENGL = Yes +DEFINES += USE_OPENGL +SRC += glcanvas.c +SRC += glcanvas_cube.c + +USE_IUPCONTROLS = Yes +SRC += colorbrowser.c +SRC += dial.c +SRC += colorbar.c +SRC += cells_numbering.c +SRC += cells_degrade.c +SRC += cells_checkboard.c +SRC += gauge.c +SRC += matrix.c +SRC += matrix_cbs.c +SRC += matrix_cbmode.c + +LINKER = g++ +DEFINES += PPLOT_TEST +SRC += pplot.c +ifneq ($(findstring Win, $(TEC_SYSNAME)), ) + LIBS += iup_pplot +# LIBS += cdpdflib +# LDIR += $(IUP)/lib/$(TEC_UNAME) +else + SLIB += $(IUP)/lib/$(TEC_UNAME)/libiup_pplot.a +# SLIB += $(CD)/lib/$(TEC_UNAME)/libcdpdflib.a +endif + +ifneq ($(findstring Win, $(TEC_SYSNAME)), ) + SRC += iuptest.rc +else + ifneq ($(findstring cygw, $(TEC_UNAME)), ) + SRC += iuptest.rc + endif +endif + +#ifneq ($(findstring Win, $(TEC_SYSNAME)), ) +# USE_GDIPLUS=Yes +#else +# USE_XRENDER=Yes +#endif diff --git a/iup/test/dial.c b/iup/test/dial.c new file mode 100755 index 0000000..727934c --- /dev/null +++ b/iup/test/dial.c @@ -0,0 +1,111 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "iup.h" +#include "iupcontrols.h" + +static int help_cb(Ihandle* ih) +{ + printf("HELP_CB(%s)\n", IupGetName(ih)); + return IUP_DEFAULT; +} + +static void printdial(Ihandle* ih, double a, char* color) +{ + Ihandle* label = NULL; + char* u = NULL; + char* type = IupGetAttribute(ih, "TYPE"); + + switch(type[0]) + { + case 'V': + label = IupGetHandle("lbl_v"); + u = "deg"; + break; + case 'H': + label = IupGetHandle("lbl_h"); + u = "rad"; + break; + case 'C': + label = IupGetHandle("lbl_c"); + u = "deg"; + break; + } + + if (label) + { + IupSetfAttribute(label, "TITLE", "%.3g %s", a, u); + IupSetAttribute(label, "BGCOLOR", color); + } +} + +static int mousemove(Ihandle* ih, double a) +{ + printdial(ih, a, "0 255 0"); + return IUP_DEFAULT; +} + +static int button_press(Ihandle* ih, double a) +{ + printdial(ih, a, "255 0 0"); + return IUP_DEFAULT; +} + +static int button_release(Ihandle* ih, double a) +{ + printdial(ih, a, NULL); + return IUP_DEFAULT; +} + +void DialTest(void) +{ + char *error = NULL; + Ihandle *dlg, *dial_h, *dial_v, *dial_c; + + error = IupLoad("dial.led"); + if (error) + { + error = IupLoad("../test/dial.led"); + if (error) + { + IupMessage("%s\n", error); + return; + } + } + + dlg = IupGetHandle("dlg"); + dial_h = IupGetHandle("dial_h"); + dial_v = IupGetHandle("dial_v"); + dial_c = IupGetHandle("dial_c"); + + IupSetFunction("dial_mousemove", (Icallback)mousemove); + IupSetFunction("dial_buttonpress", (Icallback)button_press); + IupSetFunction("dial_buttonrelease", (Icallback)button_release); + + IupSetCallback(dial_h, "HELP_CB", help_cb); + IupSetCallback(dial_v, "HELP_CB", help_cb); + + IupSetAttribute(dial_h, "EXPAND", "HORIZONTAL"); + IupSetAttribute(dial_v, "EXPAND", "VERTICAL"); + +// IupSetAttribute(dlg, "HELPBUTTON", "YES"); +// IupSetAttribute(dlg, "DIALOGFRAME", "YES"); + + IupShow(dlg); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupControlsOpen(); + + DialTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/dial.led b/iup/test/dial.led new file mode 100755 index 0000000..8157cb7 --- /dev/null +++ b/iup/test/dial.led @@ -0,0 +1,49 @@ +lbl_h = LABEL[SIZE=50x]("0") +lbl_v = LABEL[SIZE=50x]("0") +lbl_c = LABEL[SIZE=50x]("0") + +dial_v = DIAL +[ + UNIT=DEGREES, + MOUSEMOVE_CB="dial_mousemove", + BUTTON_PRESS_CB="dial_buttonpress", + BUTTON_RELEASE_CB="dial_buttonrelease" +] ("VERTICAL") + +dial_h = DIAL +[ + DENSITY=0.1, + MOUSEMOVE_CB="dial_mousemove", + BUTTON_PRESS_CB="dial_buttonpress", + BUTTON_RELEASE_CB="dial_buttonrelease" +] ("HORIZONTAL") + +dial_c = DIAL +[ + UNIT=DEGREES, + MOUSEMOVE_CB="dial_mousemove", + BUTTON_PRESS_CB="dial_buttonpress", + BUTTON_RELEASE_CB="dial_buttonrelease" +] ("CIRCULAR") + +dlg = DIALOG[TITLE="IupDial Test"] +( + VBOX[MARGIN=10x10, GAP=10] + ( + HBOX[ALIGNMENT=ACENTER] + ( + dial_v, + lbl_v + ), + HBOX[ALIGNMENT=ACENTER] + ( + dial_h, + lbl_h + ), + HBOX[ALIGNMENT=ACENTER] + ( + dial_c, + lbl_c + ) + ) +) diff --git a/iup/test/dialog.c b/iup/test/dialog.c new file mode 100755 index 0000000..f8097c9 --- /dev/null +++ b/iup/test/dialog.c @@ -0,0 +1,473 @@ +#if 0 +/* To check for memory leaks */ +#define VLD_MAX_DATA_DUMP 80 +#include <vld.h> +#endif + +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" +#include "iupkey.h" + +static unsigned char pixmap_x [ ] = +{ + 1,2,3,3,3,3,3,3,3,2,1, + 2,1,2,3,3,3,3,3,2,1,2, + 0,2,1,2,3,3,3,2,1,2,0, + 0,0,2,1,2,3,2,1,2,0,0, + 0,0,0,2,1,2,1,2,0,0,0, + 0,0,0,0,2,1,2,0,0,0,0, + 0,0,0,2,1,2,1,2,0,0,0, + 0,0,2,1,2,3,2,1,2,0,0, + 0,2,1,2,3,3,3,2,1,2,0, + 2,1,2,3,3,3,3,3,2,1,2, + 1,2,3,3,3,3,3,3,3,2,1 +}; + +static unsigned char pixmap_cursor [ ] = +{ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,2,2,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,2,0,0,2,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +} ; + +static int close_cb(Ihandle *ih) +{ + printf("CLOSE_CB(%s) with IupDestroy\n", IupGetAttribute(ih, "TESTTITLE")); + IupDestroy(ih); + return IUP_IGNORE; +} + +static int close_cb2(Ihandle *ih) +{ + printf("CLOSE_CB(%s) with IUP_IGNORE\n", IupGetAttribute(ih, "TESTTITLE")); + return IUP_IGNORE; +} + +static int show_cb(Ihandle *ih, int state) +{ + char* state_str[5] ={ + "SHOW", + "RESTORE", + "MINIMIZE", + "MAXIMIZE", + "HIDE" + }; + printf("SHOW_CB(%s, %s)\n", IupGetAttribute(ih, "TESTTITLE"), state_str[state]); + return IUP_DEFAULT; +} + +static int map_cb(Ihandle *ih) +{ + printf("MAP_CB(%s)\n", IupGetAttribute(ih, "TESTTITLE")); + return IUP_DEFAULT; +} + +static int dropfiles_cb(Ihandle *ih, const char* filename, int num, int x, int y) +{ + printf("DROPFILES_CB(%s, %s, %d, %d, %d)\n", IupGetAttribute(ih, "TESTTITLE"), filename, num, x, y); + return IUP_DEFAULT; +} + +static int resize_cb(Ihandle *ih, int w, int h) +{ + printf("RESIZE_CB(%s, %d, %d) RASTERSIZE=%s\n", IupGetAttribute(ih, "TESTTITLE"), w, h, IupGetAttribute(ih, "RASTERSIZE")); + return IUP_DEFAULT; +} + +static int move_cb(Ihandle *ih, int x, int y) +{ + printf("MOVE_CB(%s, %d, %d)\n", IupGetAttribute(ih, "TESTTITLE"), x, y); + return IUP_DEFAULT; +} + +static int getfocus_cb(Ihandle *ih) +{ + printf("GETFOCUS_CB(%s)\n", IupGetAttribute(ih, "TESTTITLE")); + return IUP_DEFAULT; +} + +static int help_cb(Ihandle* ih) +{ + printf("HELP_CB(%s)\n", IupGetAttribute(ih, "TESTTITLE")); + return IUP_DEFAULT; +} + +static int killfocus_cb(Ihandle *ih) +{ + printf("KILLFOCUS_CB(%s)\n", IupGetAttribute(ih, "TESTTITLE")); + return IUP_DEFAULT; +} + +static int leavewindow_cb(Ihandle *ih) +{ + printf("LEAVEWINDOW_CB(%s)\n", IupGetAttribute(ih, "TESTTITLE")); + return IUP_DEFAULT; +} + +static int enterwindow_cb(Ihandle *ih) +{ + printf("ENTERWINDOW_CB(%s)\n", IupGetAttribute(ih, "TESTTITLE")); + return IUP_DEFAULT; +} + +char *iupKeyCodeToName(int code); + +static void new_dialog(int test, char* tip); + +static int k_any(Ihandle *ih, int c) +{ + if (iup_isprint(c)) + printf("K_ANY(%s, %d = %s \'%c\')", IupGetAttribute(ih, "TESTTITLE"), c, iupKeyCodeToName(c), (char)c); + else + printf("K_ANY(%s, %d = %s)", IupGetAttribute(ih, "TESTTITLE"), c, iupKeyCodeToName(c)); + printf(" MODKEYSTATE(%s)\n", IupGetGlobal("MODKEYSTATE")); + + switch(c) + { + case K_r: + IupSetAttribute(ih, "RASTERSIZE", "300x300"); + IupRefresh(ih); + break; + case K_1: + new_dialog(1, "SIZE=FULLxFULL + IupShow.\n" + "Check also F1 = RASTERSIZE+IupRefresh.\n" + "close_cb returns IGNORE."); + break; + case K_2: + new_dialog(2, "Only common dlg decorations.\n" + "ShowXY.\n" + "min/max size."); + break; + case K_3: + new_dialog(3, "NO decorations"); + break; + case K_4: + new_dialog(4, "PLACEMENT.\n" + "Repeat key to test variations."); + break; + case K_5: + new_dialog(5, "IupPopup"); + break; + case K_6: + new_dialog(6, "FULLSCREEN"); + break; + case K_p: + { + static int count = 0; + if (count == 0) + IupSetAttribute(ih, "PLACEMENT", "MAXIMIZED"); + else if (count == 1) + IupSetAttribute(ih, "PLACEMENT", "MINIMIZED"); + else if (count == 2) + IupSetAttribute(ih, "PLACEMENT", "NORMAL"); + else + IupSetAttribute(ih, "PLACEMENT", "FULL"); + + count++; + if (count == 4) // cicle from 0 to 3 + count = 0; + + IupShow(ih); + } + break; + case K_s: + IupShow(IupGetHandle("_MAIN_DIALOG_TEST_")); + break; + case K_f: + if (IupGetInt(ih, "FULLSCREEN")) + IupSetAttribute(ih, "FULLSCREEN", "NO"); + else + IupSetAttribute(ih, "FULLSCREEN", "YES"); + break; + case K_ESC: + IupDestroy(ih); + return IUP_IGNORE; + case K_c: + return IUP_CLOSE; + case K_h: + IupHide(ih); + break; + } + return IUP_DEFAULT; +} + +static void new_dialog(int test, char* tip) +{ + Ihandle *dlg = IupDialog(NULL); + IupSetAttribute(dlg, "TIP", tip); + IupSetfAttribute(dlg, "_TEST_", "%d", test); + + if (test == 0) + { + char* msg = "Press a key for a dialog test:\n" + "1 = new with SIZE=FULLxFULL\n" + "2 = new with dialog decorations\n" + "3 = new with NO decorations\n" + "4 = new changing PLACEMENT\n" + "5 = new using IupPopup\n" + "6 = new with FULLSCREEN=YES\n" + "p = PLACEMENT=MAXIMIZED\n" + "pp = PLACEMENT=MINIMIZED\n" + "ppp = PLACEMENT=NORMAL\n" + "pppp = PLACEMENT=FULL\n" + "s = IupShow(main)\n" + "f = toggle FULLSCREEN state\n" + "c = return IUP_CLOSE;\n" + "h = IupHide\n" + "r = RASTERSIZE+IupRefresh\n" + "Esc = quit"; + IupAppend(dlg, IupVbox(IupLabel(msg), NULL)); + + IupSetHandle("_MAIN_DIALOG_TEST_", dlg); + } + else + { + IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_"); + IupSetAttribute(dlg, "CURSOR", "CROSS"); + } + + if (test != 3) + IupSetfAttribute(dlg, "TITLE", "dlg%d", test); + IupSetfAttribute(dlg, "TESTTITLE", "dlg%d", test); + + if (test == 1) + IupSetAttribute(dlg, "SIZE", "FULLxFULL"); + else if (test != 6) + IupSetAttribute(dlg, "RASTERSIZE", "500x500"); + + if (test == 2) + { + IupSetAttribute(dlg, "CURSOR", "DLG_CURSOR"); + IupSetAttribute(dlg, "ICON", "DLG_ICON"); + IupSetAttribute(dlg, "MINSIZE", "300x300"); + IupSetAttribute(dlg, "MAXSIZE", "600x600"); +// IupSetAttribute(dlg, "FONTSIZE", "20"); + + { + static int count = 0; + if (count == 1) + { +// IupSetAttribute(dlg, "FONT", "TIMES_ITALIC_14"); + IupSetAttribute(dlg, "FONT", "Times, Italic 14"); +// IupSetAttribute(dlg, "FONT", "Times, Underline Italic Strikeout -14"); + IupSetAttribute(dlg, "TIPBGCOLOR", "255 128 128"); + IupSetAttribute(dlg, "TIPFGCOLOR", "0 92 255"); + + // Windows Only + IupSetAttribute(dlg, "TIPBALLON", "YES"); + IupSetAttribute(dlg, "TIPBALLONTITLE", "Tip Title Test"); + IupSetAttribute(dlg, "TIPBALLONTITLEICON", "2"); + //IupSetAttribute(dlg, "TIPDELAY", "5000"); + } + if (count == 2) + { + // Windows Only + IupSetAttribute(dlg, "TOPMOST", "YES"); + IupSetAttribute(dlg, "OPACITY", "128"); + IupSetAttribute(dlg, "TOOLBOX", "YES"); + } + count++; + } + } + + if (test == 3) + { + IupSetAttribute(dlg, "BGCOLOR", "255 0 255"); + IupSetAttribute(dlg, "RESIZE", "NO"); + IupSetAttribute(dlg, "MENUBOX", "NO"); + IupSetAttribute(dlg, "MAXBOX", "NO"); + IupSetAttribute(dlg, "MINBOX", "NO"); + IupSetAttribute(dlg, "BORDER", "NO"); + + IupSetAttribute(dlg, "RASTERSIZE", "500x500"); + } + + if (test == 5) + { + IupSetAttribute(dlg, "DIALOGFRAME", "YES"); + + // Windows Only + IupSetAttribute(dlg, "HELPBUTTON", "YES"); + } + + if (test == 1) + IupSetCallback(dlg, "CLOSE_CB", (Icallback)close_cb2); + else + IupSetCallback(dlg, "CLOSE_CB", (Icallback)close_cb); + + IupSetCallback(dlg, "SHOW_CB", (Icallback)show_cb); + IupSetCallback(dlg, "MAP_CB", (Icallback)map_cb); + IupSetCallback(dlg, "K_ANY", (Icallback)k_any); + IupSetCallback(dlg, "GETFOCUS_CB", (Icallback)getfocus_cb); + IupSetCallback(dlg, "KILLFOCUS_CB", (Icallback)killfocus_cb); + IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb); + IupSetCallback(dlg, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); + IupSetCallback(dlg, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); + IupSetCallback(dlg, "RESIZE_CB", (Icallback)resize_cb); + IupSetCallback(dlg, "MOVE_CB", (Icallback)move_cb); + + // Windows and GTK Only + IupSetCallback(dlg, "DROPFILES_CB", (Icallback)dropfiles_cb); + + if (test == 0 || test == 1) + IupShow(dlg); + else if (test == 3) + IupShowXY(dlg, IUP_RIGHT, IUP_CENTER); + else if (test == 2) + IupShowXY(dlg, 100, 100); + else if (test == 4) + { + static int count = 0; + if (count == 0) + { + IupSetAttribute(dlg, "PLACEMENT", "MINIMIZED"); + IupSetfAttribute(dlg, "TIP", "%s%s", IupGetAttribute(dlg, "TIP"), "\n.PLACEMENT=MINIMIZED."); + } + else if (count == 1) + { + IupSetAttribute(dlg, "PLACEMENT", "MAXIMIZED"); + IupSetfAttribute(dlg, "TIP", "%s%s", IupGetAttribute(dlg, "TIP"), "\n.PLACEMENT=MAXIMIZED."); + } + else + { + IupSetAttribute(dlg, "PLACEMENT", "FULL"); + IupSetfAttribute(dlg, "TIP", "%s%s", IupGetAttribute(dlg, "TIP"), "\n.PLACEMENT=FULL."); + } + + count++; + if (count == 3) // cicle from 0 to 2 + count = 0; + + IupShow(dlg); + } + else if (test == 5) + { + IupPopup(dlg, IUP_CURRENT, IUP_CURRENT); + } + else if (test == 6) + { + IupSetAttribute(dlg, "FULLSCREEN", "YES"); + IupShow(dlg); + } +} + +static void create_images(void) +{ + Ihandle *image; + + image = IupImage(11, 11, pixmap_x); + IupSetAttribute(image, "0", "BGCOLOR"); + IupSetAttribute(image, "1", "0 1 0"); + IupSetAttribute(image, "2", "255 0 0"); + IupSetAttribute(image, "3", "255 255 0"); + IupSetHandle("DLG_ICON", image); + + image = IupImage(32, 32, pixmap_cursor); + IupSetAttribute(image, "0", "BGCOLOR"); /* always for cursor */ + IupSetAttribute(image, "1", "255 0 0"); + IupSetAttribute(image, "2", "128 0 0"); + IupSetAttribute(image, "HOTSPOT", "21:10"); + IupSetHandle("DLG_CURSOR", image); +} + +void DialogTest(void) +{ + create_images(); + + new_dialog(0, "IupDialog as a main window,\n" + "all decorations.\n" + "rastersize+centered."); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + DialogTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif + +/***************************************** +--------------TESTS------------------- + +to check IUP sizes x Native sizes: +in UNIX use xwininfo +in Windows use Spy++ +take screen shots, measure dlg sizes if necessary + +0- with all decorations + check: TITLE + TIP + CURSOR + BGCOLOR + RASTERSIZE (check window real size - 500x500) + CLOSE_CB, SHOW_CB, MAP_CB, K_ANY, GETFOCUS_CB, KILLFOCUS_CB, + HELP_CB, ENTERWINDOW_CB, LEAVEWINDOW_CB, RESIZE_CB + Close_cb using IupDestroy + closing main window will close child dialogs + Esc - call IupDestroy + 'h' = IupHide - no destroy + 'c' = return IUP_CLOSE - no destroy + +1- SIZE = FULLxFULL (check window real size) + press 'r' to change - RASTERSIZE+IupRefresh (300x300) + close_cb with IGNORE + +2- ShowXY (check position) + MINSIZE (300x300) and MAXSIZE (600x600) + Custom Icon and Cursor + +3- no decorations + +4- 1o. PLACEMENT MINIMIZED + 2o. PLACEMENT MAXIMIZED + 3o. PLACEMENT FULL + (press 'p' to change placement any time) + +5- only "dlg" decorations + IupPopup + 'c' = return IUP_CLOSE - no destroy + 'h' = IupHide - no destroy + 's' = IupShow for dialog0 + +6- FULLSCREEN + (press 'f' to change fullscreen any time) + +*/ diff --git a/iup/test/file_large.xbm b/iup/test/file_large.xbm new file mode 100755 index 0000000..c2095e9 --- /dev/null +++ b/iup/test/file_large.xbm @@ -0,0 +1,14 @@ +#define file_large_xbm_width 32 +#define file_large_xbm_height 32 +static char file_large_xbm_bits[] = { + 0xF0, 0xFF, 0x3F, 0x00, 0x10, 0x00, 0x60, 0x00, 0x10, 0x00, 0xA0, 0x00, + 0x10, 0x00, 0x20, 0x01, 0x10, 0x00, 0x20, 0x02, 0x10, 0x00, 0x20, 0x04, + 0x10, 0x00, 0x20, 0x08, 0x10, 0x00, 0xE0, 0x1F, 0x10, 0x00, 0x00, 0x10, + 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, + 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, + 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, + 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, + 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, + 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, + 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, + 0x10, 0x00, 0x00, 0x10, 0xF0, 0xFF, 0xFF, 0x1F }; diff --git a/iup/test/frame.c b/iup/test/frame.c new file mode 100755 index 0000000..2bcd128 --- /dev/null +++ b/iup/test/frame.c @@ -0,0 +1,68 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" + +void FrameTest(void) +{ + Ihandle *dlg, *frame1, *frame2; + + frame1 = IupFrame + ( + IupVbox + ( + IupLabel("Label1"), + IupSetAttributes(IupLabel("Label2"), "SIZE=70x"), + IupLabel("Label3"), + NULL + ) + ); + + frame2 = IupFrame + ( + IupVbox + ( + IupSetAttributes(IupLabel("Label4"), "EXPAND=HORIZONTAL"), + IupLabel("Label5"), + IupLabel("Label6"), + NULL + ) + ); + + IupSetAttribute(frame1, "TITLE", "Title Text"); +// IupSetAttribute(frame1, "FGCOLOR", "255 0 0"); +// IupSetAttribute(frame1, "BGCOLOR", "0 128 0"); + IupSetAttribute(frame2, "SUNKEN", "YES"); + + IupSetAttribute(frame1, "MARGIN", "0x0"); + IupSetAttribute(frame2, "MARGIN", "0x0"); +// IupSetAttribute(frame2, "BGCOLOR", "0 128 0"); + dlg = IupDialog(IupHbox(frame1, frame2, NULL)); + + IupSetAttribute(dlg, "TITLE", "IupFrame Test"); + IupSetAttribute(dlg, "MARGIN", "10x10"); + IupSetAttribute(dlg, "GAP", "5"); + IupSetAttribute(dlg, "FONTSIZE", "14"); +// IupSetAttribute(dlg, "RASTERSIZE", "300x200"); +// IupSetAttribute(dlg, "BGCOLOR", "0 128 0"); + + IupShow(dlg); + printf("RASTERSIZE(%s)\n", IupGetAttribute(frame1, "RASTERSIZE")); + printf("CLIENTSIZE(%s)\n", IupGetAttribute(frame1, "CLIENTSIZE")); + printf("RASTERSIZE(%s)\n", IupGetAttribute(frame2, "RASTERSIZE")); + printf("CLIENTSIZE(%s)\n", IupGetAttribute(frame2, "CLIENTSIZE")); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + FrameTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/gauge.c b/iup/test/gauge.c new file mode 100755 index 0000000..12e3c76 --- /dev/null +++ b/iup/test/gauge.c @@ -0,0 +1,305 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "iup.h" +#include "iupcontrols.h" + +static float increment = 0.01f; +static Ihandle *gauge; +static Ihandle *btn_pause; +static Ihandle *timer; + +static unsigned char pixmap_play[] = +{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }; + +static unsigned char pixmap_restart[] = +{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }; + +static unsigned char pixmap_rewind[] = +{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }; + +static unsigned char pixmap_forward[] = +{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }; + +static unsigned char pixmap_pause[] = +{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }; + +static void createimg_s (void) +{ + Ihandle *img_restart, *img_play, *img_forward, *img_rewind, *img_pause; + + img_restart = IupImage(22,22, pixmap_restart); + img_play = IupImage(22,22, pixmap_play); + img_forward = IupImage(22,22, pixmap_forward); + img_rewind = IupImage(22,22, pixmap_rewind); + img_pause = IupImage(22,22, pixmap_pause); + + IupSetHandle ("img_restart", img_restart); + IupSetHandle ("img_play", img_play); + IupSetHandle ("img_forward", img_forward); + IupSetHandle ("img_rewind", img_rewind); + IupSetHandle ("img_pause", img_pause); + + IupSetAttribute (img_restart, "1", "0 0 0"); + IupSetAttribute (img_restart, "2", "BGCOLOR"); + IupSetAttribute (img_play, "1", "0 0 0"); + IupSetAttribute (img_play, "2", "BGCOLOR"); + IupSetAttribute (img_forward, "1", "0 0 0"); + IupSetAttribute (img_forward, "2", "BGCOLOR"); + IupSetAttribute (img_rewind, "1", "0 0 0"); + IupSetAttribute (img_rewind, "2", "BGCOLOR"); + IupSetAttribute (img_pause, "1", "0 0 0"); + IupSetAttribute (img_pause, "2", "BGCOLOR"); +} + +static int time_cb(void) +{ + float value = IupGetFloat(gauge, "VALUE"); + value += increment; + if (value > 1) value = 0; /* start over */ + IupSetfAttribute(gauge, "VALUE", "%f", (double)value); + return IUP_DEFAULT; +} + +static int btn_pause_cb(void) +{ + if (!IupGetInt(timer, "RUN")) + { + IupSetAttribute(timer, "RUN", "YES"); + IupSetAttribute(btn_pause, "IMAGE", "img_pause"); + } + else + { + IupSetAttribute(timer, "RUN", "NO"); + IupSetAttribute(btn_pause, "IMAGE", "img_play"); + } + + return IUP_DEFAULT; +} + +static int btn_restart_cb(void) +{ + IupSetAttribute(gauge, "VALUE", "0"); + return IUP_DEFAULT; +} + +static int btn_accelerate_cb(void) +{ + increment *= 2; + return IUP_DEFAULT; +} + +static int btn_decelerate_cb(void) +{ + increment /= 2; + return IUP_DEFAULT; +} + +static int btn_show1_cb(void) +{ + if (!IupGetInt(gauge, "DASHED")) + IupSetAttribute(gauge, "DASHED", "YES"); + else + IupSetAttribute(gauge, "DASHED", "NO"); + + return IUP_DEFAULT; +} + +static int btn_show2_cb(void) +{ + if (!IupGetInt(gauge, "SHOW_TEXT")) + IupSetAttribute(gauge, "SHOW_TEXT", "YES"); + else + IupSetAttribute(gauge, "SHOW_TEXT", "NO"); + + return IUP_DEFAULT; +} + +void GaugeTest(void) +{ + Ihandle *dlg, *vbox, *hbox; + Ihandle *btn_restart, *btn_accelerate, *btn_decelerate, *btn_show1, *btn_show2; + + timer = IupTimer(); + IupSetCallback(timer, "ACTION_CB", (Icallback)time_cb); + IupSetAttribute(timer, "TIME", "100"); + + gauge = IupGauge(); + + IupSetAttribute(gauge, "EXPAND", "YES"); +// IupSetAttribute(gauge, "BGCOLOR", "255 0 128"); +// IupSetAttribute(gauge, "FGCOLOR", "0 128 0"); + + btn_restart = IupButton(NULL, NULL); + btn_pause = IupButton(NULL, NULL); + btn_accelerate = IupButton(NULL, NULL); + btn_decelerate = IupButton(NULL, NULL); + btn_show1 = IupButton("Dashed", NULL); + btn_show2 = IupButton("Text", NULL); + + createimg_s(); + + IupSetAttribute(btn_restart, "IMAGE", "img_restart"); + IupSetAttribute(btn_restart, "TIP", "Restart" ); + IupSetAttribute(btn_pause, "IMAGE", "img_pause"); + IupSetAttribute(btn_pause, "TIP", "Play/Pause"); + IupSetAttribute(btn_accelerate, "IMAGE", "img_forward"); + IupSetAttribute(btn_accelerate, "TIP", "Accelerate"); + IupSetAttribute(btn_decelerate, "IMAGE", "img_rewind"); + IupSetAttribute(btn_decelerate, "TIP", "Decelerate"); + IupSetAttribute(btn_show1, "TIP", "Dashed or Continuous"); + IupSetAttribute(btn_show2, "TIP", "Text or None"); + + hbox = IupHbox + ( + IupFill(), + btn_pause, + btn_restart, + btn_decelerate, + btn_accelerate, + btn_show1, + btn_show2, + IupFill(), + NULL + ); + + vbox = IupVbox(gauge, hbox, NULL); + IupSetAttribute(vbox, "MARGIN", "10x10"); + IupSetAttribute(vbox, "GAP", "5"); + + dlg = IupDialog(vbox); + + IupSetAttribute(dlg, "TITLE", "IupGauge Test"); + + IupSetCallback(btn_pause, "ACTION", (Icallback) btn_pause_cb); + IupSetCallback(btn_restart, "ACTION", (Icallback) btn_restart_cb); + IupSetCallback(btn_accelerate, "ACTION", (Icallback) btn_accelerate_cb); + IupSetCallback(btn_decelerate, "ACTION", (Icallback) btn_decelerate_cb); + IupSetCallback(btn_show1, "ACTION", (Icallback) btn_show1_cb); + IupSetCallback(btn_show2, "ACTION", (Icallback) btn_show2_cb); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); + + IupSetAttribute(timer, "RUN", "YES"); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupControlsOpen(); + + GaugeTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/getcolor.c b/iup/test/getcolor.c new file mode 100755 index 0000000..02ceb8d --- /dev/null +++ b/iup/test/getcolor.c @@ -0,0 +1,28 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "iup.h" +#include "iupcontrols.h" + +void GetColorTest(void) +{ + unsigned char r = 10, g = 100, b = 25; + if (IupGetColor(100, 100, &r, &g, &b)) + printf("RGB = %d, %d, %d Hex=[%.2X%.2X%.2X]\n", r, g, b, r, g, b); +} + + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + GetColorTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/getparam.c b/iup/test/getparam.c new file mode 100755 index 0000000..fbda6bb --- /dev/null +++ b/iup/test/getparam.c @@ -0,0 +1,98 @@ +/* IupGetParam Example in C + Shows a dialog with all the possible fields. +*/ +#include <stdlib.h> +#include <stdio.h> + +#include <iup.h> +#include <iupcontrols.h> + +static int param_action(Ihandle* dialog, int param_index, void* user_data) +{ + switch(param_index) + { + case -1: + printf("IupGetParam - OK\n"); + break; + case -2: + printf("IupGetParam - Map\n"); + break; + case -3: + printf("IupGetParam - Cancel\n"); + break; +// case 1: +// return 0; + default: + { + Ihandle* param; + char param_str[50]; + sprintf(param_str, "PARAM%d", param_index); + param = (Ihandle*)IupGetAttribute(dialog, param_str); + printf("%s = %s\n", param_str, IupGetAttribute(param, "VALUE")); + break; + } + } + return 1; +} + +void GetParamTest(void) +{ + int pboolean = 1; + int pinteger = 3456; + float preal = 3.543f; + int pinteger2 = 192; + float preal2 = 0.5f; + float pangle = 90; + char pstring[100] = "string text"; + char pcolor[100] = "255 0 128"; + int plist = 2; + char pstring2[200] = "second text\nsecond line"; + char file_name[500] = "test.jpg"; + + if (!IupGetParam("Title", param_action, 0, + "Boolean: %b[No,Yes]\n" + "Integer: %i\n" + "Real 1: %r\n" + "Sep1 %t\n" + "Integer: %i[0,255]\n" + "Real 2: %r[-1.5,1.5,0.05]\n" + "Sep2 %t\n" + "Angle: %a[0,360]\n" + "String: %s\n" + "List: %l|item1|item2|item3|\n" + "File: %f[OPEN|*.bmp;*.jpg|CURRENT|NO|NO]\n" + "Color: %c{Color Tip}\n" + "Sep3 %t\n" + "Multiline: %m\n", + &pboolean, &pinteger, &preal, &pinteger2, &preal2, &pangle, pstring, &plist, file_name, pcolor, pstring2, NULL)) + return; + + IupMessagef("IupGetParam", + "Boolean Value: %d\n" + "Integer: %d\n" + "Real 1: %g\n" + "Integer: %d\n" + "Real 2: %g\n" + "Angle: %g\n" + "String: %s\n" + "List Index: %d\n" + "FileName: %s\n" + "Color: %s\n" + "Multiline: %s", + pboolean, pinteger, (double)preal, pinteger2, (double)preal2, (double)pangle, pstring, plist, file_name, pcolor, pstring2); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + GetParamTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/glcanvas.c b/iup/test/glcanvas.c new file mode 100755 index 0000000..6a34c29 --- /dev/null +++ b/iup/test/glcanvas.c @@ -0,0 +1,77 @@ +#ifdef USE_OPENGL +#ifdef WIN32 +#include <windows.h> +#endif +#include <GL/gl.h> + +#include <stdlib.h> +#include <stdio.h> + +#include "iup.h" +#include "iupgl.h" + + +static int action(Ihandle *ih) +{ + IupGLMakeCurrent(ih); + + glClearColor(1.0, 0.0, 1.0, 1.f); /* pink */ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glColor3f(1.0,0.0,0.0); /* red */ + glBegin(GL_QUADS); + glVertex2f(0.9f,0.9f); + glVertex2f(0.9f,-0.9f); + glVertex2f(-0.9f,-0.9f); + glVertex2f(-0.9f,0.9f); + glEnd(); + + IupGLSwapBuffers(ih); + + return IUP_DEFAULT; +} + +void GLCanvasTest(void) +{ + Ihandle *dlg, *canvas, *box; + + IupGLCanvasOpen(); + + box = IupVbox(NULL); + IupSetAttribute(box, "MARGIN", "5x5"); + + canvas = IupGLCanvas(NULL); + IupSetCallback(canvas, "ACTION", action); + IupSetAttribute(canvas, "BUFFER", "DOUBLE"); + IupSetAttribute(canvas, "BORDER", "NO"); + IupSetAttribute(canvas, "RASTERSIZE", "300x200"); + IupAppend(box, canvas); + + dlg = IupDialog(box); + IupSetAttribute(dlg, "TITLE", "IupGLCanvas Test"); + + IupMap(dlg); + IupGLMakeCurrent(canvas); + printf("Vendor: %s\n", glGetString(GL_VENDOR)); + printf("Renderer: %s\n", glGetString(GL_RENDERER)); + printf("Version: %s\n", glGetString(GL_VERSION)); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupGLCanvasOpen(); + + GLCanvasTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif +#endif diff --git a/iup/test/glcanvas_cube.c b/iup/test/glcanvas_cube.c new file mode 100755 index 0000000..3bd5ec5 --- /dev/null +++ b/iup/test/glcanvas_cube.c @@ -0,0 +1,234 @@ +#ifdef USE_OPENGL +#ifdef WIN32 +#include <windows.h> +#endif +#include <GL/gl.h> +#include <GL/glu.h> + +#include <stdlib.h> +#include <stdio.h> +#include <math.h> + +#include "iup.h" +#include "iupgl.h" + + +typedef struct _color3D +{ + double r; + double g; + double b; +} color3D; + +static void add_color_vertex(const color3D* c) +{ + glColor3d(c->r, c->g, c->b); + glVertex3d(c->r, c->g, c->b); +} + +static void draw_cube_face(const color3D* c1, const color3D* c2, const color3D* c3, const color3D* c4) +{ + color3D cm; + cm.r = (c1->r + c2->r + c3->r + c4->r)/4; + cm.g = (c1->g + c2->g + c3->g + c4->g)/4; + cm.b = (c1->b + c2->b + c3->b + c4->b)/4; + + add_color_vertex(&cm); + add_color_vertex(c1); + add_color_vertex(c2); + + add_color_vertex(&cm); + add_color_vertex(c2); + add_color_vertex(c3); + + add_color_vertex(&cm); + add_color_vertex(c3); + add_color_vertex(c4); + + add_color_vertex(&cm); + add_color_vertex(c4); + add_color_vertex(c1); +} + +const color3D c3D_black = {0.0, 0.0, 0.0}; +const color3D c3D_red = {1.0, 0.0, 0.0}; +const color3D c3D_green = {0.0, 1.0, 0.0}; +const color3D c3D_blue = {0.0, 0.0, 1.0}; +const color3D c3D_cian = {0.0, 1.0, 1.0}; +const color3D c3D_magenta = {1.0, 0.0, 1.0}; +const color3D c3D_yellow = {1.0, 1.0, 0.0}; +const color3D c3D_white = {1.0, 1.0, 1.0}; + +static void draw_cube(void) +{ + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + + draw_cube_face(&c3D_black, &c3D_blue, &c3D_magenta, &c3D_red); + draw_cube_face(&c3D_black, &c3D_green, &c3D_cian, &c3D_blue); + draw_cube_face(&c3D_black, &c3D_red, &c3D_yellow, &c3D_green); + draw_cube_face(&c3D_white, &c3D_cian, &c3D_blue, &c3D_magenta); + draw_cube_face(&c3D_white, &c3D_cian, &c3D_green, &c3D_yellow); + draw_cube_face(&c3D_white, &c3D_magenta, &c3D_red, &c3D_yellow); + + glEnd(); +} + +static void init(void) +{ + glClearColor(0.5,0.5,0.5,0.0); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45, 1, 1, 10); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + gluLookAt (0.5, 0.5, 3.0, /* posicao do observador */ + 0.5, 0.5, 0.0, /* ponto de referencia */ + 0.0, 1.0, 0.0); /* vup */ + glEnable(GL_DEPTH_TEST); + glClearDepth (1.0); +} + +static void unproject (double x2, double y2, double *x3, double *y3, double *z3) +{ + double mv[16]; + double pm[16]; + int vp[4]; + + glGetDoublev (GL_MODELVIEW_MATRIX, mv); + glGetDoublev (GL_PROJECTION_MATRIX, pm); + glGetIntegerv (GL_VIEWPORT, vp); + gluUnProject (x2, y2, 0.0, + mv, pm, vp, + x3, y3, z3); +} + +static int pos_x, pos_y; +static int move = 0; + +static int button_cb(Ihandle *ih,int but,int pressed,int x,int y,char* status) +{ + (void)ih; + (void)status; + + if (but==IUP_BUTTON1) + { + if (pressed) + { + pos_x = x; + pos_y = y; + move = 1; + } + else + { + move = 0; + } + } + return IUP_DEFAULT; +} + +#define INVERT_Y(_y) (height-y) + +static int motion_cb(Ihandle *ih,int x,int y,char* status) +{ + (void)status; + + if (move) + { + double dif_x, dif_y; + double dx, dy, dz; + double x1, y1, z1; + double x2, y2, z2; + double angle, norma; + int height = IupGetInt2(ih, "RASTERSIZE"); + + IupGLMakeCurrent(ih); + + dif_x = x - pos_x; + dif_y = y - pos_y; + + pos_x = x; + pos_y = y; + + angle = sqrt(dif_x*dif_x + dif_y*dif_y); + + unproject (pos_x, INVERT_Y(pos_y), &x1, &y1, &z1); + unproject ((double)(dif_y+pos_x), (double)(dif_x+INVERT_Y(pos_y)), &x2, &y2, &z2); + dx = x2-x1; dy = y2-y1; dz = z2-z1; + norma = sqrt(dx*dx + dy*dy + dz*dz); + dx /= norma; dy /= norma; dz /= norma; + + glTranslated(0.5, 0.5, 0.5); + glRotated (angle, dx, dy, dz); + glTranslated(-0.5, -0.5, -0.5); + + draw_cube(); + + IupGLSwapBuffers(ih); + } + return IUP_DEFAULT; +} + +static int action(Ihandle *ih) +{ + IupGLMakeCurrent(ih); + + glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + draw_cube(); + + IupGLSwapBuffers(ih); + + return IUP_DEFAULT; +} + +void GLCanvasCubeTest(void) +{ + Ihandle *dlg, *canvas, *box; + + IupGLCanvasOpen(); + + box = IupVbox(NULL); + IupSetAttribute(box, "MARGIN", "5x5"); + + canvas = IupGLCanvas(NULL); + IupSetCallback(canvas, "ACTION", action); + IupSetCallback(canvas, "BUTTON_CB", (Icallback)button_cb); + IupSetCallback(canvas, "MOTION_CB", (Icallback)motion_cb); + IupSetAttribute(canvas, "BUFFER", "DOUBLE"); + IupSetAttribute(canvas, "RASTERSIZE", "300x300"); + IupAppend(box, canvas); + + dlg = IupDialog(IupSetAttributes(IupFrame(box), "TITLE=Teste")); + IupSetAttribute(dlg, "TITLE", "IupGLCanvas Test"); + IupSetAttribute(dlg, "COMPOSITED", "NO"); + + IupMap(dlg); + + IupGLMakeCurrent(canvas); + init(); + printf("Vendor: %s\n", glGetString(GL_VENDOR)); + printf("Renderer: %s\n", glGetString(GL_RENDERER)); + printf("Version: %s\n", glGetString(GL_VERSION)); + IupSetAttribute(canvas, "RASTERSIZE", NULL); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + GLCanvasCubeTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif +#endif diff --git a/iup/test/hbox.c b/iup/test/hbox.c new file mode 100755 index 0000000..44f0f02 --- /dev/null +++ b/iup/test/hbox.c @@ -0,0 +1,114 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" + +void HboxTest(void) +{ + /* IUP identifiers */ + Ihandle *fr1, *fr2, *fr3, *dlg; + Ihandle *b11, *b12, *b13; + Ihandle *b21, *b22, *b23; + Ihandle *b31, *b32, *b33; + Ihandle *h1, *h2, *h3; + + /* Creates frame with three top aligned buttons */ + fr1 = IupFrame + ( + h1 = IupHbox + ( +// IupFill(), + b11=IupButton("1", NULL), + b12=IupButton("2", NULL), + b13=IupButton("3", NULL), +// IupFill(), + NULL + ) + ); +// IupSetAttribute(fr1, "TITLE", "ALIGNMENT=ATOP"); + IupSetAttribute(fr1, "TITLE", "IupHbox"); + IupSetAttribute(b11, "SIZE", "10x10"); + IupSetAttribute(b12, "SIZE", "20x16"); + IupSetAttribute(b13, "SIZE", "30x20"); + IupSetAttributes(h1, "ALIGNMENT=ATOP"); /* Sets hbox's alignment, gap and size */ + IupSetAttribute(h1, "HOMOGENEOUS", "YES"); + IupSetAttribute(h1, "EXPANDCHILDREN", "YES"); +// IupSetAttribute(b12, "VISIBLE", "NO"); +// IupSetAttribute(b12, "FLOATING", "YES"); + + /* Creates frame with three buttons */ + fr2 = IupFrame + ( + h2=IupHbox + ( + IupFill(), + b21=IupButton("1", NULL), + b22=IupButton("2", NULL), + b23=IupButton("3", NULL), + IupFill(), + NULL + ) + ); + IupSetAttribute(fr2, "TITLE", "ALIGNMENT=ACENTER, GAP=20"); + IupSetAttribute(b21, "SIZE", "30x30"); + IupSetAttribute(b22, "SIZE", "30x40"); + IupSetAttribute(b23, "SIZE", "30x50"); + IupSetAttributes(h2, "ALIGNMENT=ACENTER, GAP=20"); /* Sets hbox's alignment and gap */ + + /* Creates frame with three bottom aligned buttons */ + fr3 = IupFrame + ( + h3=IupHbox + ( + IupFill(), + b31=IupButton ("1", NULL), + b32=IupButton ("2", NULL), + b33=IupButton ("3", NULL), + IupFill(), + NULL + ) + ); + IupSetAttribute(fr3, "TITLE", "ALIGNMENT=ABOTTOM, MARGIN=10x10"); + IupSetAttribute(b31, "SIZE", "30x30"); + IupSetAttribute(b32, "SIZE", "30x40"); + IupSetAttribute(b33, "SIZE", "30x50"); + IupSetAttributes(h3, "ALIGNMENT=ABOTTOM, MARGIN=10x10"); /* Sets hbox's alignment and size */ + + /* Creates dlg with the three frames */ + dlg = IupDialog + ( + IupVbox + ( + fr1, + fr2, + fr3, + NULL + ) + ); + + IupSetAttribute(dlg, "TITLE", "IupHbox Test"); /* Sets dlg's title */ + IupSetAttribute(dlg, "MARGIN", "10x10"); + IupSetAttribute(dlg, "GAP", "10"); + IupSetAttribute(fr1, "MARGIN", "0x0"); /* avoid attribute propagation */ + IupSetAttribute(fr2, "MARGIN", "0x0"); + IupSetAttribute(fr3, "MARGIN", "0x0"); + IupSetAttribute(fr1, "GAP", "0"); + IupSetAttribute(fr2, "GAP", "0"); + IupSetAttribute(fr3, "GAP", "0"); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); /* Shows dlg in the center of the screen */ +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + HboxTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/idle.c b/iup/test/idle.c new file mode 100755 index 0000000..f9681ba --- /dev/null +++ b/iup/test/idle.c @@ -0,0 +1,55 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" + +static int idle_count = 0; + +static int idle(void) +{ + printf("IDLE_ACTION(count = %d)\n", idle_count); + idle_count++; + +// if (idle_count == 10000) +// return IUP_IGNORE; + + return IUP_DEFAULT; +} + +static int motion_cb(Ihandle* ih) +{ + printf("MOTION_CB()\n"); + if (idle_count > 30000) + IupSetFunction ("IDLE_ACTION", NULL); + return IUP_DEFAULT; +} + +void IdleTest(void) +{ + Ihandle* dlg, *canvas; + + canvas = IupCanvas(NULL); + IupSetCallback(canvas, "MOTION_CB", motion_cb); + + dlg = IupDialog(canvas); + IupSetAttribute(dlg, "TITLE", "Idle Test"); + IupSetAttribute(dlg, "RASTERSIZE", "500x500"); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); + + IupSetFunction ("IDLE_ACTION", (Icallback)idle); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + IdleTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/iuptest.rc b/iup/test/iuptest.rc new file mode 100755 index 0000000..94e5ca1 --- /dev/null +++ b/iup/test/iuptest.rc @@ -0,0 +1,31 @@ +TECGRAF_ICON ICON "../etc/tecgraf.ico" +TECGRAF_BITMAP BITMAP "../test/tecgraf.bmp" + +CURSOR_PEN CURSOR "../etc/pen.cur" + +/* To avoid the inclusion of <winuser.h> */ +#define WS_CHILD 0x40000000L +#define WS_VISIBLE 0x10000000L +#define WS_CLIPSIBLINGS 0x04000000L +#define DS_3DLOOK 0x0004L +#define DS_CONTROL 0x0400L +#define SS_OWNERDRAW 0x0000000DL +#define WS_EX_STATICEDGE 0x00020000L + +#define IUP_PREVIEWCANVAS 3000 + +iupPreviewDlg DIALOG DISCARDABLE 0, 0, 250, 95 +STYLE WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | DS_3DLOOK | DS_CONTROL +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "", IUP_PREVIEWCANVAS, "STATIC", SS_OWNERDRAW, 70, 0, 120, 90, WS_EX_STATICEDGE +END + +#ifndef IUP_DLL +/* The following line will enable Windows XP Visual Styles */ +#ifdef WIN64 +1 24 "../etc/iup64.manifest" +#else +1 24 "../etc/iup.manifest" +#endif +#endif diff --git a/iup/test/label.c b/iup/test/label.c new file mode 100755 index 0000000..1eea959 --- /dev/null +++ b/iup/test/label.c @@ -0,0 +1,217 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" + + +#define TEST_IMAGE_SIZE 20 + +static unsigned char image_data_8 [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE] = +{ + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +}; + +static unsigned char image_data_24 [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE*3] = +{ + 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000, + 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, +}; + +static unsigned char image_data_32 [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE*4] = +{ + 000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,000,000,255,255,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,255,255,255,192,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255, + 000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255,000,000,000,255, +}; + +static int enter_cb(Ihandle *ih) +{ + Ihandle *box = IupGetChild(ih, 0); + if (IupGetInt(box, "ACTIVE")) + IupSetAttribute(box, "ACTIVE", "NO"); + else + IupSetAttribute(box, "ACTIVE", "YES"); + return IUP_DEFAULT; +} + +void LabelTest(void) +{ + Ihandle *dlg, *label, *image1, *image2, *image3, + *box1, *box2, *fill; + + box1 = IupVbox(NULL); + IupSetAttribute(box1, "MARGIN", "5x5"); + IupSetAttribute(box1, "GAP", "5"); + IupSetAttribute(box1, "BGCOLOR", "75 150 170"); + IupSetAttribute(box1, "PADDING", "5x5"); + + label = IupLabel(NULL); + IupSetAttribute(label, "TITLE", "Text Labels (ηγν)"); + IupSetAttribute(label, "BGCOLOR", IupGetGlobal("DLGBGCOLOR")); + IupSetAttribute(label, "PADDING", "0x0"); + IupSetAttribute(label, "TIP", "Text Label"); + IupAppend(box1, label); + + label = IupLabel(NULL); + IupSetAttribute(label, "SEPARATOR", "HORIZONTAL"); + IupAppend(box1, label); + + label = IupLabel(NULL); + IupSetAttribute(label, "TITLE", "Text &Label\nSecond Line"); + IupSetAttribute(label, "FGCOLOR", "0 0 255"); + IupSetAttribute(label, "RASTERSIZE", "150x70"); +// IupSetAttribute(label, "RASTERSIZE", "30x70"); +// IupSetAttribute(label, "WORDWRAP", "YES"); +// IupSetAttribute(label, "ELLIPSIS", "YES"); + IupSetAttribute(label, "ALIGNMENT", "ALEFT:ATOP"); + IupAppend(box1, label); + + label = IupLabel(NULL); + IupSetAttribute(label, "TITLE", "Text Label\nSecond Line"); + IupSetAttribute(label, "RASTERSIZE", "150x70"); + IupSetAttribute(label, "ALIGNMENT", "ACENTER:ACENTER"); + IupSetAttribute(label, "FONT", "Helvetica, 14"); +// IupSetAttribute(label, "FONTSIZE", "14"); +// IupSetAttribute(label, "FONTSTYLE", "Italic"); + IupAppend(box1, label); + + label = IupLabel(NULL); + IupSetAttribute(label, "TITLE", "Text Label\n<b>Second Line</b>"); + IupSetAttribute(label, "RASTERSIZE", "150x70"); + IupSetAttribute(label, "ALIGNMENT", "ARIGHT:ABOTTOM"); + IupSetAttribute(label, "MARKUP", "YES"); + IupAppend(box1, label); + + box2 = IupVbox(NULL); + IupSetAttribute(box2, "MARGIN", "5x5"); + IupSetAttribute(box2, "GAP", "5"); + IupSetAttribute(box2, "BGCOLOR", "75 150 170"); + IupSetAttribute(box2, "PADDING", "5x5"); + + image1 = IupImage(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_8); + IupSetAttribute(image1, "0", "BGCOLOR"); + IupSetAttribute(image1, "1", "255 0 0"); + IupSetAttribute(image1, "2", "0 255 0"); + IupSetAttribute(image1, "3", "0 0 255"); + IupSetAttribute(image1, "4", "255 255 255"); + IupSetAttribute(image1, "5", "0 0 0"); + + label = IupLabel(NULL); + IupSetAttributeHandle(label, "IMAGE", image1); + //IupSetAttribute(label, "IMAGE", "TECGRAF_BITMAP"); + //IupSetAttribute(label, "IMAGE", "../test/tecgraf.bmp"); + //IupSetAttribute(label, "IMAGE", "../test/file_large.xbm"); + //IupSetAttribute(label, "IMAGE", "gtk-open"); + IupSetAttribute(label, "BGCOLOR", IupGetGlobal("DLGBGCOLOR")); + IupSetAttribute(label, "PADDING", "0x0"); + IupSetAttribute(label, "TIP", "Image Label"); + IupAppend(box2, label); + + label = IupLabel(NULL); + IupSetAttribute(label, "SEPARATOR", "HORIZONTAL"); + IupAppend(box2, label); + + fill = IupFill(); + IupSetAttribute(fill, "SIZE", "20"); + IupAppend(box2, fill); + + label = IupLabel(NULL); + IupSetAttributeHandle(label, "IMAGE", image1); + IupSetAttribute(label, "RASTERSIZE", "150x50"); + IupAppend(box2, label); + + image2 = IupImageRGB(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_24); + + label = IupLabel(NULL); + IupSetAttributeHandle(label, "IMAGE", image2); + IupSetAttribute(label, "RASTERSIZE", "150x50"); + IupSetAttribute(label, "ALIGNMENT", "ACENTER"); + IupAppend(box2, label); + + image3 = IupImageRGBA(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_32); + + label = IupLabel(NULL); + IupSetAttributeHandle(label, "IMAGE", image3); + IupSetAttribute(label, "RASTERSIZE", "150x50"); + IupSetAttribute(label, "ALIGNMENT", "ARIGHT"); + IupAppend(box2, label); + + label = IupLabel(NULL); + IupSetAttribute(label, "SEPARATOR", "VERTICAL"); + + dlg = IupDialog(IupHbox(box1, label, box2, NULL)); + IupSetAttribute(dlg, "TITLE", "IupLabel Test"); +// IupSetAttribute(dlg, "BACKGROUND", "0 0 128"); +// IupSetAttributeHandle(dlg, "BACKGROUND", image2); + IupSetCallback(dlg, "ENTERWINDOW_CB", enter_cb); + + IupShow(dlg); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + LabelTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/list.c b/iup/test/list.c new file mode 100755 index 0000000..5db582b --- /dev/null +++ b/iup/test/list.c @@ -0,0 +1,366 @@ +#include <stdlib.h> +#include <stdio.h> +#include <iup.h> +#include <iupkey.h> + +static int button_cb(Ihandle *ih,int but,int pressed,int x,int y,char* status) +{ + printf("BUTTON_CB(but=%c (%d), x=%d, y=%d [%s]) - [pos=%d]\n",(char)but,pressed,x,y, status, IupConvertXYToPos(ih, x, y)); + return IUP_DEFAULT; +} + +static int motion_cb(Ihandle *ih,int x,int y,char* status) +{ + printf("MOTION_CB(x=%d, y=%d [%s]) - [pos=%d]\n",x,y, status,IupConvertXYToPos(ih, x, y)); + return IUP_DEFAULT; +} + +static int multilist_cb (Ihandle *ih, char *s) +{ + printf("MULTISELECT_CB(%s)\n", s); + return IUP_DEFAULT; +} + +static int list_cb (Ihandle *ih, char *t, int i, int v) +{ + printf("ACTION(%s - %d %d)\n", t, i, v); + return IUP_DEFAULT; +} + +static int dropdown_cb(Ihandle *ih, int state) +{ + printf("DROPDOWN_CB(%d)\n", state); + return IUP_DEFAULT; +} + +static int dblclick_cb(Ihandle *ih, int pos, char *text) +{ + printf("DBLCLICK_CB(%d - %s)\n", pos, text); + return IUP_DEFAULT; +} + +static int edit_cb (Ihandle *ih, int c, char *after) +{ + printf("EDIT_CB(%d - %s)\n", c, after); + return IUP_DEFAULT; +} + +static int caret_cb(Ihandle *ih, int lin, int col) +{ + printf("CARET_CB(%d, %d)\n", lin, col); + return IUP_DEFAULT; +} + +static int btok_cb(Ihandle *ih) +{ + printf("Default Enter\n"); + return IUP_DEFAULT; +} + +static int btcancel_cb(Ihandle *ih) +{ + printf("Default Esc\n"); + return IUP_DEFAULT; +} + +static int selectedtext_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute(text, "VALUE", IupGetAttribute(list, "SELECTEDTEXT")); + return IUP_DEFAULT; +} + +static int selection_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute(text, "VALUE", IupGetAttribute(list, "SELECTION")); + return IUP_DEFAULT; +} + +static int getcaret_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute(text, "VALUE", IupGetAttribute(list, "CARET")); + return IUP_DEFAULT; +} + +static int getvalue_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute(text, "VALUE", IupGetAttribute(list, "VALUE")); + return IUP_DEFAULT; +} + +static int getcount_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + printf("COUNT=%s\n", IupGetAttribute(list, "COUNT")); + return IUP_DEFAULT; +} + +static int append_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute(list, "APPEND", IupGetAttribute(text, "VALUE")); + return IUP_DEFAULT; +} + +static int readonly_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute(list, "READONLY", IupGetAttribute(text, "VALUE")); + return IUP_DEFAULT; +} + +static int setvalue_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute(list, "VALUE", IupGetAttribute(text, "VALUE")); + return IUP_DEFAULT; +} + +static int insertitem_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute(list, "INSERTITEM3", IupGetAttribute(text, "VALUE")); + return IUP_DEFAULT; +} + +static int appenditem_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute(list, "APPENDITEM", IupGetAttribute(text, "VALUE")); + return IUP_DEFAULT; +} + +static int removeitem_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute(list, "REMOVEITEM", IupGetAttribute(text, "VALUE")); + return IUP_DEFAULT; +} + +static int topitem_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute(list, "TOPITEM", IupGetAttribute(text, "VALUE")); + return IUP_DEFAULT; +} + +static int showdropdown_cb(Ihandle *ih) +{ + Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); + IupSetAttribute(list, "SHOWDROPDOWN", "YES"); + return IUP_DEFAULT; +} + +static void setactivelist(Ihandle* ih) +{ + Ihandle* dialog = IupGetDialog(ih); + Ihandle* label = (Ihandle*)IupGetAttribute(dialog, "_LABEL"); + IupSetAttribute(dialog, "_ACTIVE_LIST", (char*)ih); + IupSetAttribute(label, "TITLE", IupGetAttribute(IupGetParent(IupGetParent(ih)), "TITLE")); +} + +static int getfocus_cb(Ihandle *ih) +{ + setactivelist(ih); + printf("GETFOCUS_CB(%s)\n", IupGetAttribute(IupGetParent(IupGetParent(ih)), "TITLE")); + return IUP_DEFAULT; +} + +static int killfocus_cb(Ihandle *ih) +{ + printf("KILLFOCUS_CB(%s)\n", IupGetAttribute(IupGetParent(IupGetParent(ih)), "TITLE")); + return IUP_DEFAULT; +} + +static int leavewindow_cb(Ihandle *ih) +{ + printf("LEAVEWINDOW_CB(%s)\n", IupGetAttribute(IupGetParent(IupGetParent(ih)), "TITLE")); + return IUP_DEFAULT; +} + +static int enterwindow_cb(Ihandle *ih) +{ + setactivelist(ih); + printf("ENTERWINDOW_CB(%s)\n", IupGetAttribute(IupGetParent(IupGetParent(ih)), "TITLE")); + return IUP_DEFAULT; +} + +char *iupKeyCodeToName(int code); + +static int k_any(Ihandle *ih, int c) +{ + if (iup_isprint(c)) + printf("K_ANY(%s, %d = %s \'%c\')\n", IupGetAttribute(IupGetParent(IupGetParent(ih)), "TITLE"), c, iupKeyCodeToName(c), (char)c); + else + printf("K_ANY(%s, %d = %s)\n", IupGetAttribute(IupGetParent(IupGetParent(ih)), "TITLE"), c, iupKeyCodeToName(c)); + return IUP_CONTINUE; +} + +static int help_cb(Ihandle* ih) +{ + printf("HELP_CB(%s)\n", IupGetAttribute(IupGetParent(IupGetParent(ih)), "TITLE")); + return IUP_DEFAULT; +} + +static void set_callbacks(Ihandle* list) +{ + IupSetCallback(list, "ACTION", (Icallback)list_cb); + IupSetCallback(list, "DBLCLICK_CB", (Icallback)dblclick_cb); + IupSetCallback(list, "DROPDOWN_CB", (Icallback)dropdown_cb); + IupSetCallback(list, "EDIT_CB", (Icallback)edit_cb); + IupSetCallback(list, "CARET_CB", (Icallback)caret_cb); +// IupSetCallback(list, "BUTTON_CB", (Icallback)button_cb); +// IupSetCallback(list, "MOTION_CB", (Icallback)motion_cb); + + //IupSetCallback(list, "GETFOCUS_CB", getfocus_cb); + //IupSetCallback(list, "KILLFOCUS_CB", killfocus_cb); + + IupSetCallback(list, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); + //IupSetCallback(list, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); + + //IupSetCallback(list, "K_ANY", (Icallback)k_any); + //IupSetCallback(list, "HELP_CB", (Icallback)help_cb); + +// IupSetAttribute(list, "DROPEXPAND", "NO"); +// IupSetAttribute(list, "AUTOHIDE", "NO"); +// IupSetAttribute(list, "SCROLLBAR", "NO"); + + IupSetAttribute(list, "VISIBLE_ITEMS", "3"); +// IupSetAttribute(list, "VISIBLECOLUMNS", "7"); + IupSetAttribute(list, "VISIBLELINES", "4"); +} + +void ListTest(void) +{ + Ihandle *dlg, *list1, *list2, *list3, *list4, *text, *btok, *btcancel, + *box, *lists, *buttons1, *buttons2, *buttons3, *label; + + list1 = IupList(NULL); + list2 = IupList(NULL); + list3 = IupList(NULL); + list4 = IupList(NULL); + + IupSetAttributes(list1, "1=\"US$ 1000\", 2=\"US$ 2000\", 3=\"US$ 300.000.000\", 4=\"US$ 4000\"," + "EDITBOX=YES, DROPDOWN=YES, TIP=Edit+Drop, VALUE=\"Edit Here\", NAME=list1"); + IupSetAttributes(list2, "1=\"Banana\", 2=\"Apple\", 3=\"Orange\", 4=\"Strawberry\", 5=\"Grape\"," + "DROPDOWN=YES, NAME=list2, TIP=Drop, VALUE=2, SORT=YES"); + IupSetAttributes(list3, "1=\"Char A\", 2=\"Char B\", 3=\"Char CCCCC\", 4=\"Char D\", 5=\"Char E\", 6=\"Char F\"," + "EDITBOX=YES, NAME=list3, TIP=Edit+List, VALUE=\"Edit Here\""); +// IupSetAttributes(list4, "1=\"Number 1\", 2=\"Number 2\", 3=\"Number 3\", 4=\"Number 4\", 5=\"Number 5\", 6=\"Number 6\", 7=\"Number 7\"," +// "MULTIPLE=YES, NAME=list4, TIP=List, VALUE=+--++--"); + IupSetAttributes(list4, "1=\"Number 3\", 2=\"Number 4\", 3=\"Number 2\", 4=\"Number 1\", 5=\"Number 6\", 6=\"Number 5\", 7=\"Number 7\"," + "MULTIPLE=YES, NAME=list4, TIP=List, SORT=YES, VALUE=+--++--"); + + set_callbacks(list1); + set_callbacks(list2); + set_callbacks(list3); + set_callbacks(list4); + + //IupSetAttributes(list2, "6=\"R$ 1000\", 7=\"R$ 2000\", 8=\"R$ 123456789\", 9=\"R$ 4000\", 10=\"R$ 5000\","); + //IupSetAttributes(list2, "11=\"R$ 1000\", 12=\"R$ 2000\", 13=\"R$ 123456789\", 14=\"R$ 4000\", 15=\"R$ 5000\","); + //IupSetAttributes(list2, "16=\"R$ 1000\", 17=\"R$ 2000\", 18=\"R$ 123456789\", 19=\"R$ 4000\", 20=\"R$ 5000\","); + + IupSetCallback(list4, "MULTISELECT_CB", (Icallback)multilist_cb); + +// IupSetAttribute(list1, "READONLY", "YES"); +// IupSetAttribute(list3, "READONLY", "YES"); +// IupSetAttribute(list1, "PADDING", "10x10"); +// IupSetAttribute(list3, "PADDING", "10x10"); + +// IupSetAttribute(list3, "SPACING", "10"); +// IupSetAttribute(list4, "SPACING", "10"); + + printf("COUNT(list1)=%s\n", IupGetAttribute(list1, "COUNT")); + printf("COUNT(list2)=%s\n", IupGetAttribute(list2, "COUNT")); + printf("COUNT(list3)=%s\n", IupGetAttribute(list3, "COUNT")); + printf("COUNT(list4)=%s\n", IupGetAttribute(list4, "COUNT")); + + lists = IupHbox( + IupVbox( + IupSetAttributes(IupFrame(IupVbox(list1, NULL)), "TITLE=EDITBOX+DROPDOWN"), + IupSetAttributes(IupFrame(IupVbox(list2, NULL)), "TITLE=DROPDOWN"), + NULL), + IupSetAttributes(IupFrame(IupVbox(list3, NULL)), "TITLE=EDITBOX"), + IupSetAttributes(IupFrame(IupVbox(list4, NULL)), "TITLE=MULTIPLE"), + IupVbox( + btok = IupSetCallbacks(IupButton("Default Enter", NULL), "ACTION", btok_cb, NULL), + btcancel = IupSetCallbacks(IupButton("Default Esc", NULL), "ACTION", btcancel_cb, NULL), + NULL), + NULL); + + text = IupText(NULL); + IupSetAttribute(text, "EXPAND", "HORIZONTAL"); + IupSetAttribute(text, "NAME", "text"); + + buttons1 = IupHbox( + IupSetCallbacks(IupButton("Get(VALUE)", NULL), "ACTION", getvalue_cb, NULL), + IupSetCallbacks(IupButton("Set(VALUE)", NULL), "ACTION", setvalue_cb, NULL), + IupSetCallbacks(IupButton("Get(COUNT)", NULL), "ACTION", getcount_cb, NULL), + NULL); + buttons2 = IupHbox( + IupSetCallbacks(IupButton("INSERTITEM3", NULL), "ACTION", insertitem_cb, NULL), + IupSetCallbacks(IupButton("APPENDITEM", NULL), "ACTION", appenditem_cb, NULL), + IupSetCallbacks(IupButton("REMOVEITEM", NULL), "ACTION", removeitem_cb, NULL), + IupSetCallbacks(IupButton("SHOWDROPDOWN", NULL), "ACTION", showdropdown_cb, NULL), + IupSetCallbacks(IupButton("TOPITEM", NULL), "ACTION", topitem_cb, NULL), + NULL); + buttons3 = IupHbox( + IupSetCallbacks(IupButton("APPEND", NULL), "ACTION", append_cb, NULL), + IupSetCallbacks(IupButton("Get(CARET)", NULL), "ACTION", getcaret_cb, NULL), + IupSetCallbacks(IupButton("Set(READONLY)", NULL), "ACTION", readonly_cb, NULL), + IupSetCallbacks(IupButton("Get(SELECTEDTEXT)", NULL), "ACTION", selectedtext_cb, NULL), + IupSetCallbacks(IupButton("Get(SELECTION)", NULL), "ACTION", selection_cb, NULL), + NULL); + + box = IupVbox(lists, IupHbox(IupLabel("Attrib. Value: "), text, NULL), buttons1, buttons2, buttons3, IupHbox(IupLabel("Current List: "), label = IupLabel(NULL), NULL), NULL); + IupSetAttributes(buttons1,"MARGIN=5x5, GAP=5"); + IupSetAttributes(buttons2,"MARGIN=5x5, GAP=5"); + IupSetAttributes(buttons3,"MARGIN=5x5, GAP=5"); + IupSetAttributes(lists,"MARGIN=10x10, GAP=10"); + IupSetAttribute(label,"EXPAND", "HORIZONTAL"); + + dlg = IupDialog(box); + IupSetAttribute(dlg, "TITLE", "IupList Test"); + IupSetAttributeHandle(dlg, "DEFAULTENTER", btok); + IupSetAttributeHandle(dlg, "DEFAULTESC", btcancel); + IupSetAttribute(dlg, "_LABEL", (char*)label); + +// IupSetAttribute(box, "BGCOLOR", "92 92 255"); +// IupSetAttribute(dlg, "BGCOLOR", "92 92 255"); +// IupSetAttribute(dlg, "BACKGROUND", "200 10 80"); +// IupSetAttribute(dlg, "BGCOLOR", "173 177 194"); // Motif BGCOLOR for documentation + +// IupSetAttribute(dlg, "FONT", "Helvetica, 24"); +// IupSetAttribute(box, "FGCOLOR", "255 0 0"); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + ListTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/make_uname b/iup/test/make_uname new file mode 100755 index 0000000..ae0ab49 --- /dev/null +++ b/iup/test/make_uname @@ -0,0 +1,4 @@ +#This builds all the libraries of the folder for 1 uname + +tecmake relink $1 $2 $3 $4 $5 $6 $7 +tecmake USE_GTK=Yes relink $1 $2 $3 $4 $5 $6 $7 diff --git a/iup/test/matrix.c b/iup/test/matrix.c new file mode 100755 index 0000000..280ffdb --- /dev/null +++ b/iup/test/matrix.c @@ -0,0 +1,115 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> + +#undef __IUPDEF_H +#include "iup.h" +#include "iupcontrols.h" + +static int dropcheck_cb(Ihandle *self, int lin, int col) +{ + if (lin == 3 && col == 1) + return IUP_DEFAULT; + return IUP_IGNORE; +} + +static Ihandle* create_matrix(void) +{ + Ihandle* mat = IupMatrix(NULL); + + IupSetAttribute(mat, "NUMCOL", "15"); + IupSetAttribute(mat, "NUMLIN", "20"); +// IupSetAttribute(mat, "NUMCOL", "2"); +// IupSetAttribute(mat, "NUMLIN", "3"); + + IupSetAttribute(mat, "0:0", "Inflation"); + IupSetAttribute(mat, "1:0", "Medicine\nPharma"); + IupSetAttribute(mat, "2:0", "Food"); + IupSetAttribute(mat, "3:0", "Energy"); + IupSetAttribute(mat, "0:1", "January 2000"); + IupSetAttribute(mat, "0:2", "February 2000"); + IupSetAttribute(mat, "1:1", "5.6\n3.33"); + IupSetAttribute(mat, "2:1", "2.2"); + IupSetAttribute(mat, "3:1", "7.2"); + IupSetAttribute(mat, "1:2", "4.5"); + IupSetAttribute(mat, "2:2", "8.1"); + IupSetAttribute(mat, "3:2", "3.4"); + IupSetAttribute(mat, "3:3", "Font Test"); + IupSetAttribute(mat, "WIDTH2", "90"); + IupSetAttribute(mat, "HEIGHT2", "30"); + IupSetAttribute(mat,"SORTSIGN2","DOWN"); +// IupSetAttribute(mat, "WIDTHDEF", "34"); + IupSetAttribute(mat,"MULTILINE", "YES"); + IupSetAttribute(mat,"RESIZEMATRIX", "YES"); + IupSetAttribute(mat,"USETITLESIZE", "YES"); + //IupSetAttribute(mat,"SCROLLBAR", "NO"); + //IupSetAttribute(mat, "BGCOLOR1:2", "255 92 255"); + //IupSetAttribute(mat, "BGCOLOR2:*", "92 92 255"); + //IupSetAttribute(mat, "BGCOLOR*:3", "255 92 92"); + //IupSetAttribute(mat, "FGCOLOR1:2", "255 0 0"); + //IupSetAttribute(mat, "FGCOLOR2:*", "0 128 0"); + //IupSetAttribute(mat, "FGCOLOR*:3", "0 0 255"); + //IupSetAttribute(mat, "FONT1:2", "Helvetica, 24"); + //IupSetAttribute(mat, "FONT2:*", "Courier, 14"); + //IupSetAttribute(mat, "FONT*:3", "Times, Bold 14"); + //IupSetAttribute(mat, "ALIGNMENT2", "ARIGHT"); +// IupSetAttribute(mat, "ACTIVE", "NO"); + + IupSetAttribute(mat,"MARKMODE","CELL"); +// IupSetAttribute(mat,"MARKMODE","LIN"); +// IupSetAttribute(mat,"MARKMULTIPLE","NO"); + IupSetAttribute(mat,"MARKMULTIPLE","YES"); +// IupSetAttribute(mat,"MARKAREA","NOT_CONTINUOUS"); + IupSetAttribute(mat,"MARK2:2","YES"); + IupSetAttribute(mat,"MARK2:3","YES"); + IupSetAttribute(mat,"MARK3:3","YES"); + + +// IupSetAttribute(mat,"MARKMODE","LINCOL"); + + //IupSetAttribute(mat, "NUMCOL_VISIBLE_LAST", "YES"); + //IupSetAttribute(mat, "NUMLIN_VISIBLE_LAST", "YES"); + IupSetAttribute(mat, "WIDTHDEF", "15"); + IupSetAttribute(mat, "20:15", "The End"); + IupSetAttribute(mat, "10:0", "Middle Line"); + IupSetAttribute(mat, "15:0", "Middle Line"); + IupSetAttribute(mat, "0:7", "Middle Column"); + IupSetAttribute(mat, "0:11", "Middle Column"); + IupSetAttribute(mat, "20:0", "Line Title Test"); + IupSetAttribute(mat, "0:15", "Column Title Test"); + IupSetAttribute(mat, "NUMCOL_VISIBLE", "6"); + IupSetAttribute(mat, "NUMLIN_VISIBLE", "8"); + + IupSetCallback(mat, "DROPCHECK_CB", (Icallback)dropcheck_cb); + + return mat; +} + +void MatrixTest(void) +{ + Ihandle* dlg, *box; + + box = IupVbox(create_matrix(), NULL); + IupSetAttribute(box, "MARGIN", "10x10"); + + dlg = IupDialog(box); + IupSetAttribute(dlg, "TITLE", "IupMatrix Simple Test"); + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupControlsOpen(); + + MatrixTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/matrix_cbmode.c b/iup/test/matrix_cbmode.c new file mode 100755 index 0000000..0d0e17c --- /dev/null +++ b/iup/test/matrix_cbmode.c @@ -0,0 +1,85 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "iup.h" +#include "iupcontrols.h" + +static char data[3][3][50] = +{ + {"1:1", "1:2", "1:3"}, + {"2:1", "2:2", "2:3"}, + {"3:1", "3:2", "3:3"}, +}; + + +static char* value_cb(Ihandle *self, int lin, int col) +{ + if (lin == 0 || col == 0) + return "Title"; + return data[lin-1][col-1]; +} + +static int value_edit_cb(Ihandle *self, int lin, int col, char* newvalue) +{ + strcpy(data[lin-1][col-1], newvalue); + return IUP_DEFAULT; +} + +static Ihandle* create_matrix(void) +{ + Ihandle* mat = IupMatrix(NULL); + + IupSetAttribute(mat, "NUMCOL", "3"); + IupSetAttribute(mat, "NUMLIN", "3"); + + IupSetAttribute(mat, "NUMCOL_VISIBLE", "3"); + IupSetAttribute(mat, "NUMLIN_VISIBLE", "3"); + +// IupSetAttribute(mat, "WIDTH2", "90"); +// IupSetAttribute(mat, "HEIGHT2", "30"); +// IupSetAttribute(mat, "WIDTHDEF", "34"); +// IupSetAttribute(mat,"RESIZEMATRIX", "YES"); + IupSetAttribute(mat,"SCROLLBAR", "NO"); + IupSetCallback(mat,"VALUE_CB",(Icallback)value_cb); + IupSetCallback(mat,"VALUE_EDIT_CB",(Icallback)value_edit_cb); + +// IupSetAttribute(mat, "HEIGHT0", "10"); +// IupSetAttribute(mat, "WIDTH0", "90"); +// IupSetAttribute(mat,"MARKMODE","LIN"); +// IupSetAttribute(mat,"MARKMULTIPLE","NO"); + + //IupSetAttribute(mat, "NUMCOL_VISIBLE_LAST", "YES"); + //IupSetAttribute(mat, "NUMLIN_VISIBLE_LAST", "YES"); +// IupSetAttribute(mat, "WIDTHDEF", "15"); + + return mat; +} + +void MatrixCbModeTest(void) +{ + Ihandle* dlg, *box; + + box = IupVbox(create_matrix(), NULL); + IupSetAttribute(box, "MARGIN", "10x10"); + + dlg = IupDialog(box); + IupSetAttribute(dlg, "TITLE", "IupMatrix Simple Test"); + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupControlsOpen(); + + MatrixCbModeTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/matrix_cbs.c b/iup/test/matrix_cbs.c new file mode 100755 index 0000000..1b7afb9 --- /dev/null +++ b/iup/test/matrix_cbs.c @@ -0,0 +1,341 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "iup.h" +#include "iupcontrols.h" +#include <cd.h> + +static int leave(Ihandle *self, int lin, int col) +{ + printf("leaveitem_cb(%d, %d)\n", lin, col); + //if(lin == 3 && col ==2) + // return IUP_IGNORE; /* notice that this will lock the matrix in this cell */ + return IUP_DEFAULT; +} + +static char* value(Ihandle *self, int lin, int col) +{ + static char str[50]; + sprintf(str, "%d-%d", lin, col); + return str; +} + +static int enter(Ihandle *self, int lin, int col) +{ + printf("enteritem_cb(%d, %d)\n", lin, col); + if(lin == 2 && col == 2) + { + IupSetAttribute(IupGetHandle("mat1"), "REDRAW", "ALL"); + IupSetAttribute(IupGetHandle("mat2"), "REDRAW", "ALL"); + IupSetAttribute(IupGetHandle("mat3"), "REDRAW", "ALL"); + IupSetAttribute(IupGetHandle("mat4"), "REDRAW", "ALL"); + IupSetAttribute(IupGetHandle("mat5"), "REDRAW", "ALL"); + IupSetAttribute(IupGetHandle("mat6"), "REDRAW", "ALL"); + } + return IUP_DEFAULT; +} + +static int dropselect(Ihandle *self, int lin, int col, Ihandle *drop, char *t, int i, int v) +{ + printf("dropselect_cb(%d, %d)\n", lin, col); + return IUP_DEFAULT; +} + +int mdrop = 1; +static int dropcheck(Ihandle *self, int lin, int col) +{ + if(lin == 1 && col == 1) + { + if (mdrop) + return IUP_DEFAULT; + else + return IUP_IGNORE; + } + return IUP_IGNORE; +} + +static int click(Ihandle *self, int lin, int col) +{ + char* value = IupMatGetAttribute(self, "", lin, col); + if (!value) value = "NULL"; + printf("click_cb(%d, %d)\n", lin, col); + printf(" VALUE%d:%d = %s\n", lin, col, value); + return IUP_DEFAULT; +} + +static int drop(Ihandle *self, Ihandle *drop, int lin, int col) +{ + printf("drop_cb(%d, %d)\n", lin, col); + if(lin == 1 && col == 1 && mdrop) + { + IupSetAttribute(drop, "1", "A - Test of Very Big String for Dropdown!"); + IupSetAttribute(drop, "2", "B"); + IupSetAttribute(drop, "3", "C"); + IupSetAttribute(drop, "4", "XXX"); + IupSetAttribute(drop, "5", "5"); + IupSetAttribute(drop, "6", "6"); + IupSetAttribute(drop, "7", "7"); + IupSetAttribute(drop, "8", NULL); + return IUP_DEFAULT; + } + return IUP_IGNORE; +} + +static int edition(Ihandle *self, int lin, int col, int mode) +{ + printf("edition_cb(lin=%d, col=%d, mode=%d)\n", lin, col, mode); + if (mode==1) + { + IupSetAttribute(self, "CARET", "3"); + + if(lin == 3 && col == 2) + return IUP_IGNORE; + } + + //if(lin == 1 && col == 1 && mode==0 && mdrop == 1) + //{ + // mdrop = 0; + // IupSetAttribute(self, "EDIT_MODE", "NO"); + // IupSetAttribute(self, "EDIT_MODE", "YES"); + // return IUP_IGNORE; + //} + + return IUP_DEFAULT; +} + +static int drawcb(Ihandle *h, int lin, int col,int x1, int x2, int y1, int y2) +{ + if (lin < 4) + return IUP_IGNORE; + + cdForeground(CD_RED); + cdLine(x1, y1, x2, y2); + cdLine(x1, y2, x2, y1); + + { + char s[50]; + sprintf(s, "%d:%d", lin, col); + cdTextAlignment(CD_CENTER); + cdText((x1+x2)/2, (y1+y2)/2, s); + } + + return IUP_DEFAULT; +} + +static int actioncb(Ihandle *h, int c, int lin, int col, int active, char* after) +{ + printf("action_cb(lin=%d, col=%d, active=%d, after=%s)\n", lin, col, active, after); + if (lin == 2 && col == 3 && active && after) + { + char str[100]; + strcpy(str, after); + strcat(str, "xxx"); + IupStoreAttribute(h,"VALUE", str); + + IupSetAttribute(h,"CARET","1"); + + IupSetAttribute(h,"REDRAW","ALL"); + } + + return IUP_DEFAULT; +} + + +static Ihandle *create_mat(void) +{ + Ihandle *mat = IupMatrix(NULL); + static int mati = 1; + char name[30]; + + sprintf(name, "mat%d", mati); + mati++; + + IupSetHandle(name, mat); + + IupSetAttribute(mat,"NUMCOL","15"); + IupSetAttribute(mat,"NUMLIN","18"); + + IupSetAttribute(mat,"NUMCOL_VISIBLE","5"); + IupSetAttribute(mat,"NUMLIN_VISIBLE","8"); + +// IupSetAttribute(mat,"EXPAND", "NO"); +// IupSetAttribute(mat,"SCROLLBAR", "NO"); + IupSetAttribute(mat,"RESIZEMATRIX", "YES"); + + IupSetAttribute(mat,"MARKMODE", "CELL"); +// IupSetAttribute(mat,"MARKMODE", "LINCOL"); + IupSetAttribute(mat,"MARKMULTIPLE", "YES"); +// IupSetAttribute(mat,"MARKAREA", "NOT_CONTINUOUS"); + IupSetAttribute(mat, "MARKAREA", "CONTINUOUS"); + + IupSetAttribute(mat,"0:0","Inflation"); + IupSetAttribute(mat,"1:0","Medicine "); + IupSetAttribute(mat,"2:0","Food"); + IupSetAttribute(mat,"3:0","Energy"); + IupSetAttribute(mat,"0:1","January 2000"); + IupSetAttribute(mat,"0:2","February 2000"); + IupSetAttribute(mat,"1:1","5.6"); + IupSetAttribute(mat,"2:1","2.2"); + IupSetAttribute(mat,"3:1","7.2"); + IupSetAttribute(mat,"1:2","4.5"); + IupSetAttribute(mat,"2:2","8.1"); + IupSetAttribute(mat,"3:2","3.4 (RO)"); + +// IupSetAttribute(mat,"BGCOLOR1:*","255 128 0"); + IupSetAttribute(mat,"BGCOLOR2:1","255 128 0"); + IupSetAttribute(mat,"FGCOLOR2:0","255 0 128"); +// IupSetAttribute(mat,"BGCOLOR0:*","255 0 128"); + IupSetAttribute(mat,"FGCOLOR1:1","255 0 128"); + IupSetAttribute(mat,"BGCOLOR3:*","255 128 0"); + IupSetAttribute(mat,"BGCOLOR*:4","255 128 0"); + //IupSetAttribute(mat,"FONT2:*", "Times New Roman:BOLD:8"); + //IupSetAttribute(mat,"FONT*:2", "Courier::12"); + IupSetAttribute(mat,"SORTSIGN1","UP"); +// IupSetAttribute(mat,"SORTSIGN2","DOWN"); + IupSetAttribute(mat,"FRAMEVERTCOLOR2:2","255 255 255"); + +// IupSetAttribute(mat,"MARKAREA","NOT_CONTINUOUS"); +// IupSetAttribute(mat,"MARKMULTIPLE","YES"); + + IupSetCallback(mat,"LEAVEITEM_CB",(Icallback)leave); + IupSetCallback(mat,"ENTERITEM_CB",(Icallback)enter); + IupSetCallback(mat,"DROPSELECT_CB",(Icallback)dropselect); + IupSetCallback(mat,"DROP_CB",(Icallback)drop); + IupSetCallback(mat,"DROPCHECK_CB",(Icallback)dropcheck); + IupSetCallback(mat,"EDITION_CB",(Icallback)edition); + IupSetCallback(mat,"CLICK_CB",(Icallback)click); + IupSetCallback(mat,"DRAW_CB",(Icallback)drawcb); + IupSetCallback(mat,"ACTION_CB",(Icallback)actioncb); + +// IupSetCallback(mat,"VALUE_CB",(Icallback)value); +// IupSetAttribute(mat,"WIDTH0","24"); +// IupSetAttribute(mat,"HEIGHT0","8"); + +// iupmaskMatSet(mat, IUPMASK_FLOAT, 0, 1, 2, 1) ; + + return mat; +} + + +static int redraw(Ihandle *self) +{ + IupSetAttribute(IupGetHandle("mat1"),"REDRAW","ALL"); + IupSetAttribute(IupGetHandle("mat2"),"REDRAW","ALL"); + //IupSetAttribute(IupGetHandle("mat3"),"REDRAW","ALL"); + //IupSetAttribute(IupGetHandle("mat4"),"REDRAW","ALL"); + //IupSetAttribute(IupGetHandle("mat5"),"REDRAW","ALL"); + //IupSetAttribute(IupGetHandle("mat6"),"REDRAW","ALL"); + + //Ihandle* mat = IupGetHandle("mat1"); + //if (IupGetInt(mat, "VISIBLE")) + //{ + // IupSetAttribute(mat,"VISIBLE","NO"); + // IupStoreAttribute(mat, "OLD_SIZE", IupGetAttribute(mat, "RASTERSIZE")); + // IupSetAttribute(mat, "RASTERSIZE", "1x1"); + //} + //else + //{ + // IupStoreAttribute(mat, "RASTERSIZE", IupGetAttribute(mat, "OLD_SIZE")); + // IupSetAttribute(mat,"VISIBLE","YES"); + //} + + return IUP_DEFAULT; +} + +static int removeline(Ihandle *self) +{ + IupSetAttribute(IupGetHandle("mat1"),"DELLIN","1"); + return IUP_DEFAULT; +} + +static int addline(Ihandle *self) +{ + IupSetAttribute(IupGetHandle("mat1"),"ADDLIN","0"); + return IUP_DEFAULT; +} + +static int removecol(Ihandle *self) +{ + IupSetAttribute(IupGetHandle("mat1"),"DELCOL","1"); + return IUP_DEFAULT; +} + +static int addcol(Ihandle *self) +{ + IupSetAttribute(IupGetHandle("mat1"),"ADDCOL","0"); + return IUP_DEFAULT; +} + +static int bt_cb(Ihandle *self) +{ + printf("DEFAULTENTER\n"); + return IUP_DEFAULT; +} + +static void createmenu(void) +{ + Ihandle* menu = IupMenu( + IupSubmenu("submenu", IupMenu(IupItem("item1","x"), IupItem("item2","x"), NULL)), + IupItem("remove line","removeline"), + IupItem("add line","addline"), + IupItem("remove col","removecol"), + IupItem("add col","addcol"), + IupItem("redraw","redraw"), + NULL); + IupSetHandle("mymenu", menu); +} + +void MatrixCbsTest(void) +{ + Ihandle *dlg, *bt; + + IupSetFunction("removeline", (Icallback)removeline); + IupSetFunction("addline", (Icallback)addline); + IupSetFunction("removecol", (Icallback)removecol); + IupSetFunction("addcol", (Icallback)addcol); + IupSetFunction("redraw", (Icallback)redraw); + + createmenu(); + + bt = IupButton("Button", NULL); + IupSetCallback(bt, "ACTION", bt_cb); + + dlg = IupDialog( +// IupZbox( + IupTabs( + IupSetAttributes( + IupVbox((create_mat()), bt, IupText(""), IupLabel("Label Text"), IupVal("HORIZONTAL"), + NULL), "MARGIN=10x10, GAP=10, TABTITLE=Test1"), + IupSetAttributes( + IupVbox(IupFrame(create_mat()), IupText(""), IupLabel("Label Text"), IupVal("HORIZONTAL"), +// NULL), "BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2,FONT=HELVETICA_ITALIC_14"), +// NULL), "FONT=HELVETICA_NORMAL_12, BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2"), + NULL), "BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2"), + NULL)); + IupSetAttribute(dlg,"TITLE", "IupMatrix"); + IupSetAttribute(dlg,"MENU", "mymenu"); + IupSetAttributeHandle(dlg,"DEFAULTENTER", bt); +// IupSetAttribute(dlg,"BGCOLOR", "255 0 255"); + + //IupSetAttribute(dlg,"COMPOSITED", "YES"); + //IupSetAttribute(dlg,"OPACITY", "192"); + + IupShowXY(dlg,IUP_CENTER,IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupControlsOpen(); + + MatrixCbsTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/mdi.c b/iup/test/mdi.c new file mode 100755 index 0000000..e483ba8 --- /dev/null +++ b/iup/test/mdi.c @@ -0,0 +1,150 @@ +#include <stdlib.h> +#include <stdio.h> +#include <iup.h> + + +static int mdi_tilehoriz(Ihandle* ih) +{ + IupSetAttribute(IupGetDialog(ih), "MDIARRANGE", "TILEHORIZONTAL"); + return IUP_DEFAULT; +} + +static int mdi_tilevert(Ihandle* ih) +{ + IupSetAttribute(IupGetDialog(ih), "MDIARRANGE", "TILEVERTICAL"); + return IUP_DEFAULT; +} + +static int mdi_cascade(Ihandle* ih) +{ + IupSetAttribute(IupGetDialog(ih), "MDIARRANGE", "CASCADE"); + return IUP_DEFAULT; +} + +static int mdi_icon(Ihandle* ih) +{ + IupSetAttribute(IupGetDialog(ih), "MDIARRANGE", "ICON"); + return IUP_DEFAULT; +} + +static int mdi_next(Ihandle* ih) +{ + IupSetAttribute(IupGetDialog(ih), "MDIACTIVATE", "NEXT"); + return IUP_DEFAULT; +} + +static int mdi_previous(Ihandle* ih) +{ + IupSetAttribute(IupGetDialog(ih), "MDIACTIVATE", "PREVIOUS"); + return IUP_DEFAULT; +} + +static int mdi_closeall(Ihandle* ih) +{ + IupSetAttribute(IupGetDialog(ih), "MDICLOSEALL", NULL); + return IUP_DEFAULT; +} + +static int mdi_activate(Ihandle* ih) +{ + printf("mdi_activate(%s)\n", IupGetName(ih)); + return IUP_DEFAULT; +} + +static int mdi_new(Ihandle* ih) +{ + static int id = 0; + Ihandle *box, *cnv, *dlg; + + cnv = IupCanvas(NULL); + IupSetAttribute(cnv,"BGCOLOR","128 255 0"); + + box = IupVbox(cnv, NULL); + IupSetAttribute(box,"MARGIN","5x5"); + + dlg = IupDialog(box); + IupSetfAttribute(dlg,"TITLE","MDI Child (%d)", id); id++; + IupSetAttribute(dlg,"MDICHILD","YES"); + IupSetAttribute(dlg,"PARENTDIALOG","mdiFrame"); + IupSetCallback(dlg,"MDIACTIVATE_CB",(Icallback)mdi_activate); + IupSetAttribute(dlg,"RASTERSIZE","300x300"); +// IupSetAttribute(dlg, "PLACEMENT", "MAXIMIZED"); + + IupShow(dlg); + + return IUP_DEFAULT; +} + +static void createMenu(void) +{ + Ihandle* winmenu; + Ihandle* mnu = IupMenu( + IupSubmenu("MDI",IupMenu( + IupItem("New", "mdi_new"), + NULL)), + IupSubmenu("Window", winmenu = IupMenu( + IupItem("Tile Horizontal", "mdi_tilehoriz"), + IupItem("Tile Vertical", "mdi_tilevert"), + IupItem("Cascade", "mdi_cascade"), + IupItem("Icon Arrange", "mdi_icon"), + IupItem("Close All", "mdi_closeall"), + IupSeparator(), + IupItem("Next", "mdi_next"), + IupItem("Previous", "mdi_previous"), + NULL)), + NULL); + IupSetHandle("mnu",mnu); + IupSetHandle("mdiMenu",winmenu); + + IupSetFunction("mdi_new", (Icallback)mdi_new); + IupSetFunction("mdi_tilehoriz", (Icallback)mdi_tilehoriz); + IupSetFunction("mdi_tilevert", (Icallback)mdi_tilevert); + IupSetFunction("mdi_cascade", (Icallback)mdi_cascade); + IupSetFunction("mdi_icon", (Icallback)mdi_icon); + IupSetFunction("mdi_next", (Icallback)mdi_next); + IupSetFunction("mdi_previous", (Icallback)mdi_previous); + IupSetFunction("mdi_closeall", (Icallback)mdi_closeall); +} + +static Ihandle* createFrame(void) +{ + Ihandle *dlg, *cnv; + cnv = IupCanvas( NULL); + IupSetAttribute(cnv,"MDICLIENT","YES"); + IupSetAttribute(cnv,"MDIMENU","mdiMenu"); + + dlg = IupDialog(cnv); + IupSetAttribute(dlg,"TITLE","MDI Frame"); + IupSetAttribute(dlg,"MDIFRAME","YES"); + IupSetAttribute(dlg,"RASTERSIZE","800x600"); + IupSetAttribute(dlg,"MENU","mnu"); + IupSetHandle("mdiFrame", dlg); + + return dlg; +} + +void MdiTest(void) +{ + Ihandle* dlg; + + createMenu(); + + dlg = createFrame(); +// IupSetAttribute(dlg, "PLACEMENT", "MAXIMIZED"); + IupShow(dlg); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + MdiTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/menu.c b/iup/test/menu.c new file mode 100755 index 0000000..6f20b9e --- /dev/null +++ b/iup/test/menu.c @@ -0,0 +1,396 @@ +#include <stdlib.h> +#include <stdio.h> + +#include <iup.h> + +static Ihandle* load_image_Tecgraf(void) +{ + unsigned char imgdata[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, 95, 108, 1, 90, 100, 117, 99, 123, 138, 166, 126, 137, 152, 181, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 105, 123, 147, 122, 137, 165, 255, 136, 152, 183, 255, 132, 149, 179, 250, 133, 149, 178, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 100, 115, 43, 111, 125, 150, 253, 140, 158, 190, 255, 135, 151, 182, 255, 132, 149, 179, 255, 131, 147, 177, 217, 153, 164, 188, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 102, 113, 134, 148, 134, 151, 182, 255, 137, 154, 185, 255, 115, 129, 154, 252, 114, 128, 155, 255, 130, 146, 175, 255, 132, 147, 175, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 158, 159, 162, 3, 108, 121, 145, 230, 144, 162, 195, 255, 137, 154, 185, 197, 74, 79, 86, 45, 41, 46, 55, 246, 120, 134, 162, 255, 129, 145, 174, 156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 101, 113, 48, 124, 139, 167, 255, 144, 161, 194, 255, 138, 155, 186, 67, 0, 0, 0, 0, 49, 54, 62, 150, 87, 98, 118, 255, 128, 144, 173, 223, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 102, 113, 132, 105, 137, 154, 185, 255, 139, 156, 188, 231, 143, 159, 187, 3, 0, 0, 0, 0, 64, 68, 76, 61, 70, 79, 95, 255, 127, 143, 172, 254, 134, 149, 175, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 121, 142, 153, 141, 159, 191, 255, 139, 156, 188, 164, 0, 0, 0, 0, 0, 0, 0, 0, 79, 82, 87, 3, 69, 77, 92, 241, 122, 137, 165, 255, 127, 142, 170, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, 122, 146, 191, 145, 163, 196, 255, 139, 156, 188, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 86, 101, 190, 115, 129, 156, 255, 126, 141, 170, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 125, 149, 227, 150, 168, 201, 255, 141, 157, 188, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 91, 107, 144, 113, 127, 153, 255, 125, 140, 169, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 163, 165, 167, 2, 112, 125, 150, 252, 155, 173, 203, 255, 143, 159, 189, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 94, 110, 109, 114, 128, 155, 255, 125, 140, 168, 175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 167, 181, 1, 120, 130, 149, 33, 48, 53, 59, 69, 43, 46, 52, 100, 50, 54, 59, 137, 116, 130, 156, 255, 155, 171, 201, 255, 105, 118, 142, 155, 104, 117, 141, 151, 105, 118, 141, 151, 105, 118, 142, 151, 101, 113, 136, 185, 111, 124, 150, 255, 116, 130, 156, 220, 112, 125, 148, 95, 115, 127, 150, 67, 123, 134, 156, 33, 168, 176, 190, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 119, 129, 147, 5, 109, 121, 142, 71, 106, 118, 140, 140, 105, 117, 140, 197, 107, 120, 144, 242, 120, 135, 162, 255, 123, 137, 163, 255, 44, 49, 58, 255, 28, 32, 39, 255, 125, 139, 164, 255, 150, 167, 197, 255, 138, 155, 186, 255, 131, 148, 178, 255, 125, 141, 170, 255, 119, 134, 162, 255, 114, 128, 154, 255, 108, 122, 147, 255, 104, 117, 141, 255, 102, 115, 138, 255, 103, 116, 139, 255, 107, 120, 145, 255, 111, 124, 149, 245, 113, 126, 151, 200, 113, 127, 152, 140, 116, 129, 154, 71, 122, 135, 158, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 118, 128, 145, 14, 106, 118, 140, 130, 104, 116, 139, 234, 105, 118, 142, 255, 128, 144, 173, 255, 147, 165, 199, 255, 157, 177, 213, 255, 150, 168, 202, 255, 140, 156, 187, 229, 41, 45, 52, 196, 39, 43, 51, 183, 130, 143, 168, 255, 144, 161, 192, 233, 109, 122, 145, 109, 105, 116, 138, 109, 99, 110, 130, 109, 92, 103, 123, 109, 91, 100, 117, 145, 97, 109, 131, 255, 95, 106, 128, 248, 74, 83, 97, 193, 64, 72, 85, 227, 56, 63, 75, 255, 55, 62, 75, 255, 65, 73, 88, 255, 90, 101, 121, 255, 111, 125, 150, 255, 114, 128, 154, 236, 116, 129, 155, 130, 127, 140, 165, 16, 0, 0, 0, 0, + 95, 101, 113, 22, 103, 115, 137, 220, 103, 116, 140, 255, 110, 123, 148, 255, 146, 165, 198, 255, 147, 165, 197, 232, 142, 158, 188, 147, 131, 144, 169, 78, 115, 123, 139, 20, 0, 0, 0, 0, 0, 0, 0, 0, 91, 97, 108, 68, 128, 142, 167, 255, 144, 162, 193, 212, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 100, 107, 31, 120, 135, 163, 255, 133, 150, 180, 231, 0, 0, 0, 0, 0, 0, 0, 0, 86, 89, 93, 20, 50, 54, 61, 73, 37, 40, 46, 141, 33, 36, 42, 230, 46, 52, 63, 255, 107, 120, 144, 255, 116, 130, 157, 255, 118, 133, 159, 223, 132, 147, 174, 24, + 76, 83, 95, 114, 104, 117, 140, 255, 105, 117, 141, 255, 118, 133, 160, 253, 139, 155, 184, 116, 134, 143, 161, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 100, 110, 74, 122, 137, 163, 255, 143, 160, 191, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, 114, 120, 31, 123, 138, 166, 255, 136, 153, 183, 228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, 93, 97, 5, 42, 45, 51, 111, 86, 97, 117, 253, 118, 133, 160, 255, 119, 133, 161, 255, 133, 149, 180, 116, + 46, 50, 56, 109, 67, 76, 91, 255, 105, 118, 142, 255, 107, 120, 145, 254, 112, 125, 149, 131, 127, 139, 161, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 98, 109, 74, 116, 130, 156, 255, 142, 159, 190, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 115, 122, 31, 128, 143, 172, 255, 141, 157, 185, 228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, 137, 163, 7, 122, 136, 162, 122, 120, 135, 162, 254, 121, 136, 164, 255, 136, 152, 184, 255, 126, 141, 168, 116, + 71, 74, 79, 17, 31, 35, 41, 206, 42, 47, 57, 255, 77, 87, 105, 255, 103, 116, 140, 255, 110, 124, 149, 239, 112, 125, 150, 157, 115, 128, 153, 89, 122, 134, 158, 30, 147, 158, 177, 2, 0, 0, 0, 0, 81, 87, 96, 65, 109, 123, 148, 255, 141, 158, 190, 212, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 103, 112, 31, 135, 151, 180, 255, 141, 156, 183, 231, 0, 0, 0, 0, 153, 164, 183, 1, 134, 147, 171, 30, 124, 138, 165, 84, 123, 138, 165, 154, 122, 137, 164, 235, 127, 143, 172, 255, 140, 157, 189, 255, 144, 162, 195, 255, 129, 144, 172, 218, 126, 138, 161, 22, + 0, 0, 0, 0, 64, 68, 73, 7, 39, 43, 49, 118, 32, 36, 42, 225, 30, 35, 42, 255, 50, 57, 68, 255, 72, 81, 97, 255, 91, 102, 123, 255, 105, 118, 142, 255, 113, 127, 152, 240, 115, 129, 155, 204, 111, 124, 149, 196, 111, 125, 150, 255, 126, 141, 170, 234, 119, 133, 159, 120, 120, 134, 160, 116, 121, 135, 161, 117, 121, 135, 162, 119, 116, 130, 155, 152, 127, 142, 170, 255, 125, 140, 168, 248, 123, 138, 166, 199, 130, 145, 173, 235, 140, 155, 183, 255, 143, 160, 190, 255, 143, 161, 193, 255, 147, 165, 199, 255, 145, 164, 197, 255, 132, 148, 177, 230, 127, 140, 166, 126, 124, 134, 151, 12, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 141, 144, 3, 55, 58, 63, 58, 37, 40, 46, 126, 34, 38, 44, 184, 34, 38, 44, 235, 35, 39, 47, 254, 49, 55, 66, 255, 64, 72, 87, 255, 77, 87, 104, 255, 88, 98, 118, 255, 96, 108, 130, 255, 103, 116, 139, 255, 108, 122, 147, 255, 113, 127, 153, 255, 118, 133, 160, 255, 124, 140, 168, 255, 133, 148, 176, 255, 141, 156, 183, 255, 146, 161, 187, 255, 144, 159, 186, 255, 131, 146, 174, 254, 127, 141, 168, 237, 126, 141, 168, 188, 123, 137, 162, 131, 112, 123, 143, 61, 128, 132, 140, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 94, 98, 19, 64, 68, 73, 56, 53, 57, 65, 82, 62, 67, 76, 116, 66, 74, 89, 255, 95, 107, 129, 255, 80, 88, 103, 155, 81, 90, 105, 151, 86, 95, 112, 151, 95, 104, 122, 151, 98, 109, 128, 180, 124, 139, 166, 255, 109, 122, 146, 218, 100, 110, 128, 84, 96, 104, 118, 56, 105, 109, 117, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 174, 176, 2, 74, 83, 98, 252, 131, 147, 178, 255, 140, 155, 184, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 122, 134, 157, 114, 151, 169, 203, 255, 123, 138, 165, 174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 76, 90, 224, 122, 137, 165, 255, 136, 152, 182, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 139, 165, 147, 146, 164, 198, 255, 122, 137, 165, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 69, 81, 191, 110, 124, 149, 255, 134, 151, 181, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 143, 170, 193, 142, 160, 192, 255, 122, 137, 164, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 63, 74, 150, 94, 105, 127, 255, 133, 149, 179, 166, 0, 0, 0, 0, 0, 0, 0, 0, 115, 119, 128, 5, 130, 145, 174, 242, 137, 154, 186, 255, 125, 139, 166, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 58, 66, 102, 72, 81, 97, 255, 132, 148, 178, 236, 148, 161, 187, 5, 0, 0, 0, 0, 110, 121, 140, 64, 140, 157, 189, 255, 127, 142, 171, 254, 131, 144, 169, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 65, 71, 43, 47, 52, 63, 255, 127, 143, 172, 255, 132, 148, 177, 75, 0, 0, 0, 0, 121, 134, 158, 160, 139, 156, 188, 255, 123, 138, 165, 223, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 154, 156, 158, 1, 36, 39, 46, 227, 106, 119, 143, 255, 130, 145, 175, 203, 114, 125, 147, 51, 123, 138, 166, 247, 131, 147, 177, 255, 123, 138, 165, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 41, 47, 143, 68, 77, 93, 255, 128, 144, 174, 255, 126, 141, 170, 252, 129, 145, 174, 255, 123, 138, 166, 255, 127, 141, 167, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 68, 73, 40, 34, 38, 46, 250, 117, 131, 158, 255, 126, 142, 171, 255, 124, 140, 168, 255, 125, 139, 166, 214, 140, 152, 172, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 44, 50, 134, 58, 66, 79, 255, 123, 138, 166, 255, 123, 138, 166, 250, 127, 140, 165, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 154, 156, 158, 1, 46, 50, 55, 83, 82, 89, 102, 123, 106, 116, 136, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + Ihandle* image = IupImageRGBA(32, 32, imgdata); + return image; +} + +static Ihandle* load_image_LogoTecgraf(void) +{ + unsigned char imgdata[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 120, 143, 125, 132, 148, 178, 173, 133, 149, 178, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 110, 130, 48, 130, 147, 177, 254, 124, 139, 167, 254, 131, 147, 176, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, 128, 153, 134, 142, 159, 191, 194, 47, 52, 61, 110, 114, 128, 154, 222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 143, 172, 192, 140, 156, 188, 99, 65, 69, 76, 16, 97, 109, 131, 251, 129, 144, 172, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 147, 175, 232, 140, 157, 188, 43, 0, 0, 0, 0, 100, 112, 134, 211, 126, 141, 169, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 78, 88, 26, 48, 52, 57, 60, 135, 150, 178, 254, 108, 121, 145, 83, 105, 118, 142, 76, 106, 119, 143, 201, 118, 133, 159, 122, 117, 129, 152, 25, 168, 176, 190, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 118, 128, 145, 3, 104, 117, 140, 92, 114, 127, 152, 180, 131, 147, 177, 237, 133, 149, 178, 249, 38, 42, 50, 222, 137, 152, 180, 249, 126, 142, 170, 182, 114, 128, 154, 182, 104, 117, 140, 227, 95, 107, 128, 238, 83, 93, 112, 248, 84, 95, 113, 239, 104, 117, 141, 180, 115, 129, 155, 93, 127, 140, 165, 4, + 98, 109, 130, 153, 109, 123, 147, 254, 145, 163, 195, 153, 138, 154, 182, 56, 115, 123, 138, 5, 92, 99, 109, 35, 134, 149, 177, 230, 0, 0, 0, 0, 0, 0, 0, 0, 120, 133, 159, 143, 135, 151, 181, 115, 86, 89, 93, 5, 41, 45, 51, 54, 40, 45, 53, 150, 107, 120, 144, 254, 122, 137, 164, 154, + 51, 57, 66, 147, 83, 93, 112, 255, 108, 121, 145, 159, 113, 126, 151, 62, 123, 136, 159, 8, 87, 93, 103, 35, 125, 141, 169, 230, 0, 0, 0, 0, 0, 0, 0, 0, 129, 143, 169, 143, 140, 156, 184, 115, 134, 147, 172, 8, 124, 138, 165, 60, 124, 139, 167, 155, 131, 147, 177, 255, 131, 147, 176, 153, + 64, 68, 73, 2, 36, 39, 45, 86, 41, 46, 54, 173, 60, 67, 80, 232, 75, 84, 101, 251, 89, 100, 120, 228, 105, 118, 142, 250, 110, 123, 148, 187, 118, 132, 158, 187, 126, 141, 169, 229, 134, 149, 177, 239, 136, 152, 179, 250, 136, 152, 181, 234, 139, 156, 186, 175, 130, 145, 173, 90, 124, 134, 151, 3, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, 74, 79, 19, 60, 64, 73, 50, 92, 103, 124, 254, 86, 95, 111, 84, 90, 100, 117, 76, 126, 141, 168, 201, 113, 126, 150, 119, 99, 105, 117, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 105, 125, 231, 135, 151, 181, 46, 0, 0, 0, 0, 137, 154, 184, 212, 123, 137, 164, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, 83, 98, 191, 133, 149, 179, 102, 111, 121, 139, 17, 134, 150, 180, 252, 126, 140, 166, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 48, 57, 132, 121, 136, 164, 197, 121, 135, 161, 115, 130, 146, 175, 221, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 47, 52, 46, 87, 98, 118, 254, 126, 142, 170, 254, 124, 139, 166, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 57, 67, 118, 115, 128, 152, 170, 127, 140, 164, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + Ihandle* image = IupImageRGBA(16, 16, imgdata); + return image; +} + +static Ihandle* load_image_Test(void) +{ + unsigned char imgdata[] = + { + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,1,1,1,1,1,1,2,2,2,2,2,2,0,5, + 5,0,1,1,1,1,1,1,2,2,2,2,2,2,0,5, + 5,0,1,1,1,1,1,1,2,2,2,2,2,2,0,5, + 5,0,1,1,1,1,1,1,2,2,2,2,2,2,0,5, + 5,0,1,1,1,1,1,1,2,2,2,2,2,2,0,5, + 5,0,1,1,1,1,1,1,2,2,2,2,2,2,0,5, + 5,0,3,3,3,3,3,3,4,4,4,4,4,4,0,5, + 5,0,3,3,3,3,3,3,4,4,4,4,4,4,0,5, + 5,0,3,3,3,3,3,3,4,4,4,4,4,4,0,5, + 5,0,3,3,3,3,3,3,4,4,4,4,4,4,0,5, + 5,0,3,3,3,3,3,3,4,4,4,4,4,4,0,5, + 5,0,3,3,3,3,3,3,4,4,4,4,4,4,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + }; + + Ihandle* image = IupImage(16, 16, imgdata); + IupSetAttribute(image, "0", "BGCOLOR"); + IupSetAttribute(image, "1", "255 0 0"); + IupSetAttribute(image, "2", "0 255 0"); + IupSetAttribute(image, "3", "0 0 255"); + IupSetAttribute(image, "4", "255 255 255"); + IupSetAttribute(image, "5", "0 0 0"); + return image; +} + +static Ihandle* load_image_Test_pressed(void) +{ + static unsigned char imgdata[] = + { + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,5,1,1,1,1,1,2,2,2,2,2,5,0,5, + 5,0,1,5,1,1,1,1,2,2,2,2,5,2,0,5, + 5,0,1,1,5,1,1,1,2,2,2,5,2,2,0,5, + 5,0,1,1,1,5,1,1,2,2,5,2,2,2,0,5, + 5,0,1,1,1,1,5,1,2,5,2,2,2,2,0,5, + 5,0,1,1,1,1,1,5,5,2,2,2,2,2,0,5, + 5,0,3,3,3,3,3,5,5,4,4,4,4,4,0,5, + 5,0,3,3,3,3,5,3,4,5,4,4,4,4,0,5, + 5,0,3,3,3,5,3,3,4,4,5,4,4,4,0,5, + 5,0,3,3,5,3,3,3,4,4,4,5,4,4,0,5, + 5,0,3,5,3,3,3,3,4,4,4,4,5,4,0,5, + 5,0,5,3,3,3,3,3,4,4,4,4,4,5,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + }; + + Ihandle* image = IupImage(16, 16, imgdata); + IupSetAttribute(image, "0", "BGCOLOR"); + IupSetAttribute(image, "1", "255 0 0"); + IupSetAttribute(image, "2", "0 255 0"); + IupSetAttribute(image, "3", "0 0 255"); + IupSetAttribute(image, "4", "255 255 255"); + IupSetAttribute(image, "5", "0 0 0"); + return image; +} + +static int item_add_cb(Ihandle* ih) +{ + Ihandle* item = IupItem("New Appended Item", "item_cb"); + printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE")); + IupAppend(IupGetParent(ih), item); /* after the last item */ + IupMap(item); + return IUP_DEFAULT; +} + +static int item_insert_cb(Ihandle* ih) +{ + Ihandle* ref_item = IupGetChild(IupGetParent(ih), 4); /* before the first appended item, just after the separator */ + printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE")); + if (ref_item) + { + Ihandle* item = IupItem("New Inserted Item", "item_cb"); + IupInsert(IupGetParent(ih), ref_item, item); + IupMap(item); + } + return IUP_DEFAULT; +} + +static int item_remove_cb(Ihandle* ih) +{ + Ihandle* item = IupGetNextChild(IupGetParent(ih), IupGetNextChild(IupGetParent(ih), ih)); /* the next after the separator */ + printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE")); + if (item) + IupDestroy(item); + return IUP_DEFAULT; +} + +static int item_image_cb(Ihandle* ih) +{ + printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE")); + ih = IupGetNextChild(IupGetParent(ih), ih); + if (IupGetAttributeHandle(ih, "IMAGE")) + IupSetAttribute(ih, "IMAGE", NULL); + else + IupSetAttribute(ih, "IMAGE", "image_test"); + return IUP_DEFAULT; +} + +static int item_active_cb(Ihandle* ih) +{ + printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE")); + ih = IupGetNextChild(IupGetParent(ih), ih); + if (IupGetInt(ih, "ACTIVE")) + IupSetAttribute(ih, "ACTIVE", "NO"); + else + IupSetAttribute(ih, "ACTIVE", "YES"); + return IUP_DEFAULT; +} + +static int item_rename_cb(Ihandle* ih) +{ + printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE")); + ih = IupGetNextChild(IupGetParent(ih), ih); + IupSetAttribute(ih, "TITLE", "New Title"); + return IUP_DEFAULT; +} + +static int item_toggle_cb(Ihandle* ih) +{ + printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE")); + if (IupGetInt(ih, "VALUE")) + IupSetAttribute(ih, "VALUE", "OFF"); + else + IupSetAttribute(ih, "VALUE", "ON"); + + return IUP_DEFAULT; +} + +static int item_cb (Ihandle* ih) +{ + printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE")); + return IUP_DEFAULT; +} + +static int item_close_cb (Ihandle* ih) +{ + printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE")); + return IUP_CLOSE; +} + +static int item_help_cb (Ihandle* ih) +{ + printf("HELP_CB(%s)\n", IupGetAttribute(ih, "TITLE")); + return IUP_DEFAULT; +} + +static int item_destroy_cb (Ihandle* ih) +{ + printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE")); + IupDestroy(IupGetDialog(ih)); + return IUP_DEFAULT; +} + +static int highlight_cb(Ihandle* ih) +{ + printf("HIGHLIGHT_CB(%s)\n", IupGetAttribute(ih, "TITLE")); + return IUP_DEFAULT; +} + +static int open_cb(Ihandle* ih) +{ + printf("OPEN_CB(Menu of %s)\n", IupGetAttribute(IupGetParent(ih), "TITLE")); + return IUP_DEFAULT; +} + +static int menuclose_cb(Ihandle* ih) +{ + printf("MENUCLOSE_CB(Menu of %s)\n", IupGetAttribute(IupGetParent(ih), "TITLE")); + return IUP_DEFAULT; +} + +static void show_popup(void) +{ + Ihandle* menu_file = IupMenu( + IupSetAttributes(IupItem("Item with Image", "item_cb"), "IMAGE=image_tec"), + IupSetCallbacks(IupSetAttributes(IupItem("Toggle using VALUE", NULL), "VALUE=ON, KEY=K_V"), "ACTION", item_toggle_cb, "HIGHLIGHT_CB", highlight_cb, NULL), + IupSetAttributes(IupItem("Auto &Toggle", "item_cb"), "AUTOTOGGLE=YES, VALUE=OFF, IMAGE=image_test, IMPRESS=image_test_pressed"), + IupSeparator(), + IupSetCallbacks(IupItem("E&xit (Close)", NULL), "ACTION", item_close_cb, NULL), + NULL); + Ihandle* menu = IupMenu( + IupSetCallbacks(IupSetAttributes(IupSubmenu("Submenu", menu_file), "KEY=K_S, IMAGE=image_tec"), "HIGHLIGHT_CB", highlight_cb, NULL), + IupSetCallbacks(IupItem("Item", "item_cb"), "HIGHLIGHT_CB", highlight_cb, NULL), + IupSetCallbacks(IupSetAttributes(IupItem("Item", "item_cb"), "VALUE=ON"), "HIGHLIGHT_CB", highlight_cb, NULL), + IupSetCallbacks(IupSetAttributes(IupItem("Item", "item_cb"), "KEY=K_I, IMAGE=image_tec"), "HIGHLIGHT_CB", highlight_cb, NULL), + NULL); + IupSetCallbacks(menu_file, "OPEN_CB", open_cb, "MENUCLOSE_CB", menuclose_cb, NULL); + IupSetCallbacks(menu, "OPEN_CB", open_cb, "MENUCLOSE_CB", menuclose_cb, NULL); + IupPopup(menu, IUP_MOUSEPOS, IUP_MOUSEPOS); + IupDestroy(menu); +} + +static int k_m(Ihandle *ih) +{ + (void)ih; + show_popup(); + return IUP_DEFAULT; +} + +static int button(Ihandle *ih,int but,int pressed,int x,int y,char* status) +{ + (void)x; + (void)y; + (void)status; + (void)ih; + + if (but==IUP_BUTTON3 && pressed) + show_popup(); + + return IUP_DEFAULT; +} + +static int killfocus(Ihandle *ih) +{ + (void)ih; + printf("KILLFOCUS(canvas)\n"); + return IUP_DEFAULT; +} + +static int getfocus(Ihandle *ih) +{ + (void)ih; + printf("GETFOCUS(canvas)\n"); + return IUP_DEFAULT; +} + +void MenuTest(void) +{ + Ihandle *dlg, *canvas, *menu, + *menu_file, *menu_edit, *menu_help, + *menu_create; + + IupSetHandle("image_tec", load_image_LogoTecgraf()); + IupSetHandle("image_test", load_image_Test()); + IupSetHandle("image_test_pressed", load_image_Test_pressed()); + + /* Creates menu create */ + menu_create = IupMenu( + IupItem("Line", "item_cb"), + IupItem("Circle", "item_cb"), + IupSetCallbacks(IupSubmenu("Triangle", IupSetAttributes(IupMenu( + IupSetCallbacks(IupSetAttributes(IupItem("Equilateral", "item_cb"), "VALUE=ON"), "HIGHLIGHT_CB", highlight_cb, NULL), + IupSetCallbacks(IupItem("Isoceles", "item_cb"), "HIGHLIGHT_CB", highlight_cb, NULL), + IupSetCallbacks(IupItem("Scalenus", "item_cb"), "HIGHLIGHT_CB", highlight_cb, NULL), + NULL), "RADIO=YES")), "HIGHLIGHT_CB", highlight_cb, NULL), + NULL); + IupSetCallbacks(menu_create, "OPEN_CB", open_cb, "MENUCLOSE_CB", menuclose_cb, NULL); +// IupSetAttribute(menu_create, "BGCOLOR", "92 92 255"); + + /* Creates three menus that will be inside submenus */ + menu_file = IupMenu( + IupSetAttributes(IupItem("Item with Image \tCtrl+M", "item_cb"), "IMAGE=image_tec"), + IupSetCallbacks(IupSetAttributes(IupItem("Toggle using &VALUE", NULL), "VALUE=ON, KEY=KcV"), "ACTION", item_toggle_cb, NULL), + IupSetAttributes(IupItem("Auto &Toggle Text", "item_cb"), "AUTOTOGGLE=YES, VALUE=OFF"), + IupSetAttributes(IupItem("Auto &Toggle Image", "item_cb"), "AUTOTOGGLE=YES, VALUE=OFF, IMAGE=image_test, IMPRESS=image_test_pressed"), + IupItem("Big Image", "item_cb"), + IupSeparator(), + IupSetCallbacks(IupItem("Exit (Destroy)", NULL), "ACTION", item_destroy_cb, NULL), + IupSetCallbacks(IupItem("E&xit (Close)", NULL), "ACTION", item_close_cb, NULL), + NULL); + menu_edit = IupMenu( + IupSetCallbacks(IupItem("Active Next", NULL), "ACTION", item_active_cb, NULL), + IupSetCallbacks(IupItem("Rename Next", NULL), "ACTION", item_rename_cb, NULL), + IupSetCallbacks(IupItem("Set Next Image", NULL), "ACTION", item_image_cb, NULL), + IupSetAttributes(IupItem("Item w/ Acc\tCtrl+A", "item_cb"), "IMAGE=dummy"), + IupSeparator(), + IupSetAttributes(IupSubmenu("Create", menu_create), "IMAGE=image_tec"), + NULL); + menu_help = IupMenu( + IupSetCallbacks(IupItem("Append", NULL), "ACTION", item_add_cb, "HELP_CB", item_help_cb, NULL), + IupSetCallbacks(IupItem("Insert", NULL), "ACTION", item_insert_cb, "HELP_CB", item_help_cb, NULL), + IupSetCallbacks(IupItem("Remove", NULL), "ACTION", item_remove_cb, "HELP_CB", item_help_cb, NULL), + IupSeparator(), + NULL); + + IupSetAttributeHandle(IupGetChild(menu_file, 4), "TITLEIMAGE", load_image_Tecgraf()); + IupSetCallbacks(menu_edit, "OPEN_CB", open_cb, "MENUCLOSE_CB", menuclose_cb, NULL); + + /* Creates main menu with file menu */ + menu = IupMenu( + IupSetCallbacks(IupSetAttributes(IupSubmenu("Submenu", menu_file), "KEY=K_S, IMAGE=image_tec"), "HIGHLIGHT_CB", highlight_cb, NULL), + IupSetCallbacks(IupSubmenu("&Edit", menu_edit), "HIGHLIGHT_CB", highlight_cb, NULL), + IupSubmenu("Help", menu_help), + IupSetCallbacks(IupSetAttributes(IupItem("Item", "item_cb"), "KEY=K_I, IMAGE=image_tec"), "HIGHLIGHT_CB", highlight_cb, NULL), + NULL); + + /* Registers callbacks */ + IupSetFunction("item_cb", item_cb); + //IupSetAttribute(menu, "BGCOLOR", "92 92 255"); + //IupSetAttribute(menu, "BGCOLOR", "173 177 194"); // Motif BGCOLOR for documentation + + canvas = IupCanvas(NULL); + IupSetCallback(canvas, "BUTTON_CB", (Icallback)button); + IupSetCallback(canvas, "K_m", (Icallback)k_m); +// IupSetCallback(canvas, "KILLFOCUS_CB", killfocus); +// IupSetCallback(canvas, "GETFOCUS_CB", getfocus); + + dlg = IupDialog(canvas); + IupSetAttributeHandle(dlg, "MENU", menu); + IupSetAttributes(dlg, "TITLE=\"IupMenu Test\", SIZE=QUARTERxQUARTER"); + + /* Shows dlg in the center of the screen */ + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + MenuTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/ole.cpp b/iup/test/ole.cpp new file mode 100755 index 0000000..c3da5fc --- /dev/null +++ b/iup/test/ole.cpp @@ -0,0 +1,108 @@ +#include <stdlib.h> +#include <stdio.h> + +#include <windows.h> +#include <exdisp.h> + +#include <iup.h> +#include <iupole.h> + + +#ifndef BIG_TEST +static Ihandle *IupOleCreateBrowser(void) +{ + Ihandle *browser=IupOleControl("Shell.Explorer.2"); + IupSetAttribute(browser,"DESIGNMODE", "NO"); + return browser; +} + +static WCHAR* Char2Wide(const char* str) +{ + if (str) + { + int n = strlen(str)+1; + WCHAR* wstr = (WCHAR*)malloc(n * sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, str, -1, wstr, n); + return wstr; + } + return NULL; +} + +static IWebBrowser2 *IupOleGetWebBrowserInterface(Ihandle *browser) +{ + IWebBrowser2 *pweb = (IWebBrowser2*)IupGetAttribute(browser, "IUP_IWebBrowser2"); + if (!pweb) + { + IUnknown *punk = (IUnknown*)IupGetAttribute(browser,"IUNKNOWN"); + punk->QueryInterface(IID_IWebBrowser2, (void **) &pweb); + punk->Release(); + IupSetAttribute(browser, "IUP_IWebBrowser2", (char*)pweb); + } + return pweb; +} + +static void IupOleNavigate(Ihandle *browser,char *fname) +{ + IWebBrowser2 *pweb = IupOleGetWebBrowserInterface(browser); + WCHAR* url = Char2Wide(fname); + pweb->Navigate(url, NULL, NULL, NULL, NULL); + free(url); +} + +static void IupOleClose(Ihandle* browser) +{ + IWebBrowser2 *pweb = IupOleGetWebBrowserInterface(browser); + pweb->Release(); +} + +static int load_cb(Ihandle* ih) +{ + Ihandle* txt = (Ihandle*)IupGetAttribute(ih, "MY_TEXT"); + Ihandle* browser = (Ihandle*)IupGetAttribute(ih, "MY_BROWSER"); + IupOleNavigate(browser, IupGetAttribute(txt, "VALUE")); + return IUP_DEFAULT; +} + +static int close_cb(Ihandle* ih) +{ + Ihandle* browser = (Ihandle*)IupGetAttribute(ih, "MY_BROWSER"); + IupOleClose(browser); + return IUP_DEFAULT; +} + +void OleTest(void) +{ + Ihandle* txt, *bt; + Ihandle * browser = IupOleCreateBrowser(); + + // Creates a dlg containing the OLE control + Ihandle* dlg = IupDialog(IupVbox(IupHbox(txt = IupText(""), bt = IupButton("Load", NULL), NULL), browser, NULL)); + IupSetAttribute(dlg, "MARGIN", "10x10"); + IupSetAttribute(dlg, "GAP", "10"); + IupSetAttribute(dlg, "TITLE", "IupOle"); + IupSetAttribute(dlg, "MY_TEXT", (char*)txt); + IupSetAttribute(dlg, "MY_BROWSER", (char*)browser); + IupSetAttribute(txt, "EXPAND", "HORIZONTAL"); +// IupSetAttribute(txt, "VALUE", "d:/test.doc"); + IupSetCallback(bt, "ACTION", (Icallback)load_cb); + IupSetCallback(dlg, "CLOSE_CB", (Icallback)close_cb); + IupSetAttributeHandle(dlg, "DEFAULTENTER", bt); + + // Shows dlg + IupShow(dlg); +} + +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupOleControlOpen(); + + OleTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/pplot.c b/iup/test/pplot.c new file mode 100755 index 0000000..639aa34 --- /dev/null +++ b/iup/test/pplot.c @@ -0,0 +1,699 @@ +/* + * IupPPlot Test + * Description : Create all built-in plots. + * It is organised as two side-by-side panels: + * - left panel for current plot control + * - right panel containg tabbed plots + * Remark : depend on libs IUP, CD, IUP_PPLOT + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + + +#include "iup.h" +#include "iupcontrols.h" +#include "iup_pplot.h" + +#include <cd.h> +#include <cdiup.h> +#include <cdpdf.h> +#include <cdgdiplus.h> + + +#define MAXPLOT 6 /* room for examples */ + + +static Ihandle *plot[MAXPLOT] = {NULL}; /* PPlot controls */ +static Ihandle *dial1, *dial2, /* dials for zooming */ + *tgg1, *tgg2, /* autoscale on|off toggles */ + *tgg3, *tgg4, /* grid show|hide toggles */ + *tgg5, /* legend show|hide toggle */ + *tabs; /* tabbed control */ + +static int delete_cb(Ihandle* ih, int index, int sample_index, float x, float y) +{ + printf("DELETE_CB(%d, %d, %g, %g)\n", index, sample_index, x, y); + return IUP_DEFAULT; +} + +static int select_cb(Ihandle* ih, int index, int sample_index, float x, float y, int select) +{ + printf("SELECT_CB(%d, %d, %g, %g, %d)\n", index, sample_index, x, y, select); + return IUP_DEFAULT; +} + +static int edit_cb(Ihandle* ih, int index, int sample_index, float x, float y, float *new_x, float *new_y) +{ + printf("EDIT_CB(%d, %d, %g, %g, %g, %g)\n", index, sample_index, x, y, *new_x, *new_y); + return IUP_DEFAULT; +} + +static int postdraw_cb(Ihandle* ih, cdCanvas* cnv) +{ + int ix, iy; + + IupPPlotTransform(ih, 0.003f, 0.02f, &ix, &iy); + cdCanvasFont(cnv, NULL, CD_BOLD, 10); + cdCanvasTextAlignment(cnv, CD_SOUTH); + cdCanvasText(cnv, ix, iy, "My Inline Legend"); + printf("POSTDRAW_CB()\n"); + + return IUP_DEFAULT; +} + +static int predraw_cb(Ihandle* ih, cdCanvas* cnv) +{ + printf("PREDRAW_CB()\n"); + return IUP_DEFAULT; +} + +static void InitPlots(void) +{ + int theI; + float x, y, theFac; + + /* PLOT 0 - MakeExamplePlot1 */ + IupSetAttribute(plot[0], "TITLE", "AutoScale"); + IupSetAttribute(plot[0], "MARGINTOP", "40"); + IupSetAttribute(plot[0], "MARGINLEFT", "40"); + IupSetAttribute(plot[0], "MARGINBOTTOM", "50"); + IupSetAttribute(plot[0], "TITLEFONTSIZE", "16"); + IupSetAttribute(plot[0], "LEGENDSHOW", "YES"); + IupSetAttribute(plot[0], "AXS_XLABEL", "gnu (Foo)"); + IupSetAttribute(plot[0], "AXS_YLABEL", "Space (m^3)"); + IupSetAttribute(plot[0], "AXS_YFONTSIZE", "8"); + IupSetAttribute(plot[0], "AXS_YTICKFONTSIZE", "8"); + IupSetAttribute(plot[0], "AXS_XFONTSIZE", "10"); + IupSetAttribute(plot[0], "AXS_YFONTSIZE", "10"); + IupSetAttribute(plot[0], "AXS_XLABELCENTERED", "NO"); + IupSetAttribute(plot[0], "AXS_YLABELCENTERED", "NO"); + +// IupSetAttribute(plot[0], "USE_IMAGERGB", "YES"); +// IupSetAttribute(plot[0], "USE_GDI+", "YES"); + + theFac = (float)1.0/(100*100*100); + IupPPlotBegin(plot[0], 0); + for (theI=-100; theI<=100; theI++) + { + x = (float)(theI+50); + y = theFac*theI*theI*theI; + IupPPlotAdd(plot[0], x, y); + } + IupPPlotEnd(plot[0]); + IupSetAttribute(plot[0], "DS_LINEWIDTH", "3"); + IupSetAttribute(plot[0], "DS_LEGEND", "Line"); + + theFac = (float)2.0/100; + IupPPlotBegin(plot[0], 0); + for (theI=-100; theI<=100; theI++) + { + x = (float)theI; + y = -theFac*theI; + IupPPlotAdd(plot[0], x, y); + } + IupPPlotEnd(plot[0]); + IupSetAttribute(plot[0], "DS_LEGEND", "Curve 1"); + + IupPPlotBegin(plot[0], 0); + for (theI=-100; theI<=100; theI++) + { + x = (float)(0.01*theI*theI-30); + y = (float)0.01*theI; + IupPPlotAdd(plot[0], x, y); + } + IupPPlotEnd(plot[0]); + IupSetAttribute(plot[0], "DS_LEGEND", "Curve 2"); + + + /* PLOT 1 - MakeExamplePlot2 */ + IupSetAttribute(plot[1], "TITLE", "No Autoscale+No CrossOrigin"); + IupSetAttribute(plot[1], "TITLEFONTSIZE", "16"); + IupSetAttribute(plot[1], "MARGINTOP", "40"); + IupSetAttribute(plot[1], "MARGINLEFT", "65"); + IupSetAttribute(plot[1], "MARGINBOTTOM", "60"); + IupSetAttribute(plot[1], "BGCOLOR", "0 192 192"); + IupSetAttribute(plot[1], "AXS_XLABEL", "Tg (X)"); + IupSetAttribute(plot[1], "AXS_YLABEL", "Tg (Y)"); + IupSetAttribute(plot[1], "AXS_XAUTOMIN", "NO"); + IupSetAttribute(plot[1], "AXS_XAUTOMAX", "NO"); + IupSetAttribute(plot[1], "AXS_YAUTOMIN", "NO"); + IupSetAttribute(plot[1], "AXS_YAUTOMAX", "NO"); + IupSetAttribute(plot[1], "AXS_XMIN", "10"); + IupSetAttribute(plot[1], "AXS_XMAX", "60"); + IupSetAttribute(plot[1], "AXS_YMIN", "-0.5"); + IupSetAttribute(plot[1], "AXS_YMAX", "0.5"); + IupSetAttribute(plot[1], "AXS_XCROSSORIGIN", "NO"); + IupSetAttribute(plot[1], "AXS_YCROSSORIGIN", "NO"); + IupSetAttribute(plot[1], "AXS_XFONTSTYLE", "BOLD"); + IupSetAttribute(plot[1], "AXS_YFONTSTYLE", "BOLD"); + IupSetAttribute(plot[1], "AXS_XREVERSE", "YES"); + IupSetAttribute(plot[1], "GRIDCOLOR", "128 255 128"); + IupSetAttribute(plot[1], "GRIDLINESTYLE", "DOTTED"); + IupSetAttribute(plot[1], "GRID", "YES"); + IupSetAttribute(plot[1], "LEGENDSHOW", "YES"); + + theFac = (float)1.0/(100*100*100); + IupPPlotBegin(plot[1], 0); + for (theI=0; theI<=100; theI++) + { + x = (float)(theI); + y = theFac*theI*theI*theI; + IupPPlotAdd(plot[1], x, y); + } + IupPPlotEnd(plot[1]); + + theFac = (float)2.0/100; + IupPPlotBegin(plot[1], 0); + for (theI=0; theI<=100; theI++) + { + x = (float)(theI); + y = -theFac*theI; + IupPPlotAdd(plot[1], x, y); + } + IupPPlotEnd(plot[1]); + + /* PLOT 2 - MakeExamplePlot4 */ + IupSetAttribute(plot[2], "TITLE", "Log Scale"); + IupSetAttribute(plot[2], "TITLEFONTSIZE", "16"); + IupSetAttribute(plot[2], "MARGINTOP", "40"); + IupSetAttribute(plot[2], "MARGINLEFT", "70"); + IupSetAttribute(plot[2], "MARGINBOTTOM", "60"); + IupSetAttribute(plot[2], "GRID", "YES"); + IupSetAttribute(plot[2], "AXS_XSCALE", "LOG10"); + IupSetAttribute(plot[2], "AXS_YSCALE", "LOG2"); + IupSetAttribute(plot[2], "AXS_XLABEL", "Tg (X)"); + IupSetAttribute(plot[2], "AXS_YLABEL", "Tg (Y)"); + IupSetAttribute(plot[2], "AXS_XFONTSTYLE", "BOLD"); + IupSetAttribute(plot[2], "AXS_YFONTSTYLE", "BOLD"); + + theFac = (float)100.0/(100*100*100); + IupPPlotBegin(plot[2], 0); + for (theI=0; theI<=100; theI++) + { + x = (float)(0.0001+theI*0.001); + y = (float)(0.01+theFac*theI*theI*theI); + IupPPlotAdd(plot[2], x, y); + } + IupPPlotEnd(plot[2]); + IupSetAttribute(plot[2], "DS_COLOR", "100 100 200"); + + /* PLOT 3 - MakeExamplePlot5 */ + IupSetAttribute(plot[3], "TITLE", "Bar Mode"); + IupSetAttribute(plot[3], "TITLEFONTSIZE", "16"); + IupSetAttribute(plot[3], "MARGINTOP", "40"); + IupSetAttribute(plot[3], "MARGINLEFT", "30"); + IupSetAttribute(plot[3], "MARGINBOTTOM", "30"); + + { + const char * kLables[12] = {"jan","feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"}; + const float kData[12] = {1,2,3,4,5,6,7,8,9,0,1,2}; + IupPPlotBegin(plot[3], 1); + for (theI=0; theI<12; theI++) + IupPPlotAddStr(plot[3], kLables[theI], kData[theI]); + } + IupPPlotEnd(plot[3]); + IupSetAttribute(plot[3], "DS_COLOR", "100 100 200"); + IupSetAttribute(plot[3], "DS_MODE", "BAR"); + + /* PLOT 4 - MakeExamplePlot6 */ + IupSetAttribute(plot[4], "TITLE", "Marks Mode"); + IupSetAttribute(plot[4], "TITLEFONTSIZE", "16"); + IupSetAttribute(plot[4], "MARGINTOP", "40"); + IupSetAttribute(plot[4], "MARGINLEFT", "45"); + IupSetAttribute(plot[4], "MARGINBOTTOM", "40"); + IupSetAttribute(plot[4], "AXS_XAUTOMIN", "NO"); + IupSetAttribute(plot[4], "AXS_XAUTOMAX", "NO"); + IupSetAttribute(plot[4], "AXS_YAUTOMIN", "NO"); + IupSetAttribute(plot[4], "AXS_YAUTOMAX", "NO"); + IupSetAttribute(plot[4], "AXS_XMIN", "0"); + IupSetAttribute(plot[4], "AXS_XMAX", "0.011"); + IupSetAttribute(plot[4], "AXS_YMIN", "0"); + IupSetAttribute(plot[4], "AXS_YMAX", "0.22"); + IupSetAttribute(plot[4], "AXS_XCROSSORIGIN", "NO"); + IupSetAttribute(plot[4], "AXS_YCROSSORIGIN", "NO"); + IupSetAttribute(plot[4], "AXS_XTICKFORMAT", "%1.3f"); + IupSetAttribute(plot[4], "LEGENDSHOW", "YES"); + IupSetAttribute(plot[4], "LEGENDPOS", "BOTTOMRIGHT"); + + theFac = (float)100.0/(100*100*100); + IupPPlotBegin(plot[4], 0); + for (theI=0; theI<=10; theI++) + { + x = (float)(0.0001+theI*0.001); + y = (float)(0.01+theFac*theI*theI); + IupPPlotAdd(plot[4], x, y); + } + IupPPlotEnd(plot[4]); + IupSetAttribute(plot[4], "DS_MODE", "MARKLINE"); + IupSetAttribute(plot[4], "DS_SHOWVALUES", "YES"); + + IupPPlotBegin(plot[4], 0); + for (theI=0; theI<=10; theI++) + { + x = (float)(0.0001+theI*0.001); + y = (float)(0.2-theFac*theI*theI); + IupPPlotAdd(plot[4], x, y); + } + IupPPlotEnd(plot[4]); + IupSetAttribute(plot[4], "DS_MODE", "MARK"); + IupSetAttribute(plot[4], "DS_MARKSTYLE", "HOLLOW_CIRCLE"); + + /* PLOT 5 - MakeExamplePlot8 */ + IupSetAttribute(plot[5], "TITLE", "Data Selection and Editing"); + IupSetAttribute(plot[5], "TITLEFONTSIZE", "16"); + IupSetAttribute(plot[5], "MARGINTOP", "40"); + + theFac = (float)100.0/(100*100*100); + IupPPlotBegin(plot[5], 0); + for (theI=-10; theI<=10; theI++) + { + x = (float)(0.001*theI); + y = (float)(0.01+theFac*theI*theI*theI); + IupPPlotAdd(plot[5], x, y); + } + IupPPlotEnd(plot[5]); + IupSetAttribute(plot[5], "DS_COLOR", "100 100 200"); + IupSetAttribute(plot[5], "DS_EDIT", "YES"); + IupSetCallback(plot[5], "DELETE_CB", (Icallback)delete_cb); + IupSetCallback(plot[5], "SELECT_CB", (Icallback)select_cb); + IupSetCallback(plot[5], "POSTDRAW_CB", (Icallback)postdraw_cb); + IupSetCallback(plot[5], "PREDRAW_CB", (Icallback)predraw_cb); + IupSetCallback(plot[5], "EDIT_CB", (Icallback)edit_cb); + +} + +static int tabs_get_index(void) +{ + Ihandle *curr_tab = IupGetHandle(IupGetAttribute(tabs, "VALUE")); + char *ss = IupGetAttribute(curr_tab, "TABTITLE"); + ss += 5; /* Skip "Plot " */ + return atoi(ss); +} + +/* Some processing required by current tab change: the controls at left + will be updated according to current plot props */ +static int tabs_tabchange_cb(Ihandle* self, Ihandle* new_tab) +{ + int ii=0; + + char *ss = IupGetAttribute(new_tab, "TABTITLE"); + ss += 5; /* Skip "Plot " */ + ii = atoi(ss); + + /* autoscaling X axis */ + if (IupGetInt(plot[ii], "AXS_XAUTOMIN") && IupGetInt(plot[ii], "AXS_XAUTOMAX")) { + IupSetAttribute(tgg2, "VALUE", "ON"); + IupSetAttribute(dial2, "ACTIVE", "NO"); + } + else { + IupSetAttribute(tgg2, "VALUE", "OFF"); + IupSetAttribute(dial2, "ACTIVE", "YES"); + } + /* autoscaling Y axis */ + if (IupGetInt(plot[ii], "AXS_YAUTOMIN") && IupGetInt(plot[ii], "AXS_YAUTOMAX")) { + IupSetAttribute(tgg1, "VALUE", "ON"); + IupSetAttribute(dial1, "ACTIVE", "NO"); + } + else { + IupSetAttribute(tgg1, "VALUE", "OFF"); + IupSetAttribute(dial1, "ACTIVE", "YES"); + } + + /* grid */ + if (IupGetInt(plot[ii], "GRID")) + { + IupSetAttribute(tgg3, "VALUE", "ON"); + IupSetAttribute(tgg4, "VALUE", "ON"); + } + else + { + /* X axis */ + if (*IupGetAttribute(plot[ii], "GRID") == 'V') + IupSetAttribute(tgg3, "VALUE", "ON"); + else + IupSetAttribute(tgg3, "VALUE", "OFF"); + /* Y axis */ + if (*IupGetAttribute(plot[ii], "GRID") == 'H') + IupSetAttribute(tgg4, "VALUE", "ON"); + else + IupSetAttribute(tgg4, "VALUE", "OFF"); + } + + /* legend */ + if (IupGetInt(plot[ii], "LEGENDSHOW")) + IupSetAttribute(tgg5, "VALUE", "ON"); + else + IupSetAttribute(tgg5, "VALUE", "OFF"); + + return IUP_DEFAULT; +} + +/* show/hide V grid */ +static int tgg3_cb(Ihandle *self, int v) +{ + int ii = tabs_get_index(); + + if (v) + { + if (IupGetInt(tgg4, "VALUE")) + IupSetAttribute(plot[ii], "GRID", "YES"); + else + IupSetAttribute(plot[ii], "GRID", "VERTICAL"); + } + else + { + if (!IupGetInt(tgg4, "VALUE")) + IupSetAttribute(plot[ii], "GRID", "NO"); + else + IupSetAttribute(plot[ii], "GRID", "HORIZONTAL"); + } + + IupSetAttribute(plot[ii], "REDRAW", NULL); + + return IUP_DEFAULT; +} + + +/* show/hide H grid */ +static int tgg4_cb(Ihandle *self, int v) +{ + int ii = tabs_get_index(); + + if (v) + { + if (IupGetInt(tgg3, "VALUE")) + IupSetAttribute(plot[ii], "GRID", "YES"); + else + IupSetAttribute(plot[ii], "GRID", "HORIZONTAL"); + } + else + { + if (!IupGetInt(tgg3, "VALUE")) + IupSetAttribute(plot[ii], "GRID", "NO"); + else + IupSetAttribute(plot[ii], "GRID", "VERTICAL"); + } + + IupSetAttribute(plot[ii], "REDRAW", NULL); + + return IUP_DEFAULT; +} + + +/* show/hide legend */ +static int tgg5_cb(Ihandle *self, int v) +{ + int ii = tabs_get_index(); + + if (v) + IupSetAttribute(plot[ii], "LEGENDSHOW", "YES"); + else + IupSetAttribute(plot[ii], "LEGENDSHOW", "NO"); + + IupSetAttribute(plot[ii], "REDRAW", NULL); + + return IUP_DEFAULT; +} + + +/* autoscale Y */ +static int tgg1_cb(Ihandle *self, int v) +{ + int ii = tabs_get_index(); + + if (v) { + IupSetAttribute(dial1, "ACTIVE", "NO"); + IupSetAttribute(plot[ii], "AXS_YAUTOMIN", "YES"); + IupSetAttribute(plot[ii], "AXS_YAUTOMAX", "YES"); + } + else { + IupSetAttribute(dial1, "ACTIVE", "YES"); + IupSetAttribute(plot[ii], "AXS_YAUTOMIN", "NO"); + IupSetAttribute(plot[ii], "AXS_YAUTOMAX", "NO"); + } + + IupSetAttribute(plot[ii], "REDRAW", NULL); + + return IUP_DEFAULT; +} + + +/* autoscale X */ +static int tgg2_cb(Ihandle *self, int v) +{ + int ii = tabs_get_index(); + + if (v) { + IupSetAttribute(dial2, "ACTIVE", "NO"); + IupSetAttribute(plot[ii], "AXS_XAUTOMIN", "YES"); + IupSetAttribute(plot[ii], "AXS_XAUTOMAX", "YES"); + } + else { + IupSetAttribute(dial2, "ACTIVE", "YES"); + IupSetAttribute(plot[ii], "AXS_XAUTOMIN", "NO"); + IupSetAttribute(plot[ii], "AXS_XAUTOMAX", "NO"); + } + + IupSetAttribute(plot[ii], "REDRAW", NULL); + + return IUP_DEFAULT; +} + + +/* Y zoom */ +static int dial1_btndown_cb(Ihandle *self, double angle) +{ + int ii = tabs_get_index(); + + IupStoreAttribute(plot[ii], "OLD_YMIN", IupGetAttribute(plot[ii], "AXS_YMIN")); + IupStoreAttribute(plot[ii], "OLD_YMAX", IupGetAttribute(plot[ii], "AXS_YMAX")); + + return IUP_DEFAULT; +} + +static int dial1_btnup_cb(Ihandle *self, double angle) +{ + int ii = tabs_get_index(); + double x1, x2, xm; + char *ss; + + x1 = IupGetFloat(plot[ii], "OLD_YMIN"); + x2 = IupGetFloat(plot[ii], "OLD_YMAX"); + + ss = IupGetAttribute(plot[ii], "AXS_YMODE"); + if ( ss && ss[3]=='2' ) { + /* LOG2: one circle will zoom 2 times */ + xm = 4.0 * fabs(angle) / 3.141592; + if (angle>0.0) { x2 /= xm; x1 *= xm; } + else { x2 *= xm; x1 /= xm; } + } + if ( ss && ss[3]=='1' ) { + /* LOG10: one circle will zoom 10 times */ + xm = 10.0 * fabs(angle) / 3.141592; + if (angle>0.0) { x2 /= xm; x1 *= xm; } + else { x2 *= xm; x1 /= xm; } + } + else { + /* LIN: one circle will zoom 2 times */ + xm = (x1 + x2) / 2.0; + x1 = xm - (xm - x1)*(1.0-angle*1.0/3.141592); + x2 = xm + (x2 - xm)*(1.0-angle*1.0/3.141592); + } + + if (x1<x2) + { + IupSetfAttribute(plot[ii], "AXS_YMIN", "%f", x1); + IupSetfAttribute(plot[ii], "AXS_YMAX", "%f", x2); + } + + IupSetAttribute(plot[ii], "REDRAW", NULL); + + return IUP_DEFAULT; +} + + +/* X zoom */ +static int dial2_btndown_cb(Ihandle *self, double angle) +{ + int ii = tabs_get_index(); + + IupStoreAttribute(plot[ii], "OLD_XMIN", IupGetAttribute(plot[ii], "AXS_XMIN")); + IupStoreAttribute(plot[ii], "OLD_XMAX", IupGetAttribute(plot[ii], "AXS_XMAX")); + + return IUP_DEFAULT; +} + +static int dial2_btnup_cb(Ihandle *self, double angle) +{ + int ii = tabs_get_index(); + double x1, x2, xm; + + x1 = IupGetFloat(plot[ii], "OLD_XMIN"); + x2 = IupGetFloat(plot[ii], "OLD_XMAX"); + + xm = (x1 + x2) / 2.0; + + x1 = xm - (xm - x1)*(1.0-angle*1.0/3.141592); /* one circle will zoom 2 times */ + x2 = xm + (x2 - xm)*(1.0-angle*1.0/3.141592); + + IupSetfAttribute(plot[ii], "AXS_XMIN", "%f", x1); + IupSetfAttribute(plot[ii], "AXS_XMAX", "%f", x2); + + IupSetAttribute(plot[ii], "REDRAW", NULL); + + return IUP_DEFAULT; +} + +static int bt1_cb(Ihandle *self) +{ +// int ii = tabs_get_index(); +// cdCanvas* cnv = cdCreateCanvas(CD_PDF, "pplot.pdf -o"); +// IupPPlotPaintTo(plot[ii], cnv); +// cdKillCanvas(cnv); + return IUP_DEFAULT; +} + +void PPlotTest(void) +{ + Ihandle *vboxr[MAXPLOT+1]; /* tabs containing the plots */ + Ihandle *dlg, *vboxl, *hbox, *lbl1, *lbl2, *lbl3, *bt1, + *boxinfo, *boxdial1, *boxdial2, *f1, *f2; + int ii; + + IupPPlotOpen(); /* init IupPPlot library */ + +// cdInitGdiPlus(); + + /* create plots */ + for (ii=0; ii<MAXPLOT; ii++) + plot[ii] = IupPPlot(); + + /* left panel: plot control + Y zooming */ + dial1 = IupDial("VERTICAL"); + lbl1 = IupLabel("+"); + lbl2 = IupLabel("-"); + boxinfo = IupVbox(lbl1, IupFill(), lbl2, NULL); + boxdial1 = IupHbox(boxinfo, dial1, NULL); + + IupSetAttribute(boxdial1, "ALIGN", "ACENTER"); + IupSetAttribute(boxinfo, "ALIGN", "ACENTER"); + IupSetAttribute(boxinfo, "SIZE", "20x52"); + IupSetAttribute(boxinfo, "GAP", "2"); + IupSetAttribute(boxinfo, "MARGIN", "4"); + IupSetAttribute(boxinfo, "EXPAND", "YES"); + IupSetAttribute(lbl1, "EXPAND", "NO"); + IupSetAttribute(lbl2, "EXPAND", "NO"); + + IupSetAttribute(dial1, "ACTIVE", "NO"); + IupSetAttribute(dial1, "SIZE", "20x52"); + IupSetCallback(dial1, "BUTTON_PRESS_CB", (Icallback)dial1_btndown_cb); + IupSetCallback(dial1, "MOUSEMOVE_CB", (Icallback)dial1_btnup_cb); + IupSetCallback(dial1, "BUTTON_RELEASE_CB", (Icallback)dial1_btnup_cb); + + tgg1 = IupToggle("Y Autoscale", NULL); + IupSetCallback(tgg1, "ACTION", (Icallback)tgg1_cb); + IupSetAttribute(tgg1, "VALUE", "ON"); + + f1 = IupFrame( IupVbox(boxdial1, tgg1, NULL) ); + IupSetAttribute(f1, "TITLE", "Y Zoom"); + + /* X zooming */ + dial2 = IupDial("HORIZONTAL"); + lbl1 = IupLabel("-"); + lbl2 = IupLabel("+"); + boxinfo = IupHbox(lbl1, IupFill(), lbl2, NULL); + boxdial2 = IupVbox(dial2, boxinfo, NULL); + + IupSetAttribute(boxdial2, "ALIGN", "ACENTER"); + IupSetAttribute(boxinfo, "ALIGN", "ACENTER"); + IupSetAttribute(boxinfo, "SIZE", "64x16"); + IupSetAttribute(boxinfo, "GAP", "2"); + IupSetAttribute(boxinfo, "MARGIN", "4"); + IupSetAttribute(boxinfo, "EXPAND", "HORIZONTAL"); + + IupSetAttribute(lbl1, "EXPAND", "NO"); + IupSetAttribute(lbl2, "EXPAND", "NO"); + + IupSetAttribute(dial2, "ACTIVE", "NO"); + IupSetAttribute(dial2, "SIZE", "64x16"); + IupSetCallback(dial2, "BUTTON_PRESS_CB", (Icallback)dial2_btndown_cb); + IupSetCallback(dial2, "MOUSEMOVE_CB", (Icallback)dial2_btnup_cb); + IupSetCallback(dial2, "BUTTON_RELEASE_CB", (Icallback)dial2_btnup_cb); + + tgg2 = IupToggle("X Autoscale", NULL); + IupSetCallback(tgg2, "ACTION", (Icallback)tgg2_cb); + + f2 = IupFrame( IupVbox(boxdial2, tgg2, NULL) ); + IupSetAttribute(f2, "TITLE", "X Zoom"); + + lbl1 = IupLabel(""); + IupSetAttribute(lbl1, "SEPARATOR", "HORIZONTAL"); + + tgg3 = IupToggle("Vertical Grid", NULL); + IupSetCallback(tgg3, "ACTION", (Icallback)tgg3_cb); + tgg4 = IupToggle("Horizontal Grid", NULL); + IupSetCallback(tgg4, "ACTION", (Icallback)tgg4_cb); + + lbl2 = IupLabel(""); + IupSetAttribute(lbl2, "SEPARATOR", "HORIZONTAL"); + + tgg5 = IupToggle("Legend", NULL); + IupSetCallback(tgg5, "ACTION", (Icallback)tgg5_cb); + + lbl3 = IupLabel(""); + IupSetAttribute(lbl3, "SEPARATOR", "HORIZONTAL"); + + bt1 = IupButton("Export PDF", NULL); + IupSetCallback(bt1, "ACTION", (Icallback)bt1_cb); + + vboxl = IupVbox(f1, f2, lbl1, tgg3, tgg4, lbl2, tgg5, lbl3, bt1, NULL); + IupSetAttribute(vboxl, "GAP", "4"); + IupSetAttribute(vboxl, "EXPAND", "NO"); + + /* right panel: tabs with plots */ + for (ii=0; ii<MAXPLOT; ii++) { + vboxr[ii] = IupVbox(plot[ii], NULL); /* each plot a tab */ + IupSetfAttribute(vboxr[ii], "TABTITLE", "Plot %d", ii); /* name each tab */ + IupSetHandle(IupGetAttribute(vboxr[ii], "TABTITLE"), vboxr[ii]); + } + vboxr[MAXPLOT] = NULL; /* mark end of vector */ + +// tabs = IupZboxv(vboxr); +// IupSetAttribute(tabs, "VALUE", "Plot 3"); + tabs = IupTabsv(vboxr); + IupSetCallback(tabs, "TABCHANGE_CB", (Icallback)tabs_tabchange_cb); + + hbox = IupHbox(vboxl, tabs, NULL); + IupSetAttribute(hbox, "MARGIN", "4x4"); + IupSetAttribute(hbox, "GAP", "10"); + + dlg = IupDialog(hbox); + IupSetAttribute(dlg, "SIZE", "170x"); + IupSetAttribute(dlg, "TITLE", "IupPPlot Example"); + + InitPlots(); /* It must be able to be done independent of dlg Mapping */ + + tabs_tabchange_cb(tabs, vboxr[0]); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); + IupSetAttribute(dlg, "SIZE", NULL); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + PPlotTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/predialogs.c b/iup/test/predialogs.c new file mode 100755 index 0000000..e7b36ea --- /dev/null +++ b/iup/test/predialogs.c @@ -0,0 +1,472 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "iup.h" +#include "iupkey.h" +#include "iupcontrols.h" + + +#ifdef WIN32 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0500 +#include <windows.h> +static void drawTest(Ihandle* ih) +{ + RECT rect; + HDC hDC = (HDC)IupGetAttribute(ih, "PREVIEWDC"); + int w = IupGetInt(ih, "PREVIEWWIDTH"); + int h = IupGetInt(ih, "PREVIEWHEIGHT"); + + SetRect(&rect, 0, 0, w, h); + FillRect(hDC, &rect, GetStockObject(WHITE_BRUSH)); + + SelectObject(hDC, GetStockObject(DC_PEN)); + SetDCPenColor(hDC, RGB(255, 0, 0)); + + MoveToEx(hDC, 0, 0, NULL); + LineTo(hDC, w-1, h-1); + MoveToEx(hDC, 0, h-1, NULL); + LineTo(hDC, w-1, 0); +} +#else +#include <X11/Xlib.h> + +#define xCOLOR8TO16(_x) (_x*257) /* 65535/255 = 257 */ +static unsigned long xGetPixel(Display* dpy, unsigned char cr, unsigned char cg, unsigned char cb) +{ + XColor xc; + xc.red = xCOLOR8TO16(cr); + xc.green = xCOLOR8TO16(cg); + xc.blue = xCOLOR8TO16(cb); + xc.flags = DoRed | DoGreen | DoBlue; + + XAllocColor(dpy, DefaultColormap(dpy, XDefaultScreen(dpy)), &xc); + return xc.pixel; +} + +static void drawTest(Ihandle* ih) +{ + GC gc = (GC)IupGetAttribute(ih, "PREVIEWDC"); + Display* dpy = (Display*)IupGetAttribute(ih, "XDISPLAY"); + Drawable wnd = (Drawable)IupGetAttribute(ih, "XWINDOW"); + int w = IupGetInt(ih, "PREVIEWWIDTH"); + int h = IupGetInt(ih, "PREVIEWHEIGHT"); + + XSetForeground(dpy, gc, xGetPixel(dpy, 255, 255, 255)); + XFillRectangle(dpy, wnd, gc, 0, 0, w, h); + + XSetForeground(dpy, gc, xGetPixel(dpy, 255, 0, 0)); + + XDrawLine(dpy, wnd, gc, 0, 0, w-1, h-1); + XDrawLine(dpy, wnd, gc, 0, h-1, w-1, 0); +} +#endif + +#ifdef USE_OPENGL +#include <GL/gl.h> +#include "iupgl.h" + +static void drawTestGL(Ihandle* ih) +{ + Ihandle* glcanvas = IupGetAttributeHandle(ih, "PREVIEWGLCANVAS"); + if (glcanvas) + { + int w = IupGetInt(ih, "PREVIEWWIDTH"); + int h = IupGetInt(ih, "PREVIEWHEIGHT"); + + IupGLMakeCurrent(glcanvas); + glViewport(0,0,w,h); + + glClearColor(1.0, 0.0, 1.0, 1.f); /* pink */ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glColor3f(1.0,0.0,0.0); /* red */ + glBegin(GL_QUADS); + glVertex2f(0.9f,0.9f); + glVertex2f(0.9f,-0.9f); + glVertex2f(-0.9f,-0.9f); + glVertex2f(-0.9f,0.9f); + glEnd(); + + IupGLSwapBuffers(glcanvas); + } + else + drawTest(ih); +} + +#endif + +static int close_cb(Ihandle *ih) +{ + printf("CLOSE_CB\n"); + IupDestroy(ih); + return IUP_IGNORE; +} + +static int help_cb(Ihandle* ih) +{ + (void)ih; + printf("HELP_CB\n"); + return IUP_DEFAULT; +} + +static int file_cb(Ihandle* ih, const char* filename, const char* status) +{ + (void)ih; + printf("FILE_CB(%s - %s)\n", status, filename); + + if (strcmp(status, "PAINT")==0) + { + printf(" SIZE(%s x %s)\n", IupGetAttribute(ih, "PREVIEWWIDTH"), IupGetAttribute(ih, "PREVIEWHEIGHT")); +#ifdef USE_OPENGL + drawTestGL(ih); +#else + drawTest(ih); +#endif + } + return IUP_DEFAULT; +} + +static void new_message(char* type, char* buttons) +{ + Ihandle* dlg = IupMessageDlg(); + + if (strcmp(type, "ERROR")!=0) + IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_"); + IupSetAttribute(dlg, "DIALOGTYPE", type); + IupSetAttribute(dlg, "TITLE", "IupMessageDlg Test"); + IupSetAttribute(dlg, "BUTTONS", buttons); + IupSetAttribute(dlg, "VALUE", "Message Text\nSecond Line"); + if (strcmp(type, "WARNING")==0) + IupSetAttribute(dlg, "BUTTONDEFAULT", "2"); + if (strcmp(type, "INFORMATION")!=0) + IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb); + + IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT); + + printf("BUTTONRESPONSE(%s)\n", IupGetAttribute(dlg, "BUTTONRESPONSE")); + + IupDestroy(dlg); +} + +static void new_color(void) +{ + Ihandle* dlg = IupColorDlg(); + + IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_"); + IupSetAttribute(dlg, "VALUE", "128 0 255"); + IupSetAttribute(dlg, "ALPHA", "142"); + //IupSetAttribute(dlg, "COLORTABLE", ";;177 29 234;;;0 0 23;253 20 119"); + IupSetAttribute(dlg, "SHOWHEX", "YES"); + IupSetAttribute(dlg, "SHOWCOLORTABLE", "YES"); + //IupSetAttribute(dlg, "SHOWALPHA", "YES"); + IupSetAttribute(dlg, "TITLE", "IupColorDlg Test"); + IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb); + + IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT); + + if (IupGetInt(dlg, "STATUS")) + { + printf("OK\n"); + printf(" VALUE(%s)\n", IupGetAttribute(dlg, "VALUE")); + printf(" COLORTABLE(%s)\n", IupGetAttribute(dlg, "COLORTABLE")); + } + else + printf("CANCEL\n"); + + IupDestroy(dlg); +} + +static void new_font(void) +{ + Ihandle* dlg = IupFontDlg(); + + IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_"); + IupSetAttribute(dlg, "COLOR", "128 0 255"); + IupSetAttribute(dlg, "VALUE", "Times New Roman, Bold 20"); + IupSetAttribute(dlg, "TITLE", "IupFontDlg Test"); + IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb); + + IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT); + + if (IupGetInt(dlg, "STATUS")) + { + printf("OK\n"); + printf(" VALUE(%s)\n", IupGetAttribute(dlg, "VALUE")); + printf(" COLOR(%s)\n", IupGetAttribute(dlg, "COLOR")); + } + else + printf("CANCEL\n"); + + IupDestroy(dlg); +} + +static void new_file(char* dialogtype, int preview) +{ + Ihandle *dlg = IupFileDlg(); + + IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_"); + IupSetAttribute(dlg, "DIALOGTYPE", dialogtype); + IupSetAttribute(dlg, "TITLE", "IupFileDlg Test"); + IupSetAttribute(dlg, "DIRECTORY", "/tecgraf/iup"); + if (strcmp(dialogtype, "DIR")!=0) + { + IupSetAttributes(dlg, "FILTER = \"*.bmp\", FILTERINFO = \"Bitmap Files\""); + IupSetAttribute(dlg, "EXTFILTER", "Text files|*.txt;*.doc|Image files|*.jpg;*.bmp;*.gif|"); +// IupSetAttribute(dlg, "FILE", "/tecgraf/im/test.bmp"); + IupSetAttribute(dlg, "FILE", "test.bmp"); + } + IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb); +// IupSetAttributes(dlg, "FILE = \"\\tecgraf\\iup\\test.bmp\""); // OK +// IupSetAttributes(dlg, "FILE = \"/tecgraf/iup/test.bmp\""); // OK +// IupSetAttributes(dlg, "FILE = \"test.bmp\", DIRECTORY = \"/tecgraf/iup\""); // OK +// IupSetAttributes(dlg, "FILE = \"test.bmp\", DIRECTORY = \"\\tecgraf\\iup\""); // OK +// IupSetAttribute(dlg, "NOCHANGEDIR", "NO"); +// IupSetAttribute(dlg, "MULTIPLEFILES", "YES"); + + if (preview) + { + IupSetAttribute(dlg, "SHOWPREVIEW", "YES"); + IupSetCallback(dlg, "FILE_CB", (Icallback)file_cb); + +#ifdef USE_OPENGL + if (preview==2) + { + Ihandle* glcanvas = IupGLCanvas(NULL); + IupSetAttribute(glcanvas, "BUFFER", "DOUBLE"); + IupSetAttributeHandle(dlg, "PREVIEWGLCANVAS", glcanvas); + } +#endif + } + + IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT); + + switch(IupGetInt(dlg, "STATUS")) + { + case 1: + printf("OK\n"); + printf(" New file - VALUE(%s)\n", IupGetAttribute(dlg, "VALUE")); + break; + case 0 : + printf("OK\n"); + printf(" File exists - VALUE(%s)\n", IupGetAttribute(dlg, "VALUE")); + break; + case -1 : + printf("CANCEL\n"); + break; + } + + IupDestroy(dlg); +} + +static void new_alarm(void) +{ + int ret; + IupSetGlobal("PARENTDIALOG", "_MAIN_DIALOG_TEST_"); + ret = IupAlarm ("IupAlarm Test", "Message Text\nSecond Line", "But 1", "Button 2", "B3"); + IupSetGlobal("PARENTDIALOG", NULL); + //int ret = IupAlarm ("IupAlarm Test", "Message Text\nSecond Line\nVery long long long long long long long long long long long long text", "But 1", "Button 2", "B3"); + printf("Button(%d)\n", ret); +} + +static void new_gettext(void) +{ + int ret; + char text[1024] = "text first line\nsecond line"; + IupSetGlobal("PARENTDIALOG", "_MAIN_DIALOG_TEST_"); + ret = IupGetText("IupGetText Text", text); + IupSetGlobal("PARENTDIALOG", NULL); + if (ret) + { + printf("OK\n"); + printf("Text(%s)\n", text); + } + else + printf("CANCEL\n"); +} + +static void new_getfile(void) +{ + int ret; + char filename[1024] = "*.*"; + IupSetGlobal("PARENTDIALOG", "_MAIN_DIALOG_TEST_"); + ret = IupGetFile(filename); + IupSetGlobal("PARENTDIALOG", NULL); + if (ret!=-1) + { + printf("OK\n"); + if (ret == 0) + printf("File(%s)\n", filename); + else + printf("New File(%s)\n", filename); + } + else + printf("CANCEL\n"); +} + +static void new_list(void) +{ + int ret; + int size = 8 ; + int marks[8] = { 0,0,0,0,1,1,0,0 }; + const char *options[] = { + "Blue" , + "Red" , + "Green" , + "Yellow" , + "Black" , + "White" , + "Gray" , + "Brown" } ; + + IupSetGlobal("PARENTDIALOG", "_MAIN_DIALOG_TEST_"); + ret = IupListDialog(2,"IupListDialog Test",size,options,0,8,5,marks); + IupSetGlobal("PARENTDIALOG", NULL); + + if (ret == -1) + { + printf("CANCEL\n"); + } + else + { + int i; + char selection[80] = ""; + printf("OK\n"); + + for(i = 0 ; i < size ; i++) + { + if(marks[i]) + { + char temp[10]; + sprintf(temp,"%s\n",options[i]); + strcat(selection,temp); + } + } + + printf(" Options (%s)\n", selection); + } +} + +static int k_any(Ihandle *ih, int c) +{ + switch(c) + { + case K_m: + IupSetGlobal("PARENTDIALOG", "_MAIN_DIALOG_TEST_"); + IupMessage("IupMessage Test", "Message Text\nSecond Line."); + IupSetGlobal("PARENTDIALOG", NULL); + break; + case K_e: + new_message("ERROR", NULL); + break; + case K_i: + new_message("INFORMATION", NULL); + break; + case K_w: + new_message("WARNING", "OKCANCEL"); + break; + case K_q: + new_message("QUESTION", "YESNO"); + break; + case K_c: + new_color(); + break; + case K_f: + new_font(); + break; + case K_o: + new_file("OPEN", 0); + break; + case K_O: + new_file("OPEN", 1); + break; + case K_G: + new_file("OPEN", 2); + break; + case K_s: + new_file("SAVE", 0); + break; + case K_d: + new_file("DIR", 0); + break; + case K_a: + new_alarm(); + break; + case K_g: + new_getfile(); + break; + case K_t: + new_gettext(); + break; + case K_l: + new_list(); + break; + case K_ESC: + IupDestroy(ih); + return IUP_IGNORE; + } + return IUP_DEFAULT; +} + +void PreDialogsTest(void) +{ + char* msg = "Press a key for a pre-defined dialog:\n" + "e = IupMessageDlg(ERROR)\n" + "i = IupMessageDlg(INFORMATION)\n" + "w = IupMessageDlg(WARNING)\n" + "q = IupMessageDlg(QUESTION)\n" + "--------------------\n" + "o = IupFileDlg(OPEN)\n" + "O = IupFileDlg(OPEN+PREVIEW)\n" + "G = IupFileDlg(OPEN+PREVIEW+OPENGL)\n" + "s = IupFileDlg(SAVE)\n" + "d = IupFileDlg(DIR)\n" + "--------------------\n" + "c = IupColorDlg\n" + "f = IupFontDlg\n" + "--------------------\n" + "m = IupMessage\n" + "a = IupAlarm\n" + "t = IupGetText\n" + "g = IupGetFile\n" + "l = IupListDialog\n" + "--------------------\n" + "Esc = quit"; + Ihandle *dlg = IupDialog(IupVbox(IupLabel(msg), NULL)); + +#ifdef USE_OPENGL + IupGLCanvasOpen(); +#endif + + IupSetHandle("_MAIN_DIALOG_TEST_", dlg); + + IupSetAttribute(dlg, "TITLE", "Pre-defined Dialogs Test"); + IupSetAttribute(dlg, "MARGIN", "10x10"); + + IupSetCallback(dlg, "K_ANY", (Icallback)k_any); + IupSetCallback(dlg, "CLOSE_CB", (Icallback)close_cb); + + IupShow(dlg); +} + + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupControlsOpen(); + +#ifdef USE_OPENGL + IupGLCanvasOpen(); +#endif + + PreDialogsTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/progressbar.c b/iup/test/progressbar.c new file mode 100755 index 0000000..26b8bfd --- /dev/null +++ b/iup/test/progressbar.c @@ -0,0 +1,330 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "iup.h" +#include "iupcontrols.h" + +static float increment = 0.01f; +static Ihandle *progressbar1; +static Ihandle *progressbar2; +static Ihandle *btn_pause; +static Ihandle *timer = NULL; + +static unsigned char pixmap_play[] = +{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }; + +static unsigned char pixmap_restart[] = +{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,1,1,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }; + +static unsigned char pixmap_rewind[] = +{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }; + +static unsigned char pixmap_forward[] = +{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,1,2,1,1,1,1,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }; + +static unsigned char pixmap_pause[] = +{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 + ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }; + +static void createimg_s (void) +{ + Ihandle *img_restart, *img_play, *img_forward, *img_rewind, *img_pause; + + img_restart = IupImage(22,22, pixmap_restart); + img_play = IupImage(22,22, pixmap_play); + img_forward = IupImage(22,22, pixmap_forward); + img_rewind = IupImage(22,22, pixmap_rewind); + img_pause = IupImage(22,22, pixmap_pause); + + IupSetHandle ("img_restart", img_restart); + IupSetHandle ("img_play", img_play); + IupSetHandle ("img_forward", img_forward); + IupSetHandle ("img_rewind", img_rewind); + IupSetHandle ("img_pause", img_pause); + + IupSetAttribute (img_restart, "1", "0 0 0"); + IupSetAttribute (img_restart, "2", "BGCOLOR"); + IupSetAttribute (img_play, "1", "0 0 0"); + IupSetAttribute (img_play, "2", "BGCOLOR"); + IupSetAttribute (img_forward, "1", "0 0 0"); + IupSetAttribute (img_forward, "2", "BGCOLOR"); + IupSetAttribute (img_rewind, "1", "0 0 0"); + IupSetAttribute (img_rewind, "2", "BGCOLOR"); + IupSetAttribute (img_pause, "1", "0 0 0"); + IupSetAttribute (img_pause, "2", "BGCOLOR"); +} + +static int time_cb(void) +{ + float value = IupGetFloat(progressbar1, "VALUE"); + value += increment; + if (value > 1) value = 0; /* start over */ + IupSetfAttribute(progressbar1, "VALUE", "%f", (double)value); + + value = IupGetFloat(progressbar2, "VALUE"); + value += increment*50; + if (value > 50) value = 0; /* start over */ + IupSetfAttribute(progressbar2, "VALUE", "%f", (double)value); + return IUP_DEFAULT; +} + +static int btn_pause_cb(void) +{ + if (!IupGetInt(timer, "RUN")) + { + IupSetAttribute(timer, "RUN", "YES"); + IupSetAttribute(btn_pause, "IMAGE", "img_pause"); + } + else + { + IupSetAttribute(timer, "RUN", "NO"); + IupSetAttribute(btn_pause, "IMAGE", "img_play"); + } + + return IUP_DEFAULT; +} + + +static int unmap_cb(Ihandle* ih) +{ + IupDestroy(timer); + timer = NULL; + return IUP_DEFAULT; +} + +static int btn_restart_cb(void) +{ + IupSetAttribute(progressbar1, "VALUE", "0"); + IupSetAttribute(progressbar2, "VALUE", "0"); + return IUP_DEFAULT; +} + +static int btn_accelerate_cb(void) +{ + increment *= 2; + return IUP_DEFAULT; +} + +static int btn_decelerate_cb(void) +{ + increment /= 2; + return IUP_DEFAULT; +} + +static int btn_show1_cb(void) +{ + if (!IupGetInt(progressbar1, "DASHED")) + IupSetAttribute(progressbar1, "DASHED", "YES"); + else + IupSetAttribute(progressbar1, "DASHED", "NO"); + + return IUP_DEFAULT; +} + +static int btn_show2_cb(void) +{ + if (!IupGetInt(progressbar1, "MARQUEE")) + IupSetAttribute(progressbar1, "MARQUEE", "YES"); + else + IupSetAttribute(progressbar1, "MARQUEE", "NO"); + + return IUP_DEFAULT; +} + +void ProgressbarTest(void) +{ + Ihandle *dlg, *vbox, *hbox; + Ihandle *btn_restart, *btn_accelerate, *btn_decelerate, *btn_show1, *btn_show2; + + if (timer) + IupDestroy(timer); + timer = IupTimer(); + IupSetCallback(timer, "ACTION_CB", (Icallback)time_cb); + IupSetAttribute(timer, "TIME", "100"); + + progressbar1 = IupProgressBar(); + progressbar2 = IupProgressBar(); + + IupSetAttribute(progressbar1, "EXPAND", "YES"); + //IupSetAttribute(progressbar1, "DASHED", "YES"); + IupSetAttribute(progressbar1, "MARQUEE", "YES"); + + IupSetAttribute(progressbar2, "ORIENTATION", "VERTICAL"); + IupSetAttribute(progressbar2, "BGCOLOR", "255 0 128"); + IupSetAttribute(progressbar2, "FGCOLOR", "0 128 0"); + IupSetAttribute(progressbar2, "RASTERSIZE", "30x100"); + IupSetAttribute(progressbar2, "MAX", "50"); + IupSetAttribute(progressbar2, "VALUE", "25"); + + btn_restart = IupButton(NULL, NULL); + btn_pause = IupButton(NULL, NULL); + btn_accelerate = IupButton(NULL, NULL); + btn_decelerate = IupButton(NULL, NULL); + btn_show1 = IupButton("Dashed", NULL); + btn_show2 = IupButton("Marquee", NULL); + + createimg_s(); + + IupSetAttribute(btn_restart, "IMAGE", "img_restart"); + IupSetAttribute(btn_restart, "TIP", "Restart" ); + IupSetAttribute(btn_pause, "IMAGE", "img_pause"); + IupSetAttribute(btn_pause, "TIP", "Play/Pause"); + IupSetAttribute(btn_accelerate, "IMAGE", "img_forward"); + IupSetAttribute(btn_accelerate, "TIP", "Accelerate"); + IupSetAttribute(btn_decelerate, "IMAGE", "img_rewind"); + IupSetAttribute(btn_decelerate, "TIP", "Decelerate"); + IupSetAttribute(btn_show1, "TIP", "Dashed or Continuous"); + IupSetAttribute(btn_show2, "TIP", "Marquee or Defined"); + + hbox = IupHbox + ( + IupFill(), + btn_pause, + btn_restart, + btn_decelerate, + btn_accelerate, + btn_show1, + btn_show2, + IupFill(), + NULL + ); + + vbox = IupHbox(IupVbox(progressbar1, hbox, NULL), progressbar2, NULL); + IupSetAttribute(vbox, "MARGIN", "10x10"); + IupSetAttribute(vbox, "GAP", "5"); + + dlg = IupDialog(vbox); + + IupSetAttribute(dlg, "TITLE", "IupProgressBar Test"); + IupSetCallback(dlg, "UNMAP_CB", (Icallback) unmap_cb); + + IupSetCallback(btn_pause, "ACTION", (Icallback) btn_pause_cb); + IupSetCallback(btn_restart, "ACTION", (Icallback) btn_restart_cb); + IupSetCallback(btn_accelerate, "ACTION", (Icallback) btn_accelerate_cb); + IupSetCallback(btn_decelerate, "ACTION", (Icallback) btn_decelerate_cb); + IupSetCallback(btn_show1, "ACTION", (Icallback) btn_show1_cb); + IupSetCallback(btn_show2, "ACTION", (Icallback) btn_show2_cb); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); + + IupSetAttribute(timer, "RUN", "YES"); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + ProgressbarTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/sample.c b/iup/test/sample.c new file mode 100755 index 0000000..e99617d --- /dev/null +++ b/iup/test/sample.c @@ -0,0 +1,407 @@ +#include <stdlib.h> +#include <stdio.h> +#include <iup.h> + +static Ihandle* load_image_Tecgraf(void) +{ + unsigned char imgdata[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, 95, 108, 1, 90, 100, 117, 99, 123, 138, 166, 126, 137, 152, 181, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 105, 123, 147, 122, 137, 165, 255, 136, 152, 183, 255, 132, 149, 179, 250, 133, 149, 178, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 100, 115, 43, 111, 125, 150, 253, 140, 158, 190, 255, 135, 151, 182, 255, 132, 149, 179, 255, 131, 147, 177, 217, 153, 164, 188, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 102, 113, 134, 148, 134, 151, 182, 255, 137, 154, 185, 255, 115, 129, 154, 252, 114, 128, 155, 255, 130, 146, 175, 255, 132, 147, 175, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 158, 159, 162, 3, 108, 121, 145, 230, 144, 162, 195, 255, 137, 154, 185, 197, 74, 79, 86, 45, 41, 46, 55, 246, 120, 134, 162, 255, 129, 145, 174, 156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 101, 113, 48, 124, 139, 167, 255, 144, 161, 194, 255, 138, 155, 186, 67, 0, 0, 0, 0, 49, 54, 62, 150, 87, 98, 118, 255, 128, 144, 173, 223, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 102, 113, 132, 105, 137, 154, 185, 255, 139, 156, 188, 231, 143, 159, 187, 3, 0, 0, 0, 0, 64, 68, 76, 61, 70, 79, 95, 255, 127, 143, 172, 254, 134, 149, 175, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 121, 142, 153, 141, 159, 191, 255, 139, 156, 188, 164, 0, 0, 0, 0, 0, 0, 0, 0, 79, 82, 87, 3, 69, 77, 92, 241, 122, 137, 165, 255, 127, 142, 170, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, 122, 146, 191, 145, 163, 196, 255, 139, 156, 188, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 86, 101, 190, 115, 129, 156, 255, 126, 141, 170, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 125, 149, 227, 150, 168, 201, 255, 141, 157, 188, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 91, 107, 144, 113, 127, 153, 255, 125, 140, 169, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 163, 165, 167, 2, 112, 125, 150, 252, 155, 173, 203, 255, 143, 159, 189, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 94, 110, 109, 114, 128, 155, 255, 125, 140, 168, 175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 167, 181, 1, 120, 130, 149, 33, 48, 53, 59, 69, 43, 46, 52, 100, 50, 54, 59, 137, 116, 130, 156, 255, 155, 171, 201, 255, 105, 118, 142, 155, 104, 117, 141, 151, 105, 118, 141, 151, 105, 118, 142, 151, 101, 113, 136, 185, 111, 124, 150, 255, 116, 130, 156, 220, 112, 125, 148, 95, 115, 127, 150, 67, 123, 134, 156, 33, 168, 176, 190, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 119, 129, 147, 5, 109, 121, 142, 71, 106, 118, 140, 140, 105, 117, 140, 197, 107, 120, 144, 242, 120, 135, 162, 255, 123, 137, 163, 255, 44, 49, 58, 255, 28, 32, 39, 255, 125, 139, 164, 255, 150, 167, 197, 255, 138, 155, 186, 255, 131, 148, 178, 255, 125, 141, 170, 255, 119, 134, 162, 255, 114, 128, 154, 255, 108, 122, 147, 255, 104, 117, 141, 255, 102, 115, 138, 255, 103, 116, 139, 255, 107, 120, 145, 255, 111, 124, 149, 245, 113, 126, 151, 200, 113, 127, 152, 140, 116, 129, 154, 71, 122, 135, 158, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 118, 128, 145, 14, 106, 118, 140, 130, 104, 116, 139, 234, 105, 118, 142, 255, 128, 144, 173, 255, 147, 165, 199, 255, 157, 177, 213, 255, 150, 168, 202, 255, 140, 156, 187, 229, 41, 45, 52, 196, 39, 43, 51, 183, 130, 143, 168, 255, 144, 161, 192, 233, 109, 122, 145, 109, 105, 116, 138, 109, 99, 110, 130, 109, 92, 103, 123, 109, 91, 100, 117, 145, 97, 109, 131, 255, 95, 106, 128, 248, 74, 83, 97, 193, 64, 72, 85, 227, 56, 63, 75, 255, 55, 62, 75, 255, 65, 73, 88, 255, 90, 101, 121, 255, 111, 125, 150, 255, 114, 128, 154, 236, 116, 129, 155, 130, 127, 140, 165, 16, 0, 0, 0, 0, + 95, 101, 113, 22, 103, 115, 137, 220, 103, 116, 140, 255, 110, 123, 148, 255, 146, 165, 198, 255, 147, 165, 197, 232, 142, 158, 188, 147, 131, 144, 169, 78, 115, 123, 139, 20, 0, 0, 0, 0, 0, 0, 0, 0, 91, 97, 108, 68, 128, 142, 167, 255, 144, 162, 193, 212, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 100, 107, 31, 120, 135, 163, 255, 133, 150, 180, 231, 0, 0, 0, 0, 0, 0, 0, 0, 86, 89, 93, 20, 50, 54, 61, 73, 37, 40, 46, 141, 33, 36, 42, 230, 46, 52, 63, 255, 107, 120, 144, 255, 116, 130, 157, 255, 118, 133, 159, 223, 132, 147, 174, 24, + 76, 83, 95, 114, 104, 117, 140, 255, 105, 117, 141, 255, 118, 133, 160, 253, 139, 155, 184, 116, 134, 143, 161, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 100, 110, 74, 122, 137, 163, 255, 143, 160, 191, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, 114, 120, 31, 123, 138, 166, 255, 136, 153, 183, 228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, 93, 97, 5, 42, 45, 51, 111, 86, 97, 117, 253, 118, 133, 160, 255, 119, 133, 161, 255, 133, 149, 180, 116, + 46, 50, 56, 109, 67, 76, 91, 255, 105, 118, 142, 255, 107, 120, 145, 254, 112, 125, 149, 131, 127, 139, 161, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 98, 109, 74, 116, 130, 156, 255, 142, 159, 190, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 115, 122, 31, 128, 143, 172, 255, 141, 157, 185, 228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, 137, 163, 7, 122, 136, 162, 122, 120, 135, 162, 254, 121, 136, 164, 255, 136, 152, 184, 255, 126, 141, 168, 116, + 71, 74, 79, 17, 31, 35, 41, 206, 42, 47, 57, 255, 77, 87, 105, 255, 103, 116, 140, 255, 110, 124, 149, 239, 112, 125, 150, 157, 115, 128, 153, 89, 122, 134, 158, 30, 147, 158, 177, 2, 0, 0, 0, 0, 81, 87, 96, 65, 109, 123, 148, 255, 141, 158, 190, 212, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 103, 112, 31, 135, 151, 180, 255, 141, 156, 183, 231, 0, 0, 0, 0, 153, 164, 183, 1, 134, 147, 171, 30, 124, 138, 165, 84, 123, 138, 165, 154, 122, 137, 164, 235, 127, 143, 172, 255, 140, 157, 189, 255, 144, 162, 195, 255, 129, 144, 172, 218, 126, 138, 161, 22, + 0, 0, 0, 0, 64, 68, 73, 7, 39, 43, 49, 118, 32, 36, 42, 225, 30, 35, 42, 255, 50, 57, 68, 255, 72, 81, 97, 255, 91, 102, 123, 255, 105, 118, 142, 255, 113, 127, 152, 240, 115, 129, 155, 204, 111, 124, 149, 196, 111, 125, 150, 255, 126, 141, 170, 234, 119, 133, 159, 120, 120, 134, 160, 116, 121, 135, 161, 117, 121, 135, 162, 119, 116, 130, 155, 152, 127, 142, 170, 255, 125, 140, 168, 248, 123, 138, 166, 199, 130, 145, 173, 235, 140, 155, 183, 255, 143, 160, 190, 255, 143, 161, 193, 255, 147, 165, 199, 255, 145, 164, 197, 255, 132, 148, 177, 230, 127, 140, 166, 126, 124, 134, 151, 12, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 141, 144, 3, 55, 58, 63, 58, 37, 40, 46, 126, 34, 38, 44, 184, 34, 38, 44, 235, 35, 39, 47, 254, 49, 55, 66, 255, 64, 72, 87, 255, 77, 87, 104, 255, 88, 98, 118, 255, 96, 108, 130, 255, 103, 116, 139, 255, 108, 122, 147, 255, 113, 127, 153, 255, 118, 133, 160, 255, 124, 140, 168, 255, 133, 148, 176, 255, 141, 156, 183, 255, 146, 161, 187, 255, 144, 159, 186, 255, 131, 146, 174, 254, 127, 141, 168, 237, 126, 141, 168, 188, 123, 137, 162, 131, 112, 123, 143, 61, 128, 132, 140, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 94, 98, 19, 64, 68, 73, 56, 53, 57, 65, 82, 62, 67, 76, 116, 66, 74, 89, 255, 95, 107, 129, 255, 80, 88, 103, 155, 81, 90, 105, 151, 86, 95, 112, 151, 95, 104, 122, 151, 98, 109, 128, 180, 124, 139, 166, 255, 109, 122, 146, 218, 100, 110, 128, 84, 96, 104, 118, 56, 105, 109, 117, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 174, 176, 2, 74, 83, 98, 252, 131, 147, 178, 255, 140, 155, 184, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 122, 134, 157, 114, 151, 169, 203, 255, 123, 138, 165, 174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 76, 90, 224, 122, 137, 165, 255, 136, 152, 182, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 139, 165, 147, 146, 164, 198, 255, 122, 137, 165, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 69, 81, 191, 110, 124, 149, 255, 134, 151, 181, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 143, 170, 193, 142, 160, 192, 255, 122, 137, 164, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 63, 74, 150, 94, 105, 127, 255, 133, 149, 179, 166, 0, 0, 0, 0, 0, 0, 0, 0, 115, 119, 128, 5, 130, 145, 174, 242, 137, 154, 186, 255, 125, 139, 166, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 58, 66, 102, 72, 81, 97, 255, 132, 148, 178, 236, 148, 161, 187, 5, 0, 0, 0, 0, 110, 121, 140, 64, 140, 157, 189, 255, 127, 142, 171, 254, 131, 144, 169, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 65, 71, 43, 47, 52, 63, 255, 127, 143, 172, 255, 132, 148, 177, 75, 0, 0, 0, 0, 121, 134, 158, 160, 139, 156, 188, 255, 123, 138, 165, 223, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 154, 156, 158, 1, 36, 39, 46, 227, 106, 119, 143, 255, 130, 145, 175, 203, 114, 125, 147, 51, 123, 138, 166, 247, 131, 147, 177, 255, 123, 138, 165, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 41, 47, 143, 68, 77, 93, 255, 128, 144, 174, 255, 126, 141, 170, 252, 129, 145, 174, 255, 123, 138, 166, 255, 127, 141, 167, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 68, 73, 40, 34, 38, 46, 250, 117, 131, 158, 255, 126, 142, 171, 255, 124, 140, 168, 255, 125, 139, 166, 214, 140, 152, 172, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 44, 50, 134, 58, 66, 79, 255, 123, 138, 166, 255, 123, 138, 166, 250, 127, 140, 165, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 154, 156, 158, 1, 46, 50, 55, 83, 82, 89, 102, 123, 106, 116, 136, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + Ihandle* image = IupImageRGBA(32, 32, imgdata); + return image; +} + +static Ihandle* load_image_LogoTecgraf(void) +{ + unsigned char imgdata[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 120, 143, 125, 132, 148, 178, 173, 133, 149, 178, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 110, 130, 48, 130, 147, 177, 254, 124, 139, 167, 254, 131, 147, 176, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, 128, 153, 134, 142, 159, 191, 194, 47, 52, 61, 110, 114, 128, 154, 222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 143, 172, 192, 140, 156, 188, 99, 65, 69, 76, 16, 97, 109, 131, 251, 129, 144, 172, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 147, 175, 232, 140, 157, 188, 43, 0, 0, 0, 0, 100, 112, 134, 211, 126, 141, 169, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 78, 88, 26, 48, 52, 57, 60, 135, 150, 178, 254, 108, 121, 145, 83, 105, 118, 142, 76, 106, 119, 143, 201, 118, 133, 159, 122, 117, 129, 152, 25, 168, 176, 190, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 118, 128, 145, 3, 104, 117, 140, 92, 114, 127, 152, 180, 131, 147, 177, 237, 133, 149, 178, 249, 38, 42, 50, 222, 137, 152, 180, 249, 126, 142, 170, 182, 114, 128, 154, 182, 104, 117, 140, 227, 95, 107, 128, 238, 83, 93, 112, 248, 84, 95, 113, 239, 104, 117, 141, 180, 115, 129, 155, 93, 127, 140, 165, 4, + 98, 109, 130, 153, 109, 123, 147, 254, 145, 163, 195, 153, 138, 154, 182, 56, 115, 123, 138, 5, 92, 99, 109, 35, 134, 149, 177, 230, 0, 0, 0, 0, 0, 0, 0, 0, 120, 133, 159, 143, 135, 151, 181, 115, 86, 89, 93, 5, 41, 45, 51, 54, 40, 45, 53, 150, 107, 120, 144, 254, 122, 137, 164, 154, + 51, 57, 66, 147, 83, 93, 112, 255, 108, 121, 145, 159, 113, 126, 151, 62, 123, 136, 159, 8, 87, 93, 103, 35, 125, 141, 169, 230, 0, 0, 0, 0, 0, 0, 0, 0, 129, 143, 169, 143, 140, 156, 184, 115, 134, 147, 172, 8, 124, 138, 165, 60, 124, 139, 167, 155, 131, 147, 177, 255, 131, 147, 176, 153, + 64, 68, 73, 2, 36, 39, 45, 86, 41, 46, 54, 173, 60, 67, 80, 232, 75, 84, 101, 251, 89, 100, 120, 228, 105, 118, 142, 250, 110, 123, 148, 187, 118, 132, 158, 187, 126, 141, 169, 229, 134, 149, 177, 239, 136, 152, 179, 250, 136, 152, 181, 234, 139, 156, 186, 175, 130, 145, 173, 90, 124, 134, 151, 3, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, 74, 79, 19, 60, 64, 73, 50, 92, 103, 124, 254, 86, 95, 111, 84, 90, 100, 117, 76, 126, 141, 168, 201, 113, 126, 150, 119, 99, 105, 117, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 105, 125, 231, 135, 151, 181, 46, 0, 0, 0, 0, 137, 154, 184, 212, 123, 137, 164, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, 83, 98, 191, 133, 149, 179, 102, 111, 121, 139, 17, 134, 150, 180, 252, 126, 140, 166, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 48, 57, 132, 121, 136, 164, 197, 121, 135, 161, 115, 130, 146, 175, 221, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 47, 52, 46, 87, 98, 118, 254, 126, 142, 170, 254, 124, 139, 166, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 57, 67, 118, 115, 128, 152, 170, 127, 140, 164, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + Ihandle* image = IupImageRGBA(16, 16, imgdata); + return image; +} + +static unsigned char img_bits1[] = +{ + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1 +,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1 +,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1 +,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1 +,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1 +,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1 +,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1 +,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1 +,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +,2,2,2,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +,2,2,2,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +,2,2,2,0,2,0,2,0,2,2,0,2,2,2,0,0,0,2,2,2,0,0,2,0,2,2,0,0,0,2,2,2 +,2,2,2,0,2,0,0,2,0,0,2,0,2,0,2,2,2,0,2,0,2,2,0,0,2,0,2,2,2,0,2,2 +,2,2,2,0,2,0,2,2,0,2,2,0,2,2,2,2,2,0,2,0,2,2,2,0,2,0,2,2,2,0,2,2 +,2,2,2,0,2,0,2,2,0,2,2,0,2,2,0,0,0,0,2,0,2,2,2,0,2,0,0,0,0,0,2,2 +,2,2,2,0,2,0,2,2,0,2,2,0,2,0,2,2,2,0,2,0,2,2,2,0,2,0,2,2,2,2,2,2 +,2,2,2,0,2,0,2,2,0,2,2,0,2,0,2,2,2,0,2,0,2,2,0,0,2,0,2,2,2,0,2,2 +,2,2,2,0,2,0,2,2,0,2,2,0,2,2,0,0,0,0,2,2,0,0,2,0,2,2,0,0,0,2,2,2 +,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,2,2,2,2,2,2,2,2 +,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,2,2,2,0,2,2,2,2,2,2,2,2 +,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,2,2,2,2,2,2,2,2,2 +,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1 +,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1 +,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1 +,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +}; + +static unsigned char img_bits2[] = +{ + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2 +,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2 +,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2 +,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2 +,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2 +,2,2,2,2,2,2,2,2,2,2,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2 +,2,2,2,2,2,2,2,2,2,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2 +,2,2,2,2,2,2,2,2,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2 +,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 +,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 +,3,3,3,0,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 +,3,3,3,0,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 +,3,3,3,0,3,0,3,0,3,3,0,3,3,3,1,1,0,3,3,3,0,0,3,0,3,3,0,0,0,3,3,3 +,3,3,3,0,3,0,0,3,0,0,3,0,3,0,1,1,3,0,3,0,3,3,0,0,3,0,3,3,3,0,3,3 +,3,3,3,0,3,0,3,3,0,3,3,0,3,3,1,1,3,0,3,0,3,3,3,0,3,0,3,3,3,0,3,3 +,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +,3,3,3,0,3,0,3,3,0,3,3,0,3,0,1,1,3,0,3,0,3,3,0,0,3,0,3,3,3,0,3,3 +,3,3,3,0,3,0,3,3,0,3,3,0,3,3,1,1,0,0,3,3,0,0,3,0,3,3,0,0,0,3,3,3 +,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3 +,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,0,3,3,3,0,3,3,3,3,3,3,3,3 +,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,0,0,0,3,3,3,3,3,3,3,3,3 +,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 +,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 +,2,2,2,2,2,2,2,3,3,3,3,3,3,3,1,1,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2 +,2,2,2,2,2,2,3,3,3,3,3,3,3,3,1,1,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2 +,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2 +,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +}; + +static int valuechanged_cb(Ihandle *ih) +{ + printf("VALUECHANGED_CB(%s)=%s\n", IupGetClassName(ih), IupGetAttribute(ih, "VALUE")); + return IUP_DEFAULT; +} + +static int getfocus_cb(Ihandle *ih) +{ + printf("GETFOCUS_CB(%s)\n", IupGetClassName(ih)); + return IUP_DEFAULT; +} + +static int killfocus_cb(Ihandle *ih) +{ + printf("KILLFOCUS_CB(%s)\n", IupGetClassName(ih)); + return IUP_DEFAULT; +} + +static int leavewindow_cb(Ihandle *ih) +{ + printf("LEAVEWINDOW_CB(%s)\n", IupGetClassName(ih)); + return IUP_DEFAULT; +} + +static int enterwindow_cb(Ihandle *ih) +{ + printf("ENTERWINDOW_CB(%s)\n", IupGetClassName(ih)); + return IUP_DEFAULT; +} + +char *iupKeyCodeToName(int code); + +static int k_any(Ihandle *ih, int c) +{ + if (iup_isprint(c)) + printf("K_ANY(%s, %d = %s \'%c\')\n", IupGetClassName(ih), c, iupKeyCodeToName(c), (char)c); + else + printf("K_ANY(%s, %d = %s)\n", IupGetClassName(ih), c, iupKeyCodeToName(c)); + return IUP_CONTINUE; +} + +static int help_cb(Ihandle* ih) +{ + printf("HELP_CB(%s)\n", IupGetClassName(ih)); + return IUP_DEFAULT; +} + +static Ihandle* set_callbacks(Ihandle* ih) +{ + IupSetCallback(ih, "VALUECHANGED_CB", (Icallback)valuechanged_cb); + +// IupSetCallback(ih, "GETFOCUS_CB", (Icallback)getfocus_cb); +// IupSetCallback(ih, "KILLFOCUS_CB", (Icallback)killfocus_cb); + +// IupSetCallback(ih, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); +// IupSetCallback(ih, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); + +// IupSetCallback(ih, "K_ANY", (Icallback)k_any); +// IupSetCallback(ih, "HELP_CB", (Icallback)help_cb); + + return ih; +} + +void SampleTest(void) +{ + Ihandle *mnu, *_hbox_1, *_cnv_1, *_vbox_1, *dlg, *img, + *_frm_1, *_frm_2, *_frm_3, *_frm_4, *_frm_5, *pbar, *val, *tabs, + *_list_1, *_list_2, *_list_3, *_text_1, *_ml_1, *tree; + + //img = IupImage(32,32, img_bits1); + //IupSetHandle ("img1", img); + //IupSetAttribute (img, "0", "0 0 0"); + //IupSetAttribute (img, "1", "BGCOLOR"); + //IupSetAttribute (img, "2", "255 0 0"); + + img = load_image_Tecgraf(); + IupSetHandle ("img1", img); + + img = IupImage(32,32, img_bits2); + IupSetHandle ("img2", img); + IupSetAttribute (img, "0", "0 0 0"); + IupSetAttribute (img, "1", "0 255 0"); + IupSetAttribute (img, "2", "BGCOLOR"); + IupSetAttribute (img, "3", "255 0 0"); + + mnu = IupMenu( + IupSubmenu("IupSubmenu 1", IupMenu( + IupSetAttributes(IupItem("IupItem 1 Checked", NULL), "VALUE=ON"), + IupSeparator(), + IupSetAttributes(IupItem("IupItem 2 Disabled", NULL), "ACTIVE=NO"), + NULL)), + IupItem("IupItem 3", NULL), + IupItem("IupItem 4", NULL), + NULL); + IupSetHandle("mnu",mnu); + + _frm_1 = IupFrame( + IupVbox( + set_callbacks(IupSetAttributes(IupButton("Button Text", NULL), "PADDING=5x5")), + set_callbacks(IupSetAttributes(IupButton("Text", NULL), "IMAGE=img1, PADDING=5x5")), + set_callbacks(IupSetAttributes(IupButton(NULL, NULL), "IMAGE=img1")), + set_callbacks(IupSetAttributes(IupButton("", NULL), "IMAGE=img1,IMPRESS=img2")), + NULL)); + IupSetAttribute(_frm_1,"TITLE","IupButton"); + + _frm_2 = IupFrame( + IupVbox( + IupLabel("Label Text"), + IupSetAttributes(IupLabel(NULL), "SEPARATOR=HORIZONTAL, MAXSIZE=150, NAME=SAMP_SEP"), + IupSetAttributes(IupLabel(NULL), "IMAGE=img1"), + NULL)); + IupSetAttribute(_frm_2,"TITLE","IupLabel"); + + _frm_3 = IupFrame( + IupVbox( + set_callbacks(IupSetAttributes(IupToggle("Toggle Text", NULL), "VALUE=ON")), + set_callbacks(IupSetAttributes(IupToggle(NULL, NULL), "VALUE=ON,IMAGE=img1,IMPRESS=img2")), + set_callbacks(IupSetAttributes(IupToggle(NULL, NULL), "VALUE=ON,IMAGE=img1")), + IupSetAttributes(IupFrame(IupRadio(IupVbox( + set_callbacks(IupToggle("Toggle Text", NULL)), + set_callbacks(IupToggle("Toggle Text", NULL)), + NULL))), "TITLE=IupRadio"), + NULL)); + IupSetAttribute(_frm_3,"TITLE","IupToggle"); + + _text_1 = IupText( NULL); + IupSetAttribute(_text_1,"VALUE","Single Line Text"); + IupSetAttribute(_text_1,"SIZE","80x"); + + _ml_1 = IupMultiLine( NULL); + IupSetAttribute(_ml_1,"VALUE","Multiline Text\nSecond Line\nThird Line"); + IupSetAttribute(_ml_1,"EXPAND","YES"); + IupSetAttribute(_ml_1,"SIZE","80x40"); + + _frm_4 = IupFrame(IupVbox( + set_callbacks(_text_1), + set_callbacks(_ml_1), + NULL)); + IupSetAttribute(_frm_4,"TITLE","IupText"); + + _list_1 = IupList( NULL); +// IupSetAttribute(_list_1,"EXPAND","YES"); + IupSetAttribute(_list_1,"VALUE","1"); + IupSetAttribute(_list_1,"1","Item 1 Text"); + IupSetAttribute(_list_1,"2","Item 2 Text"); + IupSetAttribute(_list_1,"3","Item 3 Text"); + + _list_2 = IupList( NULL); + IupSetAttribute(_list_2,"DROPDOWN","YES"); +// IupSetAttribute(_list_2,"EXPAND","YES"); + IupSetAttribute(_list_2,"VALUE","2"); + IupSetAttribute(_list_2,"1","Item 1 Text"); + IupSetAttribute(_list_2,"2","Item 2 Text"); + IupSetAttribute(_list_2,"3","Item 3 Text"); + + _list_3 = IupList( NULL); + IupSetAttribute(_list_3,"EDITBOX","YES"); +// IupSetAttribute(_list_3,"EXPAND","YES"); + IupSetAttribute(_list_3,"VALUE","3"); + IupSetAttribute(_list_3,"1","Item 1 Text"); + IupSetAttribute(_list_3,"2","Item 2 Text"); + IupSetAttribute(_list_3,"3","Item 3 Text"); + + _frm_5 = IupFrame(IupVbox( + set_callbacks(_list_1), + set_callbacks(_list_2), + set_callbacks(_list_3), + NULL)); + IupSetAttribute(_frm_5,"TITLE","IupList"); + + _hbox_1 = IupHbox( + _frm_1, + _frm_2, + _frm_3, + _frm_4, + _frm_5, + NULL); + + val = IupVal(NULL); + set_callbacks(val); + + pbar = IupProgressBar(); + IupSetAttribute(pbar, "VALUE", "0.5"); + set_callbacks(pbar); + + tabs = IupTabs(IupVbox(NULL), IupVbox(NULL), IupVbox(NULL), NULL); + IupSetAttribute(tabs,"TABTITLE0","Tab Title 0"); + IupSetAttribute(tabs,"TABTITLE1","Tab Title 1"); + IupSetAttributeHandle(tabs,"TABIMAGE1", load_image_LogoTecgraf()); + IupSetAttribute(tabs,"TABTITLE2","Tab Title 2"); + IupSetAttribute(tabs,"RASTERSIZE","300x50"); +// IupSetAttribute(tabs,"PADDING","5x5"); + set_callbacks(tabs); + + tree = IupTree(); + IupSetAttribute(tree, "SHOWRENAME", "YES"); + IupSetAttribute(tree,"RASTERSIZE","100x150"); + set_callbacks(tree); + + _cnv_1 = IupCanvas(NULL); + IupSetAttribute(_cnv_1,"BGCOLOR","128 255 0"); + IupSetAttribute(_cnv_1,"SCROLLBAR","YES"); + IupSetAttribute(_cnv_1,"EXPAND","HORIZONTAL"); + IupSetAttribute(_cnv_1,"RASTERSIZE","x100"); +// IupSetAttribute(_cnv_1,"CANFOCUS","NO"); + set_callbacks(_cnv_1); + + _vbox_1 = IupVbox( + _hbox_1, + IupHbox(IupSetAttributes(IupFrame(IupHbox(val, NULL)), "TITLE=IupVal"), + IupSetAttributes(IupFrame(IupHbox(pbar, NULL)), "TITLE=IupProgressBar"), + IupSetAttributes(IupFrame(IupHbox(tabs, NULL)), "TITLE=IupTabs"), + NULL), + IupHbox(IupSetAttributes(IupFrame(IupHbox(_cnv_1, NULL)), "TITLE=IupCanvas"), + IupSetAttributes(IupFrame(IupHbox(tree, NULL)), "TITLE=IupTree"), + NULL), + NULL); + IupSetAttribute(_vbox_1,"MARGIN","5x5"); + IupSetAttribute(_vbox_1,"GAP","5"); + + dlg = IupDialog(_vbox_1); + IupSetHandle("dlg",dlg); + IupSetAttribute(dlg,"MENU","mnu"); + IupSetAttribute(dlg,"TITLE","IupDialog Title"); +// IupSetAttribute(dlg,"COMPOSITED","YES"); /* Windows Only */ +// IupSetAttribute(dlg, "OPACITY", "192"); + +// IupSetAttribute(dlg, "BGCOLOR", "173 177 194"); // Motif BGCOLOR for documentation +// IupSetAttribute(_vbox_1, "BGCOLOR", "92 92 255"); +// IupSetAttribute(dlg, "BGCOLOR", "92 92 255"); +// IupSetAttribute(dlg, "BACKGROUND", "200 10 80"); + + //IupSetGlobal("DLGBGCOLOR", "92 92 255"); + //IupSetGlobal("TXTFGCOLOR", "255 92 92"); + //IupSetGlobal("TXTBGCOLOR", "92 92 255"); + +// IupSetAttribute(dlg, "FONT", "Helvetica, 24"); +// IupSetAttribute(dlg, "FONT", "-*-helvetica-*-r-*-*-18-*-*-*-*-*-*-*"); + +// IupSetAttribute(box, "FGCOLOR", "255 0 0"); + + IupMap(dlg); + + IupSetAttribute(tree, "TITLE0", "Figures"); + IupSetAttribute(tree, "ADDLEAF0", "Other"); /* new id=1 */ + IupSetAttribute(tree, "ADDBRANCH1", "triangle"); /* new id=2 */ + IupSetAttribute(tree, "ADDLEAF2", "equilateral"); /* ... */ + IupSetAttribute(tree, "ADDLEAF3", "isoceles"); + IupSetAttribute(tree, "ADDLEAF4", "scalenus"); + + IupShow(dlg); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + SampleTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/sbox.c b/iup/test/sbox.c new file mode 100755 index 0000000..13b5582 --- /dev/null +++ b/iup/test/sbox.c @@ -0,0 +1,46 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" + +void SboxTest(void) +{ + Ihandle *dlg, *bt, *box, *lbl, *ml, *vbox; + + bt = IupButton("Button", NULL); + //IupSetAttribute(bt, "EXPAND", "VERTICAL"); /* This is the only necessary EXPAND */ + IupSetAttribute(bt, "EXPAND", "YES"); + + box = IupSbox(bt); + IupSetAttribute(box, "DIRECTION", "SOUTH"); /* place at the bottom of the button */ +// IupSetAttribute(box, "COLOR", "0 255 0"); + + ml = IupMultiLine(NULL); + IupSetAttribute(ml, "EXPAND", "YES"); + IupSetAttribute(ml, "VISIBLELINES", "5"); + vbox = IupVbox(box, ml, NULL); + + lbl = IupLabel("Label"); + IupSetAttribute(lbl, "EXPAND", "VERTICAL"); + + dlg = IupDialog(IupHbox(vbox, lbl, NULL)); + IupSetAttribute(dlg, "TITLE", "IupSbox Example"); + IupSetAttribute(dlg, "MARGIN", "10x10"); + IupSetAttribute(dlg, "GAP", "10"); + + IupShow(dlg); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + SboxTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/scanf.c b/iup/test/scanf.c new file mode 100755 index 0000000..2ea7663 --- /dev/null +++ b/iup/test/scanf.c @@ -0,0 +1,39 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" + +void ScanfTest(void) +{ + int ret; + int integer = 12; + float real = 1e-3f; + char text[300]="This is a vector of characters"; + char *fmt = + { + "IupScanf Example\n" + "Text: %300.5%s\n" + "Real: %20.10%g\n" + "Integer: %20.10%d\n" + }; + +// IupSetLanguage("ENGLISH"); + + ret = IupScanf(fmt, text, &real, &integer); + if (ret == -1) + IupMessage("IupScanf","Operation canceled"); + else + IupMessagef("IupScanf","Text: %s\nReal: %f\nInteger: %d\nFields read successfully: %d",text,real,integer,ret); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + ScanfTest(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/spin.c b/iup/test/spin.c new file mode 100755 index 0000000..63a3bbc --- /dev/null +++ b/iup/test/spin.c @@ -0,0 +1,43 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "iup.h" + + +static int spin_cb(Ihandle* ih, int inc) +{ + (void)ih; + /* does nothing, just print the call */ + printf("SPIN_CB(%d)\n", inc); + return IUP_DEFAULT; +} + +void SpinTest(void) +{ + Ihandle *dlg, *spinbox; + + spinbox = IupSpinbox(IupSetAttributes(IupText(NULL), "SIZE=50x")); + + IupSetCallback(spinbox, "SPIN_CB", (Icallback)spin_cb); + + dlg = IupDialog(IupVbox(spinbox, NULL)); + IupSetAttribute(dlg, "MARGIN", "10x10"); + + IupSetAttribute(dlg, "TITLE", "IupSpin Test"); + IupShow(dlg); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + SpinTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/sysinfo.c b/iup/test/sysinfo.c new file mode 100755 index 0000000..2f0d9c0 --- /dev/null +++ b/iup/test/sysinfo.c @@ -0,0 +1,60 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" + +void SysInfoTest(void) +{ + char* sysver; + int motif = 0; + + printf("IUP System Info:\n"); + printf(" Version: %s\n", IupVersion()); + printf(" Copyright: %s\n", IUP_COPYRIGHT); + printf(" Driver: %s\n", IupGetGlobal("DRIVER")); + printf(" System: %s\n", IupGetGlobal("SYSTEM")); + printf(" System Version: %s\n\n", IupGetGlobal("SYSTEMVERSION")); + printf(" System Language: %s\n\n", IupGetGlobal("SYSTEMLANGUAGE")); + + sysver = IupGetGlobal("MOTIFVERSION"); + if (sysver) + { + printf(" Motif Version: %s\n", sysver); + printf(" Motif Number: %s\n", IupGetGlobal("MOTIFNUMBER")); + printf(" X Server Vendor: %s\n", IupGetGlobal("XSERVERVENDOR")); + printf(" X Vendor Release: %s\n\n", IupGetGlobal("XVENDORRELEASE")); + motif = 1; + } + + sysver = IupGetGlobal("GTKVERSION"); + if (sysver) + printf(" GTK Version: %s\n", sysver); + + printf(" Screen Depth: %s\n", IupGetGlobal("SCREENDEPTH")); + printf(" Screen Size: %s\n", IupGetGlobal("SCREENSIZE")); + printf(" Full Screen Size: %s\n", IupGetGlobal("FULLSIZE")); + printf(" True Color Canvas: %s\n\n", IupGetGlobal("TRUECOLORCANVAS")); + + if (!motif) + { + printf(" Virtual Screen: %s\n", IupGetGlobal("VIRTUALSCREEN")); + printf(" Monitors Info: %s\n", IupGetGlobal("MONITORSINFO")); + } + + printf(" Computer Name: %s\n", IupGetGlobal("COMPUTERNAME")); + printf(" User Name: %s\n", IupGetGlobal("USERNAME")); + printf(" Default Font: %s\n", IupGetGlobal("DEFAULTFONT")); +} + + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + SysInfoTest(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/tabs.c b/iup/test/tabs.c new file mode 100755 index 0000000..a069f01 --- /dev/null +++ b/iup/test/tabs.c @@ -0,0 +1,403 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "iup.h" +#include "iupkey.h" + +static Ihandle* load_image_LogoTecgraf(void) +{ + unsigned char imgdata[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 120, 143, 125, 132, 148, 178, 173, 133, 149, 178, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 110, 130, 48, 130, 147, 177, 254, 124, 139, 167, 254, 131, 147, 176, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, 128, 153, 134, 142, 159, 191, 194, 47, 52, 61, 110, 114, 128, 154, 222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 143, 172, 192, 140, 156, 188, 99, 65, 69, 76, 16, 97, 109, 131, 251, 129, 144, 172, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 147, 175, 232, 140, 157, 188, 43, 0, 0, 0, 0, 100, 112, 134, 211, 126, 141, 169, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 78, 88, 26, 48, 52, 57, 60, 135, 150, 178, 254, 108, 121, 145, 83, 105, 118, 142, 76, 106, 119, 143, 201, 118, 133, 159, 122, 117, 129, 152, 25, 168, 176, 190, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 118, 128, 145, 3, 104, 117, 140, 92, 114, 127, 152, 180, 131, 147, 177, 237, 133, 149, 178, 249, 38, 42, 50, 222, 137, 152, 180, 249, 126, 142, 170, 182, 114, 128, 154, 182, 104, 117, 140, 227, 95, 107, 128, 238, 83, 93, 112, 248, 84, 95, 113, 239, 104, 117, 141, 180, 115, 129, 155, 93, 127, 140, 165, 4, + 98, 109, 130, 153, 109, 123, 147, 254, 145, 163, 195, 153, 138, 154, 182, 56, 115, 123, 138, 5, 92, 99, 109, 35, 134, 149, 177, 230, 0, 0, 0, 0, 0, 0, 0, 0, 120, 133, 159, 143, 135, 151, 181, 115, 86, 89, 93, 5, 41, 45, 51, 54, 40, 45, 53, 150, 107, 120, 144, 254, 122, 137, 164, 154, + 51, 57, 66, 147, 83, 93, 112, 255, 108, 121, 145, 159, 113, 126, 151, 62, 123, 136, 159, 8, 87, 93, 103, 35, 125, 141, 169, 230, 0, 0, 0, 0, 0, 0, 0, 0, 129, 143, 169, 143, 140, 156, 184, 115, 134, 147, 172, 8, 124, 138, 165, 60, 124, 139, 167, 155, 131, 147, 177, 255, 131, 147, 176, 153, + 64, 68, 73, 2, 36, 39, 45, 86, 41, 46, 54, 173, 60, 67, 80, 232, 75, 84, 101, 251, 89, 100, 120, 228, 105, 118, 142, 250, 110, 123, 148, 187, 118, 132, 158, 187, 126, 141, 169, 229, 134, 149, 177, 239, 136, 152, 179, 250, 136, 152, 181, 234, 139, 156, 186, 175, 130, 145, 173, 90, 124, 134, 151, 3, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, 74, 79, 19, 60, 64, 73, 50, 92, 103, 124, 254, 86, 95, 111, 84, 90, 100, 117, 76, 126, 141, 168, 201, 113, 126, 150, 119, 99, 105, 117, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 105, 125, 231, 135, 151, 181, 46, 0, 0, 0, 0, 137, 154, 184, 212, 123, 137, 164, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, 83, 98, 191, 133, 149, 179, 102, 111, 121, 139, 17, 134, 150, 180, 252, 126, 140, 166, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 48, 57, 132, 121, 136, 164, 197, 121, 135, 161, 115, 130, 146, 175, 221, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 47, 52, 46, 87, 98, 118, 254, 126, 142, 170, 254, 124, 139, 166, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 57, 67, 118, 115, 128, 152, 170, 127, 140, 164, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + Ihandle* image = IupImageRGBA(16, 16, imgdata); + return image; +} + +#define TEST_IMAGE_SIZE 16 + +static Ihandle* load_image_TestImage(void) +{ + unsigned char image_data_8 [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE] = + { + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,1,1,1,1,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,2,2,2,2,0,0,0,5, + 5,0,0,0,3,3,3,3,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,4,4,4,4,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + }; + + Ihandle* image = IupImage(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_8); + IupSetAttribute(image, "0", "BGCOLOR"); + IupSetAttribute(image, "1", "255 0 0"); + IupSetAttribute(image, "2", "0 255 0"); + IupSetAttribute(image, "3", "0 0 255"); + IupSetAttribute(image, "4", "255 255 255"); + IupSetAttribute(image, "5", "0 0 0"); + + return image; +} + +static int cbChildButton(Ihandle* ih) +{ + printf("button(%s)\n", IupGetAttribute(ih, "TITLE")); + return IUP_DEFAULT; +} + +static int cbValuePos(Ihandle* ih) +{ + Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS"); + IupSetAttribute(tabs, "VALUEPOS", "0"); +// printf("VALUE=%s\n", IupGetAttribute(tabs, "VALUE")); + return IUP_DEFAULT; +} + +static int cbType(Ihandle* ih, int v) +{ + if (v) + { + char* title = IupGetAttribute(ih, "TITLE"); + Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS"); + + switch(*title) + { + case 'L': + IupSetAttribute(tabs, "TABTYPE", "LEFT"); + break; + case 'R': + IupSetAttribute(tabs, "TABTYPE", "RIGHT"); + break; + case 'T': + IupSetAttribute(tabs, "TABTYPE", "TOP"); + break; + case 'B': + IupSetAttribute(tabs, "TABTYPE", "BOTTOM"); + break; + } + + IupSetAttribute(tabs, "UPDATE", NULL); + IupRefresh(tabs); /* update children layout */ + } + return IUP_DEFAULT; +} + +static int cbOrientation(Ihandle* ih, int v) +{ + if (v) + { + char* title = IupGetAttribute(ih, "TITLE"); + Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS"); + + switch(*title) + { + case 'H': + IupSetAttribute(tabs, "TABORIENTATION", "HORIZONTAL"); + break; + case 'V': + IupSetAttribute(tabs, "TABORIENTATION", "VERTICAL"); + break; + } + + IupSetAttribute(tabs, "UPDATE", NULL); + IupRefresh(tabs); /* update children layout */ + } + return IUP_DEFAULT; +} + +static int cbAddTab(Ihandle* ih) +{ + Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS"); + Ihandle *vbox; + + vbox = IupFrame(IupVbox(IupLabel("Label XXX"), IupButton("Button XXX", "cbChildButton"), NULL)); + IupSetAttribute(vbox, "TABTITLE", "XXX"); + IupSetAttribute(vbox, "TITLE", "TABS XXX"); + + IupAppend(tabs, vbox); + IupMap(vbox); + + IupSetAttribute(tabs, "UPDATE", NULL); + IupRefresh(tabs); /* update children layout */ + + return IUP_DEFAULT; +} + +static int cbInsertTab(Ihandle* ih) +{ + Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS"); + Ihandle* ref_vbox = IupGetHandle(IupGetAttribute(tabs, "VALUE")); + Ihandle *vbox; + + vbox = IupFrame(IupVbox(IupLabel("Label YYY"), IupButton("Button YYY", "cbChildButton"), NULL)); + IupSetAttribute(vbox, "TABTITLE", "YYY"); + IupSetAttribute(vbox, "TITLE", "TABS YYY"); + + IupInsert(tabs, ref_vbox, vbox); + IupMap(vbox); + + IupSetAttribute(tabs, "UPDATE", NULL); + IupRefresh(tabs); /* update children layout */ + + return IUP_DEFAULT; +} + +static int cbRemoveTab(Ihandle* ih) +{ + Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS"); + Ihandle* vbox = IupGetHandle(IupGetAttribute(tabs, "VALUE")); + + IupDestroy(vbox); + + IupSetAttribute(tabs, "UPDATE", NULL); + IupRefresh(tabs); /* update children layout */ + + return IUP_DEFAULT; +} + +static int cbTabChange(Ihandle* ih, Ihandle* new_tab, Ihandle* old_tab) +{ + printf("new Tab: %s, old Tab: %s\n", IupGetAttribute(new_tab, "TABTITLE"), IupGetAttribute(old_tab, "TABTITLE")); + return IUP_DEFAULT; +} + +static int cbInactive(Ihandle *ih, int state) +{ + Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS"); + IupSetAttribute(tabs, "ACTIVE", state? "NO": "YES"); + IupSetAttribute(tabs, "UPDATE", NULL); + return IUP_DEFAULT; +} + +char *iupKeyCodeToName(int code); + +static int k_any(Ihandle *ih, int c) +{ + if (iup_isprint(c)) + printf("K_ANY(%d = %s \'%c\')\n", c, iupKeyCodeToName(c), (char)c); + else + printf("K_ANY(%d = %s)\n", c, iupKeyCodeToName(c)); + printf(" MODKEYSTATE(%s)\n", IupGetGlobal("MODKEYSTATE")); + return IUP_DEFAULT; +} + +static int getfocus_cb(Ihandle *ih) +{ + printf("GETFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int help_cb(Ihandle* ih) +{ + printf("HELP_CB()\n"); + return IUP_DEFAULT; +} + +static int killfocus_cb(Ihandle *ih) +{ + printf("KILLFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int leavewindow_cb(Ihandle *ih) +{ + printf("LEAVEWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +static int enterwindow_cb(Ihandle *ih) +{ + printf("ENTERWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +//#define IupFrame(_x) (_x) + +static Ihandle* CreateTabs(int tab) +{ + Ihandle *vboxA, *vboxB, *vboxG, + *vboxC, *vboxD,*vboxE, *vboxF, *vboxH, *vboxI, + *tabs; + +// if (tab) // to test Tabs inside Tabs + // vboxA = IupVbox(CreateTabs(0), NULL); +// else + vboxA = IupFrame(IupVbox(IupFill(), IupLabel("Label AAA"), IupButton("Button AAA", "cbChildButton"), //NULL)); + IupText(NULL), IupToggle("Button TTTT", "cbChildButton"), + IupVal(NULL), IupSetAttributes(IupProgressBar(), "VALUE=0.5"), NULL)); + vboxB = IupFrame(IupVbox(IupLabel("Label BBB"), IupButton("Button BBB", "cbChildButton"), NULL)); + vboxC = IupFrame(IupVbox(IupLabel("Label CCC"), IupButton("Button CCC", "cbChildButton"), NULL)); + vboxD = IupFrame(IupVbox(IupLabel("Label DDD"), IupButton("Button DDD", "cbChildButton"), NULL)); + vboxE = IupVbox(IupFill(), IupLabel("Label EEE"), IupButton("Button EEE", "cbChildButton"), + IupButton("Button EEE", "cbChildButton"), IupButton("Button EEE", "cbChildButton"), NULL); + vboxF = IupVbox(IupLabel("Label FFF"), IupButton("Button FFF", "cbChildButton"), NULL); + vboxG = IupVbox(IupLabel("Label GGG"), IupButton("Button GGG", "cbChildButton"), NULL); + vboxH = IupVbox(IupLabel("Label HHH"), IupButton("Button HHH", "cbChildButton"), NULL); + vboxI = IupVbox(IupLabel("Canvas"), IupCanvas(NULL), NULL); + + IupSetAttribute(vboxA, "TABTITLE", "A"); + IupSetAttributeHandle(vboxA, "TABIMAGE", load_image_LogoTecgraf()); + IupSetAttribute(vboxB, "TABTITLE", "BB"); +// IupSetAttribute(vboxC, "TABTITLE", "CCC"); + IupStoreAttribute(vboxC, "TABIMAGE", IupGetAttribute(vboxA, "TABIMAGE")); + IupSetAttribute(vboxD, "TABTITLE", "DDDD"); + IupSetAttribute(vboxE, "TABTITLE", "EEEEE"); + IupSetAttribute(vboxF, "TABTITLE", "FFFFFF"); + IupSetAttribute(vboxG, "TABTITLE", "GGGGGGG"); + IupSetAttribute(vboxH, "TABTITLE", "HHHHHHHH"); + IupSetAttribute(vboxI, "TABTITLE", "Canvas"); + IupSetAttribute(vboxA, "TITLE", "TABS A"); + IupSetAttribute(vboxB, "TITLE", "TABS BB"); + IupSetAttribute(vboxC, "TITLE", "TABS CCC"); + IupSetAttribute(vboxC, "ACTIVE", "NO"); + IupSetAttribute(vboxF, "TABSIZE", "100"); + IupSetAttribute(vboxI, "BGCOLOR", "32 192 32"); + + tabs = IupTabs(vboxA, vboxB, vboxC, vboxD, vboxE, vboxF, vboxG, vboxH, vboxI, NULL); + + IupSetCallback(tabs, "TABCHANGE_CB", (Icallback)cbTabChange); + + //IupSetAttributeHandle(tabs, "TABIMAGE1", load_image_LogoTecgraf()); + IupSetAttributeHandle(tabs, "TABIMAGE1", load_image_TestImage()); + + + // In Windows, must be set before map +// IupSetAttribute(tabs, "TABTYPE", "LEFT"); +// IupSetAttribute(tabs, "TABTYPE", "RIGHT"); +// IupSetAttribute(tabs, "TABTYPE", "BOTTOM"); +// IupSetAttribute(tabs, "TABORIENTATION", "VERTICAL"); +// IupSetAttribute(tabs, "MULTILINE", "YES"); + + IupSetAttribute(tabs, "MARGIN", "0x0"); /* for children */ +// IupSetAttribute(tabs, "EXPAND", "YES"); + IupSetAttribute(tabs, "RASTERSIZE", "300x200"); /* initial size */ +// IupSetAttribute(tabs, "ALIGNMENT", "NW"); +// IupSetAttribute(tabs, "ALIGNMENT", "NORTH"); +// IupSetAttribute(tabs, "ALIGNMENT", "WEST"); +// IupSetAttribute(tabs, "ALIGNMENT", "EAST"); +// IupSetAttribute(tabs, "ALIGNMENT", "SOUTH"); +// IupSetAttribute(tabs, "ALIGNMENT", "SE"); + +// IupSetAttribute(tabs, "BACKGROUND", "10 150 200"); +// IupSetAttribute(tabs, "BGCOLOR", "92 92 255"); +// IupSetAttribute(tabs, "FGCOLOR", "250 0 0"); +// IupSetAttribute(tabs, "FONT", "Helvetica, Italic 16"); + + IupSetAttribute(tabs, "TIP", "IupTabs Tip"); +// IupSetAttribute(tabs, "TIPFONT", "SYSTEM"); +// IupSetAttribute(tabs, "TIPBGCOLOR", "255 128 128"); +// IupSetAttribute(tabs, "TIPFGCOLOR", "0 92 255"); + + // Windows Only + //IupSetAttribute(tabs, "TIPBALLON", "YES"); + //IupSetAttribute(tabs, "TIPBALLONTITLE", "Tip Title"); + //IupSetAttribute(tabs, "TIPBALLONTITLEICON", "2"); + //IupSetAttribute(tabs, "TIPDELAY", "5000"); + + //IupSetCallback(tabs, "K_ANY", (Icallback)k_any); + //IupSetCallback(tabs, "HELP_CB", (Icallback)help_cb); + + //IupSetCallback(tabs, "GETFOCUS_CB", (Icallback)getfocus_cb); + //IupSetCallback(tabs, "KILLFOCUS_CB", (Icallback)killfocus_cb); + //IupSetCallback(tabs, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); + //IupSetCallback(tabs, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); + + return tabs; +} + +void TabsTest(void) +{ + Ihandle *box, *frm1, *frm2, *dlg, *tabs; + + tabs = CreateTabs(1); + + box = IupHbox(tabs, + frm1 = IupFrame(IupRadio(IupVbox(IupToggle("TOP", "cbType"), + IupToggle("LEFT", "cbType"), + IupToggle("BOTTOM", "cbType"), + IupToggle("RIGHT", "cbType"), + NULL))), + frm2 = IupFrame(IupRadio(IupVbox(IupToggle("HORIZONTAL", "cbOrientation"), + IupToggle("VERTICAL", "cbOrientation"), + NULL))), + IupVbox(IupSetAttributes(IupButton("Add Tab", "cbAddTab"), "TIP=\"Button Tip\""), + IupButton("Insert Tab", "cbInsertTab"), + IupButton("Remove Tab", "cbRemoveTab"), + IupToggle("Inactive", "cbInactive"), + IupButton("VALUEPOS=0", "cbValuePos"), + NULL), + NULL); + + IupSetAttribute(frm1, "MARGIN", "5x5"); + IupSetAttribute(frm2, "MARGIN", "5x5"); + IupSetAttribute(frm1, "GAP", "0"); + IupSetAttribute(frm2, "GAP", "0"); + IupSetAttribute(frm1, "TITLE", "Type"); + IupSetAttribute(frm2, "TITLE", "Orientation"); + + IupSetAttribute(box, "MARGIN", "10x10"); + IupSetAttribute(box, "GAP", "10"); + dlg = IupDialog(box); + + IupSetAttribute(dlg, "TITLE", "IupTabs Test"); + IupSetAttribute(dlg, "APP_TABS", (char*)tabs); +// IupSetAttribute(box, "BGCOLOR", "92 92 255"); +// IupSetAttribute(dlg, "BGCOLOR", "92 92 255"); +// IupSetAttribute(dlg, "BACKGROUND", "200 10 80"); +// IupSetAttributeHandle(dlg, "BACKGROUND", load_image_LogoTecgraf()); +// IupSetAttribute(dlg, "FGCOLOR", "10 200 80"); +// IupSetAttribute(dlg, "BGCOLOR", "173 177 194"); // Motif BGCOLOR for documentation +// IupSetAttribute(dlg,"COMPOSITED","NO"); + + IupMap(dlg); + IupSetAttribute(dlg, "SIZE", NULL); + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); + + IupSetFunction("cbOrientation", (Icallback)cbOrientation); + IupSetFunction("cbType", (Icallback)cbType); + IupSetFunction("cbAddTab", (Icallback)cbAddTab); + IupSetFunction("cbInsertTab", (Icallback)cbInsertTab); + IupSetFunction("cbRemoveTab", (Icallback)cbRemoveTab); + IupSetFunction("cbInactive", (Icallback)cbInactive); + IupSetFunction("cbChildButton", (Icallback)cbChildButton); + IupSetFunction("cbValuePos", (Icallback)cbValuePos); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + TabsTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/tecgraf.bmp b/iup/test/tecgraf.bmp Binary files differnew file mode 100755 index 0000000..e6dcbdd --- /dev/null +++ b/iup/test/tecgraf.bmp diff --git a/iup/test/text.c b/iup/test/text.c new file mode 100755 index 0000000..f1c29a2 --- /dev/null +++ b/iup/test/text.c @@ -0,0 +1,433 @@ +#include <stdlib.h> +#include <stdio.h> +#include <iup.h> +#include <iupkey.h> + +static void text2multiline (Ihandle* ih, char* attribute) +{ + Ihandle *mltline = IupGetDialogChild(ih, "mltline"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute (mltline, attribute, IupGetAttribute (text, "VALUE")); +} + +static void multiline2text (Ihandle* ih, char* attribute) +{ + Ihandle *mltline = IupGetDialogChild(ih, "mltline"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetAttribute (text, "VALUE", IupGetAttribute(mltline, attribute)); +} + +static int btn_append_cb (Ihandle* ih) +{ + text2multiline(ih, "APPEND"); + return IUP_DEFAULT; +} + +static int btn_insert_cb (Ihandle* ih) +{ + text2multiline(ih, "INSERT"); + return IUP_DEFAULT; +} + +static int btn_clip_cb (Ihandle* ih) +{ + text2multiline(ih, "CLIPBOARD"); + return IUP_DEFAULT; +} + +int iupKeyNameToCode(const char *name); + +static int btn_key_cb (Ihandle* ih) +{ + Ihandle *mltline = IupGetDialogChild(ih, "mltline"); + Ihandle *text = IupGetDialogChild(ih, "text"); + IupSetFocus(mltline); + IupFlush(); + IupSetfAttribute(NULL, "KEY", "%d", iupKeyNameToCode(IupGetAttribute(text, "VALUE"))); + return IUP_DEFAULT; +} + +static int btn_caret_cb (Ihandle* ih) +{ + Ihandle *opt = IupGetHandle("text2multi"); + if (IupGetInt(opt, "VALUE")) + text2multiline(ih, "CARET"); + else + multiline2text(ih, "CARET"); + return IUP_DEFAULT; +} + +static int btn_readonly_cb (Ihandle* ih) +{ + Ihandle *opt = IupGetHandle("text2multi"); + if (IupGetInt(opt, "VALUE")) + text2multiline(ih, "READONLY"); + else + multiline2text(ih, "READONLY"); + return IUP_DEFAULT; +} + +static int btn_selection_cb (Ihandle* ih) +{ + Ihandle *opt = IupGetHandle ("text2multi"); + if (IupGetInt (opt, "VALUE")) + text2multiline (ih, "SELECTION"); + else + multiline2text (ih, "SELECTION"); + return IUP_DEFAULT; +} + +static int btn_selectedtext_cb (Ihandle* ih) +{ + Ihandle *opt = IupGetHandle ("text2multi"); + if (IupGetInt (opt, "VALUE")) + text2multiline (ih, "SELECTEDTEXT"); + else + multiline2text (ih, "SELECTEDTEXT"); + return IUP_DEFAULT; +} + +static int btn_overwrite_cb (Ihandle* ih) +{ + Ihandle *opt = IupGetHandle ("text2multi"); + if (IupGetInt (opt, "VALUE")) + text2multiline (ih, "OVERWRITE"); + else + multiline2text (ih, "OVERWRITE"); + return IUP_DEFAULT; +} + +static int btn_active_cb(Ihandle *ih) +{ + Ihandle *opt = IupGetHandle ("text2multi"); + if (IupGetInt (opt, "VALUE")) + text2multiline (ih, "ACTIVE"); + else + multiline2text (ih, "ACTIVE"); + return IUP_DEFAULT; +} + +static int btn_remformat_cb(Ihandle *ih) +{ + text2multiline (ih, "REMOVEFORMATTING"); + return IUP_DEFAULT; +} + +static int btn_nc_cb (Ihandle* ih) +{ + Ihandle *opt = IupGetHandle ("text2multi"); + if (IupGetInt (opt, "VALUE")) + text2multiline (ih, "NC"); + else + multiline2text (ih, "NC"); + return IUP_DEFAULT; +} + +static int btn_value_cb (Ihandle* ih) +{ + Ihandle *opt = IupGetHandle ("text2multi"); + if (IupGetInt (opt, "VALUE")) + text2multiline (ih, "VALUE"); + else + multiline2text (ih, "VALUE"); + return IUP_DEFAULT; +} + +static int btn_tabsize_cb (Ihandle* ih) +{ + Ihandle *opt = IupGetHandle ("text2multi"); + if (IupGetInt (opt, "VALUE")) + text2multiline (ih, "TABSIZE"); + else + multiline2text (ih, "TABSIZE"); + return IUP_DEFAULT; +} + +static int k_f2(void) +{ + printf("K_F2\n"); + return IUP_DEFAULT; +} + +static int file_open(void) +{ + char filename[100] = ""; + IupGetFile(filename); // test key after dlg in multiline + printf(filename); + return IUP_DEFAULT; +} + +char *iupKeyCodeToName(int code); + +static int k_any(Ihandle *ih, int c) +{ + if (iup_isprint(c)) + printf("K_ANY(%d = %s \'%c\')\n", c, iupKeyCodeToName(c), (char)c); + else + printf("K_ANY(%d = %s)\n", c, iupKeyCodeToName(c)); + printf(" CARET(%s)\n", IupGetAttribute(ih, "CARET")); + if (c == K_cA) + return IUP_IGNORE; // Sound a beep in Windows + if (c == K_cP) + { + file_open(); + return IUP_IGNORE; // Sound a beep in Windows + } + return IUP_CONTINUE; +} + +static int action(Ihandle *ih, int c, char* after) +{ + if (iup_isprint(c)) + printf("ACTION(%d = %s \'%c\', %s)\n", c, iupKeyCodeToName(c), (char)c, after); + else + printf("ACTION(%d = %s, %s)\n", c, iupKeyCodeToName(c), after); + if (c == K_i) + return IUP_IGNORE; // OK + if (c == K_cD) + return IUP_IGNORE; // Sound a beep in Windows + if (c == K_h) + return K_j; + return IUP_DEFAULT; +} + +static int caret_cb(Ihandle *ih, int lin, int col, int pos) +{ + printf("CARET_CB(%d, %d - %d)\n", lin, col, pos); + printf(" CARET(%s - %s)\n", IupGetAttribute(ih, "CARET"), IupGetAttribute(ih, "CARETPOS")); + return IUP_DEFAULT; +} + +static int getfocus_cb(void) +{ + printf("GETFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int help_cb(void) +{ + printf("HELP_CB()\n"); + return IUP_DEFAULT; +} + +static int killfocus_cb(void) +{ + printf("KILLFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int leavewindow_cb(void) +{ + printf("LEAVEWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +static int enterwindow_cb(void) +{ + printf("ENTERWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +static int btn_def_esc_cb(void) +{ + printf("DEFAULTESC\n"); + return IUP_DEFAULT; +} + +static int btn_def_enter_cb(void) +{ + printf("DEFAULTENTER\n"); + return IUP_DEFAULT; +} + +static int dropfiles_cb(Ihandle *ih, const char* filename, int num, int x, int y) +{ + printf("DROPFILES_CB(%s, %d, x=%d, y=%d)\n", filename, num, x, y); + return IUP_DEFAULT; +} + +static int button_cb(Ihandle *ih,int but,int pressed,int x,int y,char* status) +{ + int lin, col, pos; + printf("BUTTON_CB(but=%c (%d), x=%d, y=%d [%s])\n",(char)but,pressed,x,y, status); + pos = IupConvertXYToPos(ih, x, y); + IupTextConvertPosToLinCol(ih, pos, &lin, &col); + printf(" (lin=%d, col=%d, pos=%d)\n", lin, col, pos); + return IUP_DEFAULT; +} + +static int motion_cb(Ihandle *ih,int x,int y,char* status) +{ + int lin, col, pos; + printf("MOTION_CB(x=%d, y=%d [%s])\n",x,y, status); + pos = IupConvertXYToPos(ih, x, y); + IupTextConvertPosToLinCol(ih, pos, &lin, &col); + printf(" (lin=%d, col=%d, pos=%d)\n", lin, col, pos); + return IUP_DEFAULT; +} + +void TextTest(void) +{ + int formatting = 0; + Ihandle *dlg, *mltline, *text, *opt, *btn_def_enter, *btn_def_esc, *btn_active, *btn_overwrite, + *btn_append, *btn_insert, *btn_caret, *btn_clip, *btn_key, *btn_readonly, *btn_tabsize, + *btn_selection, *btn_selectedtext, *btn_nc, *btn_value, *lbl, *formattag, *btn_remformat; + +// IupSetGlobal("UTF8AUTOCONVERT", "NO"); + + text = IupText (NULL); + IupSetAttribute(text, "EXPAND", "HORIZONTAL"); +// IupSetAttribute(text, "VALUE", "Single Line Text"); + IupSetAttribute(text, "CUEBANNER", "Enter Attribute Value Here"); + IupSetAttribute(text, "NAME", "text"); + IupSetAttribute(text, "TIP", "Attribute Value"); + + opt = IupToggle("Set/Get", NULL); + IupSetAttribute (opt, "VALUE", "ON"); + IupSetHandle ("text2multi", opt); + + mltline = IupMultiLine(NULL); +// mltline = IupText(NULL); +// IupSetAttribute(mltline, "MULTILINE", "YES"); + IupSetAttribute(mltline, "NAME", "mltline"); + + IupSetCallback(mltline, "DROPFILES_CB", (Icallback)dropfiles_cb); + IupSetCallback(mltline, "BUTTON_CB", (Icallback)button_cb); +// IupSetCallback(mltline, "MOTION_CB", (Icallback)motion_cb); + IupSetCallback(mltline, "HELP_CB", (Icallback)help_cb); + IupSetCallback(mltline, "GETFOCUS_CB", (Icallback)getfocus_cb); + IupSetCallback(mltline, "KILLFOCUS_CB", (Icallback)killfocus_cb); + IupSetCallback(mltline, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); + IupSetCallback(mltline, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); + //IupSetCallback(mltline, "ACTION", (Icallback)action); + IupSetCallback(mltline, "K_ANY", (Icallback)k_any); + IupSetCallback(mltline, "K_F2", (Icallback)k_f2); + IupSetCallback(mltline, "CARET_CB", (Icallback)caret_cb); +// IupSetAttribute(mltline, "WORDWRAP", "YES"); +// IupSetAttribute(mltline, "BORDER", "NO"); +// IupSetAttribute(mltline, "AUTOHIDE", "YES"); +// IupSetAttribute(mltline, "BGCOLOR", "255 0 128"); +// IupSetAttribute(mltline, "FGCOLOR", "0 128 192"); +// IupSetAttribute(mltline, "PADDING", "15x15"); +// IupSetAttribute(mltline, "VALUE", "First Line\nSecond Line Big Big Big\nThird Line\nmore\nmore\nçãáÑóé"); // UTF-8 + IupSetAttribute(mltline, "VALUE", "First Line\nSecond Line Big Big Big\nThird Line\nmore\nmore\nηγυασι"); // Windows-1252 + IupSetAttribute(mltline, "TIP", "First Line\nSecond Line\nThird Line"); +// IupSetAttribute(mltline, "FONT", "Helvetica, 14"); +// IupSetAttribute(mltline, "MASK", IUP_MASK_FLOAT); +// IupSetAttribute(mltline, "FILTER", "UPPERCASE"); +// IupSetAttribute(mltline, "ALIGNMENT", "ACENTER"); + + /* Turns on multiline expand and text horizontal expand */ + IupSetAttribute(mltline, "SIZE", "80x40"); + IupSetAttribute(mltline, "EXPAND", "YES"); + + formatting = 0; + if (formatting) /* just to make easier to comment this section */ + { + /* formatting before Map */ + IupSetAttribute(mltline, "FORMATTING", "YES"); + + formattag = IupUser(); + IupSetAttribute(formattag, "ALIGNMENT", "CENTER"); + IupSetAttribute(formattag, "SPACEAFTER", "10"); + IupSetAttribute(formattag, "FONTSIZE", "24"); + IupSetAttribute(formattag, "SELECTION", "3,1:3,50"); + IupSetAttribute(mltline, "ADDFORMATTAG_HANDLE", (char*)formattag); + + formattag = IupUser(); + IupSetAttribute(formattag, "BGCOLOR", "255 128 64"); + IupSetAttribute(formattag, "UNDERLINE", "SINGLE"); + IupSetAttribute(formattag, "WEIGHT", "BOLD"); + IupSetAttribute(formattag, "SELECTION", "3,7:3,11"); + IupSetAttribute(mltline, "ADDFORMATTAG_HANDLE", (char*)formattag); + } + + /* Creates buttons */ +// btn_append = IupButton ("APPEND ηγυασι", NULL); // Windows-1252 +// btn_append = IupButton ("APPEND çãáÑóé", NULL); // UTF-8 + btn_append = IupButton ("&APPEND", NULL); + btn_insert = IupButton ("INSERT", NULL); + btn_caret = IupButton ("CARET", NULL); + btn_readonly = IupButton ("READONLY", NULL); + btn_selection = IupButton ("SELECTION", NULL); + btn_selectedtext = IupButton ("SELECTEDTEXT", NULL); + btn_nc = IupButton ("NC", NULL); + btn_value = IupButton ("VALUE", NULL); + btn_tabsize = IupButton ("TABSIZE", NULL); + btn_clip = IupButton ("CLIPBOARD", NULL); + btn_key = IupButton ("KEY", NULL); + btn_def_enter = IupButton ("Default Enter", NULL); + btn_def_esc = IupButton ("Default Esc", NULL); + btn_active = IupButton("ACTIVE", NULL); + btn_remformat = IupButton("REMOVEFORMATTING", NULL); + btn_overwrite = IupButton("OVERWRITE", NULL); + + IupSetAttribute(btn_append, "TIP", "First Line\nSecond Line\nThird Line"); + + /* Registers callbacks */ + IupSetCallback(btn_append, "ACTION", (Icallback) btn_append_cb); + IupSetCallback(btn_insert, "ACTION", (Icallback) btn_insert_cb); + IupSetCallback(btn_caret, "ACTION", (Icallback) btn_caret_cb); + IupSetCallback(btn_readonly, "ACTION", (Icallback) btn_readonly_cb); + IupSetCallback(btn_selection, "ACTION", (Icallback) btn_selection_cb); + IupSetCallback(btn_selectedtext, "ACTION", (Icallback) btn_selectedtext_cb); + IupSetCallback(btn_nc, "ACTION", (Icallback) btn_nc_cb); + IupSetCallback(btn_value, "ACTION", (Icallback) btn_value_cb); + IupSetCallback(btn_tabsize, "ACTION", (Icallback) btn_tabsize_cb); + IupSetCallback(btn_clip, "ACTION", (Icallback) btn_clip_cb); + IupSetCallback(btn_key, "ACTION", (Icallback) btn_key_cb); + IupSetCallback(btn_def_enter, "ACTION", (Icallback) btn_def_enter_cb); + IupSetCallback(btn_def_esc, "ACTION", (Icallback) btn_def_esc_cb); + IupSetCallback(btn_active, "ACTION", (Icallback) btn_active_cb); + IupSetCallback(btn_remformat, "ACTION", (Icallback) btn_remformat_cb); + IupSetCallback(btn_overwrite, "ACTION", (Icallback) btn_overwrite_cb); + + lbl = IupLabel("&Multiline:"); + IupSetAttribute(lbl, "PADDING", "2x2"); + + /* Creates dlg */ + dlg = IupDialog(IupVbox(lbl, + mltline, + IupHbox (text, opt, NULL), + IupHbox (btn_append, btn_insert, btn_caret, btn_readonly, btn_selection, NULL), + IupHbox (btn_selectedtext, btn_nc, btn_value, btn_tabsize, btn_clip, btn_key, NULL), + IupHbox (btn_def_enter, btn_def_esc, btn_active, btn_remformat, btn_overwrite, NULL), + NULL)); + IupSetCallback(dlg, "K_cO", (Icallback)file_open); + IupSetAttribute(dlg, "TITLE", "IupText Test"); + IupSetAttribute(dlg, "MARGIN", "10x10"); + IupSetAttribute(dlg, "GAP", "5"); + IupSetAttributeHandle(dlg, "DEFAULTENTER", btn_def_enter); + IupSetAttributeHandle(dlg, "DEFAULTESC", btn_def_esc); + IupSetAttribute(dlg, "SHRINK", "YES"); + + if (formatting) /* just to make easier to comment this section */ + { + IupMap(dlg); + /* formatting after Map */ + + formattag = IupUser(); + IupSetAttribute(formattag, "ITALIC", "YES"); + IupSetAttribute(formattag, "STRIKEOUT", "YES"); + IupSetAttribute(formattag, "SELECTION", "2,1:2,12"); + IupSetAttribute(mltline, "ADDFORMATTAG_HANDLE", (char*)formattag); + } + + /* Shows dlg in the center of the screen */ + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + TextTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/text_spin.c b/iup/test/text_spin.c new file mode 100755 index 0000000..114c1ed --- /dev/null +++ b/iup/test/text_spin.c @@ -0,0 +1,74 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "iup.h" +#include "iupkey.h" + + +static int spin_cb(Ihandle* ih, int pos) +{ + (void)ih; + printf("SPIN_CB(%d)\n", pos); + if (!IupGetInt(ih, "SPINAUTO")) + IupSetfAttribute(ih, "VALUE", "%s(%d)", "Test", pos); + return IUP_DEFAULT; +} + +static int action_cb(Ihandle* ih, int c, char* after) +{ + printf("ACTION(%d, %s)\n", c, after); + return IUP_DEFAULT; +} + +static int setspinvalue(Ihandle* ih) +{ + IupSetAttribute(IupGetDialogChild(ih, "spin"), "SPINVALUE", "25"); + return IUP_DEFAULT; +} + +void TextSpinTest(void) +{ + Ihandle *dlg, *text; + + text = IupText(NULL); + IupSetAttribute(text, "SIZE", "60x"); +// IupSetAttribute(text, "EXPAND", "HORIZONTAL"); + + IupSetAttribute(text, "SPIN", "YES"); +// IupSetAttribute(text, "SPINMIN", "10"); +// IupSetAttribute(text, "SPINMAX", "60"); +// IupSetAttribute(text, "SPININC", "5"); +// IupSetAttribute(text, "SPINWRAP", "YES"); +// IupSetAttribute(text, "SPINALIGN", "LEFT"); +// IupSetAttribute(text, "SPINVALUE", "25"); +// IupSetAttribute(text, "SPINAUTO", "NO"); + IupSetAttribute(text, "NAME", "spin"); + + IupSetCallback(text, "SPIN_CB", (Icallback)spin_cb); + IupSetCallback(text, "ACTION", (Icallback)action_cb); + + dlg = IupDialog(IupVbox(text, IupButton("SPINVALUE", "setspinvalue"), NULL)); + IupSetAttribute(dlg, "GAP", "20"); + IupSetAttribute(dlg, "MARGIN", "20x20"); +// IupSetAttribute(dlg, "BGCOLOR", "173 177 194"); // Motif BGCOLOR for documentation + + IupSetFunction("setspinvalue", (Icallback)setspinvalue); + + IupSetAttribute(dlg, "TITLE", "Text Spin Test"); + IupShow(dlg); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + TextSpinTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/timer.c b/iup/test/timer.c new file mode 100755 index 0000000..f570b63 --- /dev/null +++ b/iup/test/timer.c @@ -0,0 +1,70 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" + +static Ihandle *timer1, *timer2, *timer3; + +static int timer_cb(Ihandle *ih) +{ + if (ih == timer1) + printf("timer 1 called\n"); + + if (ih == timer2) + { + printf("timer 2 called and stopped\n"); + IupSetAttribute(ih, "RUN", "NO"); + } + + if (ih == timer3) + { + printf("timer 3 called and CLOSE returned.\n"); + IupDestroy(timer1); + IupDestroy(timer2); + IupDestroy(timer3); + return IUP_CLOSE; + } + + return IUP_DEFAULT; +} + +void TimerTest(void) +{ + Ihandle *dlg; + + dlg = IupDialog(NULL); + IupSetAttribute(dlg, "TITLE", "IupTimer Test"); + IupSetAttribute(dlg, "SIZE", "200x100"); + + IupShow(dlg); + + timer1 = IupTimer(); + timer2 = IupTimer(); + timer3 = IupTimer(); + + IupSetAttribute(timer1, "TIME", "100"); + IupSetAttribute(timer1, "RUN", "YES"); + IupSetCallback(timer1, "ACTION_CB", (Icallback)timer_cb); + + IupSetAttribute(timer2, "TIME", "400"); + IupSetAttribute(timer2, "RUN", "YES"); + IupSetCallback(timer2, "ACTION_CB", (Icallback)timer_cb); + + IupSetAttribute(timer3, "TIME", "5000"); + IupSetAttribute(timer3, "RUN", "YES"); + IupSetCallback(timer3, "ACTION_CB", (Icallback)timer_cb); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + TimerTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/toggle.c b/iup/test/toggle.c new file mode 100755 index 0000000..e504eb1 --- /dev/null +++ b/iup/test/toggle.c @@ -0,0 +1,306 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" + +#define TEST_IMAGE_SIZE 20 + +static unsigned char image_data_32[16*16*4] = { + 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, + 255, 0, 255, 0, 183, 182, 245, 255, 183, 182, 245, 255, 179, 178, 243, 255, 174, 173, 241, 255, 168, 167, 238, 255, 162, 161, 234, 255, 155, 154, 231, 255, 148, 147, 228, 255, 143, 142, 224, 255, 136, 135, 221, 255, 129, 128, 218, 255, 123, 122, 214, 255, 117, 116, 211, 255, 112, 111, 209, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 179, 178, 243, 255, 190, 189, 255, 255, 147, 146, 248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 75, 88, 190, 255, 89, 88, 176, 255, 89, 88, 176, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 173, 172, 240, 255, 190, 189, 255, 255, 138, 137, 239, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 234, 238, 246, 255, 63, 82, 184, 255, 51, 51, 103, 255, 86, 85, 170, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 167, 166, 237, 255, 190, 189, 255, 255, 129, 128, 230, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 234, 238, 246, 255, 222, 229, 240, 255, 52, 77, 179, 255, 122, 121, 223, 255, 83, 82, 164, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 159, 158, 233, 255, 190, 189, 255, 255, 119, 118, 220, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 234, 238, 246, 255, 222, 229, 240, 255, 210, 219, 234, 255, 40, 71, 173, 255, 114, 113, 215, 255, 80, 79, 159, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 152, 151, 229, 255, 190, 189, 255, 255, 110, 109, 211, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 234, 238, 246, 255, 222, 229, 240, 255, 210, 219, 234, 255, 198, 209, 229, 255, 28, 65, 167, 255, 103, 103, 204, 255, 77, 77, 154, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 146, 145, 226, 255, 190, 189, 255, 255, 103, 102, 204, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 248, 251, 255, 234, 238, 246, 255, 222, 229, 240, 255, 210, 219, 234, 255, 198, 209, 229, 255, 189, 202, 225, 255, 17, 59, 161, 255, 92, 93, 194, 255, 74, 74, 148, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 139, 138, 223, 255, 188, 187, 255, 255, 183, 182, 255, 255, 96, 99, 201, 255, 86, 94, 196, 255, 75, 88, 190, 255, 63, 82, 184, 255, 52, 77, 179, 255, 40, 71, 173, 255, 28, 65, 167, 255, 17, 59, 161, 255, 92, 93, 193, 255, 84, 86, 186, 255, 71, 71, 143, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 132, 131, 219, 255, 180, 179, 255, 255, 174, 173, 255, 255, 164, 163, 252, 255, 143, 142, 244, 255, 135, 134, 236, 255, 129, 128, 230, 255, 122, 121, 223, 255, 114, 113, 215, 255, 108, 107, 209, 255, 92, 93, 193, 255, 84, 86, 186, 255, 76, 80, 178, 255, 68, 68, 137, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 124, 123, 215, 255, 170, 169, 255, 255, 160, 159, 251, 255, 148, 147, 245, 255, 75, 91, 113, 255, 75, 91, 113, 255, 75, 91, 113, 255, 75, 91, 113, 255, 82, 98, 118, 255, 91, 106, 125, 255, 84, 86, 186, 255, 76, 79, 178, 255, 68, 73, 170, 255, 65, 65, 131, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 118, 117, 212, 255, 160, 159, 255, 255, 145, 144, 245, 255, 135, 134, 236, 255, 75, 91, 113, 255, 0, 0, 0, 255, 52, 60, 71, 255, 206, 217, 233, 255, 212, 221, 236, 255, 103, 116, 133, 255, 67, 75, 174, 255, 68, 73, 170, 255, 60, 66, 163, 255, 62, 62, 125, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 112, 111, 209, 255, 154, 153, 255, 255, 135, 134, 236, 255, 129, 128, 230, 255, 75, 91, 113, 255, 52, 60, 71, 255, 104, 120, 141, 255, 216, 224, 237, 255, 224, 231, 241, 255, 115, 127, 143, 255, 53, 65, 163, 255, 60, 66, 162, 255, 53, 61, 156, 255, 60, 59, 120, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 108, 107, 207, 255, 143, 142, 243, 255, 129, 128, 230, 255, 36, 68, 170, 255, 33, 50, 71, 255, 171, 180, 195, 255, 179, 187, 198, 255, 188, 193, 202, 255, 196, 200, 206, 255, 72, 77, 86, 255, 51, 62, 158, 255, 54, 61, 156, 255, 49, 57, 152, 255, 57, 57, 114, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 108, 107, 207, 84, 101, 100, 195, 255, 86, 85, 170, 255, 83, 82, 164, 255, 80, 79, 159, 255, 77, 77, 154, 255, 74, 74, 148, 255, 71, 71, 143, 255, 68, 68, 137, 255, 65, 65, 131, 255, 60, 59, 120, 255, 60, 59, 120, 255, 57, 57, 114, 255, 55, 54, 110, 255, 255, 0, 255, 0, + 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0}; + +static unsigned char image_data_8 [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE] = +{ + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,3,3,4,4,4,4,4,4,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +}; + +static unsigned char image_data_8_pressed [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE] = +{ + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,5,1,1,1,1,1,2,2,2,2,2,5,0,0,0,5, + 5,0,0,0,1,5,1,1,1,1,2,2,2,2,5,2,0,0,0,5, + 5,0,0,0,1,1,5,1,1,1,2,2,2,5,2,2,0,0,0,5, + 5,0,0,0,1,1,1,5,1,1,2,2,5,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,5,1,2,5,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,1,5,5,2,2,2,2,2,0,0,0,5, + 5,0,0,0,3,3,3,3,3,5,5,4,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,5,3,4,5,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,5,3,3,4,4,5,4,4,4,0,0,0,5, + 5,0,0,0,3,3,5,3,3,3,4,4,4,5,4,4,0,0,0,5, + 5,0,0,0,3,5,3,3,3,3,4,4,4,4,5,4,0,0,0,5, + 5,0,0,0,5,3,3,3,3,3,4,4,4,4,4,5,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +}; + +static unsigned char image_data_8_inactive [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE] = +{ + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,5,5,1,1,1,1,1,1,1,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,5,5,5,1,5,5,5,5,5,5,0,0,0,5, + 5,0,0,0,5,5,1,1,1,1,1,1,1,5,5,5,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, +}; + +static void createimgs(void) +{ + Ihandle *image; + + image = IupImageRGBA(16, 16, image_data_32); + IupSetHandle ("image2", image); + + image = IupImage(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_8); + IupSetAttribute(image, "0", "BGCOLOR"); + IupSetAttribute(image, "1", "255 0 0"); + IupSetAttribute(image, "2", "0 255 0"); + IupSetAttribute(image, "3", "0 0 255"); + IupSetAttribute(image, "4", "255 255 255"); + IupSetAttribute(image, "5", "0 0 0"); + IupSetHandle ("image1", image); + + image = IupImage(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_8_inactive); + IupSetAttribute(image, "0", "BGCOLOR"); + IupSetAttribute(image, "1", "255 0 0"); + IupSetAttribute(image, "2", "0 255 0"); + IupSetAttribute(image, "3", "0 0 255"); + IupSetAttribute(image, "4", "255 255 255"); + IupSetAttribute(image, "5", "0 0 0"); + IupSetHandle ("image1i", image); + + image = IupImage(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_8_pressed); + IupSetAttribute(image, "0", "BGCOLOR"); + IupSetAttribute(image, "1", "255 0 0"); + IupSetAttribute(image, "2", "0 255 0"); + IupSetAttribute(image, "3", "0 0 255"); + IupSetAttribute(image, "4", "255 255 255"); + IupSetAttribute(image, "5", "0 0 0"); + IupSetHandle ("image1p", image); +} + +static int togglecb(Ihandle *self, int v) +{ + if (v == 1) printf("Toggle %s - ON\n", IupGetAttribute(self, "NAME")); + else printf("Toggle %s - OFF\n", IupGetAttribute(self, "NAME")); + return IUP_DEFAULT; +} + +static int toggle9cb(Ihandle *self, int v) +{ + Ihandle* ih = IupGetHandle("radio test"); + if (v == 1) printf("Toggle 9 - ON\n"); + else if (v == -1) printf("Toggle 9 - NOTDEF\n"); + else printf("Toggle 9 - OFF\n"); + + if (v == 1) + IupSetAttribute(ih, "VALUE", "ON"); + else + IupSetAttribute(ih, "VALUE", "OFF"); + + return IUP_DEFAULT; +} + +static int toggle7cb(Ihandle *ih, int v) +{ + Ihandle* dlg = IupGetDialog(ih); + Ihandle* box = IupGetChild(dlg, 0); + if (v) + IupSetAttribute(box, "ACTIVE", "NO"); + else + IupSetAttribute(box, "ACTIVE", "YES"); + IupSetAttribute(ih, "ACTIVE", "YES"); + return IUP_DEFAULT; +} + +static int k_any(Ihandle *ih, int c) +{ + printf("K_ANY(%d)\n", c); + return IUP_DEFAULT; +} + +static int getfocus_cb(Ihandle *ih) +{ + printf("GETFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int help_cb(Ihandle* ih) +{ + printf("HELP_CB()\n"); + return IUP_DEFAULT; +} + +static int killfocus_cb(Ihandle *ih) +{ + printf("KILLFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int leavewindow_cb(Ihandle *ih) +{ + printf("LEAVEWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +static int enterwindow_cb(Ihandle *ih) +{ + printf("ENTERWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +void ToggleTest(void) +{ + Ihandle *dlg, *box; + Ihandle *toggle1, *toggle2, *toggle3, *toggle4, *toggle5, *toggle6, *toggle7, *toggle8, *toggle9; + + createimgs(); + + toggle1 = IupToggle(NULL, NULL); + toggle2 = IupToggle(NULL, NULL); + toggle3 = IupToggle("Text Toggle", NULL); +// toggle4 = IupToggle("blue foreground color", NULL); + toggle4 = IupToggle("Radio &Text", NULL); + toggle5 = IupToggle("red background color", NULL); + toggle6 = IupToggle("multiple lines\nsecond line", NULL); + toggle7 = IupToggle("INACTIVE", NULL); + toggle8 = IupToggle("Courier 14 Bold font", NULL); + toggle9 = IupToggle("3 State", NULL); + + IupSetHandle("radio test", toggle8); + + IupSetCallback(toggle1, "ACTION", (Icallback)togglecb); + IupSetCallback(toggle2, "ACTION", (Icallback)togglecb); + IupSetCallback(toggle3, "ACTION", (Icallback)togglecb); + IupSetCallback(toggle4, "ACTION", (Icallback)togglecb); + IupSetCallback(toggle5, "ACTION", (Icallback)togglecb); + IupSetCallback(toggle6, "ACTION", (Icallback)togglecb); + IupSetCallback(toggle8, "ACTION", (Icallback)togglecb); + IupSetCallback(toggle7, "ACTION", (Icallback)toggle7cb); + IupSetCallback(toggle9, "ACTION", (Icallback)toggle9cb); + + IupSetCallback(toggle3, "K_ANY", (Icallback)k_any); + IupSetCallback(toggle3, "HELP_CB", (Icallback)help_cb); + IupSetCallback(toggle3, "GETFOCUS_CB", (Icallback)getfocus_cb); + IupSetCallback(toggle3, "KILLFOCUS_CB", (Icallback)killfocus_cb); + IupSetCallback(toggle3, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); + IupSetCallback(toggle3, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); + + IupSetAttribute(toggle1, "IMAGE", "image1"); + IupSetAttribute(toggle1, "IMPRESS", "image1p"); + IupSetAttribute(toggle1, "IMINACTIVE", "image1i"); +// IupSetAttribute(toggle1, "PADDING", "10x10"); +// IupSetAttribute(toggle1, "RASTERSIZE", "160x160"); +// IupSetAttribute(toggle2, "RASTERSIZE", "60x60"); +// IupSetAttribute(toggle1, "ALIGNMENT", "ARIGHT"); +// IupSetAttribute(toggle2, "ALIGNMENT", "ARIGHT"); + IupSetAttribute(toggle2, "IMAGE", "image2"); + IupSetAttribute(toggle1, "NAME", "1"); + IupSetAttribute(toggle2, "NAME", "2"); + IupSetAttribute(toggle3, "NAME", "3"); + IupSetAttribute(toggle4, "NAME", "4"); + IupSetAttribute(toggle5, "NAME", "5"); + IupSetAttribute(toggle6, "NAME", "6"); + IupSetAttribute(toggle8, "NAME", "8"); +// IupSetAttribute(toggle4, "FGCOLOR", "0 0 255"); + IupSetAttribute(toggle5, "BGCOLOR", "255 0 0"); + IupSetAttribute(toggle8, "FONT", "COURIER_BOLD_14"); + IupSetAttribute(toggle9, "3STATE", "YES"); + IupSetAttribute(toggle6, "TIP", "Toggle Tip"); + IupSetAttribute(toggle7, "RIGHTBUTTON", "YES"); + IupSetAttribute(toggle5, "RIGHTBUTTON", "YES"); + + /* Creating box that contains the toggles */ + box = IupHbox( + IupVbox( + toggle1, + toggle2, + toggle3, + toggle7, + toggle9, + NULL), + IupFrame(IupRadio(IupVbox( + toggle4, + toggle5, + toggle6, + toggle8, + NULL))), + NULL); + + IupSetAttribute(IupGetChild(box, 1), "TITLE", "Radio in a Frame"); + +// IupSetAttribute(box, "BGCOLOR", "255 0 0"); + + /* Dialog */ + dlg = IupDialog(box); + IupSetAttribute (dlg, "TITLE", "IupToggle Test"); + IupSetAttributes(dlg, "MARGIN=5x5, GAP=5"); + + /* Associates a menu to the dlg */ + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + ToggleTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/tray.c b/iup/test/tray.c new file mode 100755 index 0000000..58b7daf --- /dev/null +++ b/iup/test/tray.c @@ -0,0 +1,120 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" + +static unsigned char pixmap [ ] = +{ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,1,2,3,3,3,3,3,3,3,2,1,0,0,0, + 0,0,2,1,2,3,3,3,3,3,2,1,2,0,0,0, + 0,0,3,2,1,2,3,3,3,2,1,2,3,0,0,0, + 0,0,3,3,2,1,2,3,2,1,2,3,3,0,0,0, + 0,0,3,3,3,2,1,2,1,2,3,3,3,0,0,0, + 0,0,3,3,3,3,2,1,2,3,3,3,3,0,0,0, + 0,0,3,3,3,2,1,2,1,2,3,3,3,0,0,0, + 0,0,3,3,2,1,2,3,2,1,2,3,3,0,0,0, + 0,0,3,2,1,2,3,3,3,2,1,2,3,0,0,0, + 0,0,2,1,2,3,3,3,3,3,2,1,2,0,0,0, + 0,0,1,2,3,3,3,3,3,3,3,2,1,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +static int close(Ihandle* ih) +{ + IupDestroy((Ihandle*)IupGetAttribute(ih, "_DIALOG")); + return IUP_DEFAULT; +// return IUP_CLOSE; +} + +static int hide(Ihandle* ih) +{ + IupSetAttribute((Ihandle*)IupGetAttribute(ih, "_DIALOG"), "HIDETASKBAR", "YES"); + return IUP_DEFAULT; +} + +static int show(Ihandle* ih) +{ + IupSetAttribute((Ihandle*)IupGetAttribute(ih, "_DIALOG"), "HIDETASKBAR", "NO"); + return IUP_DEFAULT; +} + +static int showmenu(Ihandle* ih) +{ + Ihandle* menu = IupMenu(IupItem("Show", "show"), IupItem("Hide", "hide"), IupItem("Exit", "close"), NULL); + IupSetAttribute(menu, "_DIALOG", (char*)ih); + IupSetFunction("show", (Icallback) show); + IupSetFunction("hide", (Icallback) hide); + IupSetFunction("close", (Icallback) close); + IupPopup(menu, IUP_MOUSEPOS, IUP_MOUSEPOS); + IupDestroy(menu); + return IUP_DEFAULT; +} + +static int k_esc(Ihandle* ih) +{ + IupDestroy(ih); + return IUP_DEFAULT; +} + +static int close_cb(Ihandle* ih) +{ + IupSetAttribute(ih, "HIDETASKBAR", "YES"); + return IUP_IGNORE; +} + +static int trayclick(Ihandle *ih, int button, int pressed, int dclick) +{ +printf("trayclick_cb(button=%d, pressed=%d, dclick=%d)\n", button, pressed, dclick); + if (button == 1 && pressed) + IupSetAttribute(ih, "HIDETASKBAR", "NO"); + else if (button == 3 && pressed) + showmenu(ih); + return IUP_DEFAULT; +} + +void TrayTest(void) +{ + Ihandle *dlg, *img; + + img = IupImage(16, 16, pixmap); + IupSetAttribute(img, "0", "BGCOLOR"); + IupSetAttribute(img, "1", "255 255 0"); + IupSetAttribute(img, "2", "255 0 0"); + IupSetAttribute(img, "3", "255 255 0"); + IupSetHandle ("img", img); + + dlg = IupDialog(NULL); + + IupSetAttribute(dlg, "TITLE", "Tray Test"); + IupSetAttribute(dlg, "TRAY", "YES"); + IupSetAttribute(dlg, "TRAYTIP", "Tip at Tray"); + IupSetAttribute(dlg, "TRAYIMAGE", "img"); + IupSetAttribute(dlg, "SIZE", "100x100"); + IupSetCallback(dlg, "TRAYCLICK_CB", (Icallback)trayclick); + IupSetCallback(dlg, "CLOSE_CB", (Icallback)close_cb); + IupSetCallback(dlg, "K_ESC", (Icallback)k_esc); + + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); + + /* start only the task bar icon */ + IupSetAttribute(dlg, "HIDETASKBAR", "YES"); +} + + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + TrayTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/tree.c b/iup/test/tree.c new file mode 100755 index 0000000..009c97f --- /dev/null +++ b/iup/test/tree.c @@ -0,0 +1,518 @@ +/*IupTree Example in C +Creates a tree with some branches and leaves. +Two callbacks are registered: one deletes marked nodes when the Del key is pressed, +and the other, called when the right mouse button is pressed, opens a menu with options. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "iup.h" +#include "iupkey.h" + + +static Ihandle* load_image_LogoTecgraf(void) +{ + unsigned char imgdata[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 120, 143, 125, 132, 148, 178, 173, 133, 149, 178, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 110, 130, 48, 130, 147, 177, 254, 124, 139, 167, 254, 131, 147, 176, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, 128, 153, 134, 142, 159, 191, 194, 47, 52, 61, 110, 114, 128, 154, 222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 143, 172, 192, 140, 156, 188, 99, 65, 69, 76, 16, 97, 109, 131, 251, 129, 144, 172, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 147, 175, 232, 140, 157, 188, 43, 0, 0, 0, 0, 100, 112, 134, 211, 126, 141, 169, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 78, 88, 26, 48, 52, 57, 60, 135, 150, 178, 254, 108, 121, 145, 83, 105, 118, 142, 76, 106, 119, 143, 201, 118, 133, 159, 122, 117, 129, 152, 25, 168, 176, 190, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 118, 128, 145, 3, 104, 117, 140, 92, 114, 127, 152, 180, 131, 147, 177, 237, 133, 149, 178, 249, 38, 42, 50, 222, 137, 152, 180, 249, 126, 142, 170, 182, 114, 128, 154, 182, 104, 117, 140, 227, 95, 107, 128, 238, 83, 93, 112, 248, 84, 95, 113, 239, 104, 117, 141, 180, 115, 129, 155, 93, 127, 140, 165, 4, + 98, 109, 130, 153, 109, 123, 147, 254, 145, 163, 195, 153, 138, 154, 182, 56, 115, 123, 138, 5, 92, 99, 109, 35, 134, 149, 177, 230, 0, 0, 0, 0, 0, 0, 0, 0, 120, 133, 159, 143, 135, 151, 181, 115, 86, 89, 93, 5, 41, 45, 51, 54, 40, 45, 53, 150, 107, 120, 144, 254, 122, 137, 164, 154, + 51, 57, 66, 147, 83, 93, 112, 255, 108, 121, 145, 159, 113, 126, 151, 62, 123, 136, 159, 8, 87, 93, 103, 35, 125, 141, 169, 230, 0, 0, 0, 0, 0, 0, 0, 0, 129, 143, 169, 143, 140, 156, 184, 115, 134, 147, 172, 8, 124, 138, 165, 60, 124, 139, 167, 155, 131, 147, 177, 255, 131, 147, 176, 153, + 64, 68, 73, 2, 36, 39, 45, 86, 41, 46, 54, 173, 60, 67, 80, 232, 75, 84, 101, 251, 89, 100, 120, 228, 105, 118, 142, 250, 110, 123, 148, 187, 118, 132, 158, 187, 126, 141, 169, 229, 134, 149, 177, 239, 136, 152, 179, 250, 136, 152, 181, 234, 139, 156, 186, 175, 130, 145, 173, 90, 124, 134, 151, 3, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, 74, 79, 19, 60, 64, 73, 50, 92, 103, 124, 254, 86, 95, 111, 84, 90, 100, 117, 76, 126, 141, 168, 201, 113, 126, 150, 119, 99, 105, 117, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 105, 125, 231, 135, 151, 181, 46, 0, 0, 0, 0, 137, 154, 184, 212, 123, 137, 164, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, 83, 98, 191, 133, 149, 179, 102, 111, 121, 139, 17, 134, 150, 180, 252, 126, 140, 166, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 48, 57, 132, 121, 136, 164, 197, 121, 135, 161, 115, 130, 146, 175, 221, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 47, 52, 46, 87, 98, 118, 254, 126, 142, 170, 254, 124, 139, 166, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 57, 67, 118, 115, 128, 152, 170, 127, 140, 164, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + Ihandle* image = IupImageRGBA(16, 16, imgdata); + return image; +} + +#define TEST_IMAGE_SIZE 16 + +static Ihandle* load_image_TestImage(void) +{ + unsigned char image_data_8 [TEST_IMAGE_SIZE*TEST_IMAGE_SIZE] = + { + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,1,1,1,1,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,2,2,2,2,0,0,0,5, + 5,0,0,0,1,1,1,1,2,2,2,2,0,0,0,5, + 5,0,0,0,3,3,3,3,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,4,4,4,4,0,0,0,5, + 5,0,0,0,3,3,3,3,4,4,4,4,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + }; + + Ihandle* image = IupImage(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_8); + IupSetAttribute(image, "0", "BGCOLOR"); + IupSetAttribute(image, "1", "255 0 0"); + IupSetAttribute(image, "2", "0 255 0"); + IupSetAttribute(image, "3", "0 0 255"); + IupSetAttribute(image, "4", "255 255 255"); + IupSetAttribute(image, "5", "0 0 0"); + + return image; +} + +static int addleaf(void) +{ + char attr[50]; + Ihandle* tree = IupGetHandle("tree"); + int id = IupGetInt(tree, "VALUE"); + sprintf(attr, "ADDLEAF%d", id); + IupSetAttribute(tree, attr, ""); + return IUP_DEFAULT; +} + +static int insertleaf(void) +{ + char attr[50]; + Ihandle* tree = IupGetHandle("tree"); + int id = IupGetInt(tree, "VALUE"); + sprintf(attr, "INSERTLEAF%d", id); + IupSetAttribute(tree, attr, ""); + return IUP_DEFAULT; +} + +static int addbranch(void) +{ + char attr[50]; + Ihandle* tree = IupGetHandle("tree"); + int id = IupGetInt(tree, "VALUE"); + sprintf(attr, "ADDBRANCH%d", id); + IupSetAttribute(tree, attr, ""); + return IUP_DEFAULT; +} + +static int insertbranch(void) +{ + char attr[50]; + Ihandle* tree = IupGetHandle("tree"); + int id = IupGetInt(tree, "VALUE"); + sprintf(attr, "INSERTBRANCH%d", id); + IupSetAttribute(tree, attr, ""); + return IUP_DEFAULT; +} + +static int text_cb(Ihandle* ih, int c, char *after) +{ + if (c == K_ESC) + return IUP_CLOSE; + + if (c == K_CR) + { + Ihandle *tree = IupGetHandle("tree"); + IupSetAttribute(tree, "NAME", after); + return IUP_CLOSE; + } + + return IUP_DEFAULT; +} + +static int removenode(void) +{ + Ihandle* tree = IupGetHandle("tree"); + IupSetAttribute(tree, "DELNODE", "SELECTED"); + return IUP_DEFAULT; +} + +static int removechild(void) +{ + Ihandle* tree = IupGetHandle("tree"); + IupSetAttribute(tree, "DELNODE", "CHILDREN"); + return IUP_DEFAULT; +} + +int renamenode(void) +{ + Ihandle* tree = IupGetHandle("tree"); + IupSetAttribute(tree, "RENAME", "YES"); + return IUP_DEFAULT; +} + +static int button_cb(Ihandle *ih,int but,int pressed,int x,int y,char* status) +{ + printf("BUTTON_CB(but=%c (%d), x=%d, y=%d [%s]) - [id=%d]\n",(char)but,pressed,x,y, status, IupConvertXYToPos(ih, x, y)); + return IUP_DEFAULT; +} + +static int motion_cb(Ihandle *ih,int x,int y,char* status) +{ + printf("MOTION_CB(x=%d, y=%d [%s]) - [id=%d]\n",x,y, status,IupConvertXYToPos(ih, x, y)); + return IUP_DEFAULT; +} + +static int showrename_cb(Ihandle* ih, int id) +{ + (void)ih; + printf("SHOWRENAME_CB(%d)\n", id); + return IUP_DEFAULT; +} + +static int selection_cb(Ihandle *ih, int id, int status) +{ + (void)ih; + printf("SELECTION_CB(%d, %d)\n", id, status); + return IUP_DEFAULT; +} + +static int multiselection_cb(Ihandle *ih, int* ids, int n) +{ + int i; + (void)ih; + printf("MULTISELECTION_CB("); + for (i = 0; i < n; i++) + printf("%d, ", ids[i]); + printf("n=%d)\n", n); + return IUP_DEFAULT; +} + +static int executeleaf_cb(Ihandle* ih, int id) +{ + printf("EXECUTELEAF_CB (%d)\n", id); + return IUP_DEFAULT; +} + +static int renamenode_cb(Ihandle* ih, int id, char* title) +{ + printf("RENAMENODE_CB (%d=%s)\n", id, title); + return IUP_DEFAULT; +} + +static int rename_cb(Ihandle* ih, int id, char* title) +{ + printf("RENAME_CB (%d=%s)\n", id, title); + if (strcmp(title, "fool") == 0) + return IUP_IGNORE; + return IUP_DEFAULT; +} + +static int branchopen_cb(Ihandle* ih, int id) +{ + printf("BRANCHOPEN_CB (%d)\n", id); +// if (id == 6) +// return IUP_IGNORE; + return IUP_DEFAULT; +} + +static int branchclose_cb(Ihandle* ih, int id) +{ + printf("BRANCHCLOSE_CB (%d)\n", id); +// if (id == 6) +// return IUP_IGNORE; + return IUP_DEFAULT; +} + +static int dragdrop_cb(Ihandle* ih, int drag_id, int drop_id, int shift, int control) +{ + printf("DRAGDROP_CB (%d)->(%d)\n", drag_id, drop_id); + return IUP_CONTINUE; +// return IUP_DEFAULT; +} + +static int getfocus_cb(Ihandle* ih) +{ + printf("GETFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int killfocus_cb(Ihandle* ih) +{ + printf("KILLFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int leavewindow_cb(Ihandle *ih) +{ + printf("LEAVEWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +static int enterwindow_cb(Ihandle* ih) +{ + printf("ENTERWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +static int k_any_cb(Ihandle* ih, int c) +{ + if (c == K_DEL) + IupSetAttribute(ih, "DELNODE", "MARKED"); + if (iup_isprint(c)) + printf("K_ANY(%s, %d = %s \'%c\')\n", IupGetAttribute(IupGetParent(IupGetParent(ih)), "TITLE"), c, iupKeyCodeToName(c), (char)c); + else + printf("K_ANY(%s, %d = %s)\n", IupGetAttribute(IupGetParent(IupGetParent(ih)), "TITLE"), c, iupKeyCodeToName(c)); + return IUP_CONTINUE; +} + +static int help_cb(Ihandle* ih) +{ + printf("HELP_CB()\n"); + return IUP_DEFAULT; +} + +static int selectnode(Ihandle* ih) +{ + Ihandle* tree = IupGetHandle("tree"); + IupSetAttribute(tree, "VALUE", IupGetAttribute(ih, "TITLE")); + return IUP_DEFAULT; +} + +static int nodeinfo(Ihandle* ih) +{ + char attr[50], *kind; + Ihandle* tree = IupGetHandle("tree"); + int branch = 0, id = IupGetInt(tree, "VALUE"); + printf("\nTree Info:\n"); + printf(" TOTALCOUNT=%s\n", IupGetAttribute(tree, "COUNT")); + printf("Node Info:\n"); + printf(" ID=%d\n", id); + printf(" TITLE=%s\n", IupGetAttribute(tree, "TITLE")); + printf(" DEPTH=%s\n", IupGetAttribute(tree, "DEPTH")); + sprintf(attr, "KIND%d", id); + kind = IupGetAttribute(tree, "KIND"); + printf(" KIND=%s\n", kind); + if (strcmp(kind, "BRANCH")==0) branch = 1; + if (branch) + printf(" STATE=%s\n", IupGetAttribute(tree, "STATE")); + printf(" IMAGE=%s\n", IupGetAttribute(tree, "IMAGE")); + if (branch) + printf(" IMAGEBRANCHEXPANDED=%s\n", IupGetAttribute(tree, "IMAGEBRANCHEXPANDED")); + printf(" MARKED=%s\n", IupGetAttribute(tree, "MARKED")); + printf(" COLOR=%s\n", IupGetAttribute(tree, "COLOR")); + printf(" PARENT=%s\n", IupGetAttribute(tree, "PARENT")); + printf(" COUNT=%s\n", IupGetAttribute(tree, "CHILDCOUNT")); + printf(" USERDATA=%p\n", IupGetAttribute(tree, "USERDATA")); + return IUP_DEFAULT; +} + +static int rightclick_cb(Ihandle* ih, int id) +{ + Ihandle *popup_menu; + char attr[50]; + + popup_menu = IupMenu( + IupItem ("Node Info","nodeinfo"), + IupItem ("Rename Node","renamenode"), + IupSeparator(), + IupItem ("Add Leaf","addleaf"), + IupItem ("Add Branch","addbranch"), + IupItem ("Insert Leaf","insertleaf"), + IupItem ("Insert Branch","insertbranch"), + IupItem ("Remove Node","removenode"), + IupItem ("Remove Children","removechild"), + IupSubmenu("Focus", IupMenu( + IupItem ("ROOT", "selectnode"), + IupItem ("LAST", "selectnode"), + IupItem ("PGUP", "selectnode"), + IupItem ("PGDN", "selectnode"), + IupItem ("NEXT", "selectnode"), + IupItem ("PREVIOUS", "selectnode"), + NULL)), + IupSubmenu("Mark", IupMenu( + IupItem ("INVERT", "selectnode"), + IupItem ("BLOCK", "selectnode"), + IupItem ("CLEARALL", "selectnode"), + IupItem ("MARKALL", "selectnode"), + IupItem ("INVERTALL", "selectnode"), + NULL)), + NULL); + + IupSetFunction("nodeinfo", (Icallback) nodeinfo); + IupSetFunction("selectnode", (Icallback) selectnode); + IupSetFunction("addleaf", (Icallback) addleaf); + IupSetFunction("addbranch", (Icallback) addbranch); + IupSetFunction("insertleaf", (Icallback) insertleaf); + IupSetFunction("insertbranch", (Icallback) insertbranch); + IupSetFunction("removenode", (Icallback) removenode); + IupSetFunction("removechild", (Icallback) removechild); + IupSetFunction("renamenode", (Icallback) renamenode); + +// sprintf(attr, "%d", id); +// IupSetAttribute(ih, "VALUE", attr); + IupPopup(popup_menu, IUP_MOUSEPOS, IUP_MOUSEPOS); + + IupDestroy(popup_menu); + + return IUP_DEFAULT; +} + +static int active(Ihandle *ih) +{ + Ihandle* tree = IupGetHandle("tree"); + if (IupGetInt(tree, "ACTIVE")) + IupSetAttribute(tree, "ACTIVE", "NO"); + else + IupSetAttribute(tree, "ACTIVE", "YES"); + return IUP_DEFAULT; +} + +static int next(Ihandle *ih) +{ + Ihandle* tree = IupGetHandle("tree"); + IupSetAttribute(tree, "VALUE", "NEXT"); + //IupSetAttribute(tree, "TOPITEM", "8"); + return IUP_DEFAULT; +} + +static int prev(Ihandle *ih) +{ + Ihandle* tree = IupGetHandle("tree"); + IupSetAttribute(tree, "VALUE", "PREVIOUS"); + return IUP_DEFAULT; +} + +/* Initializes IupTree and registers callbacks */ +static void init_tree(void) +{ + Ihandle* tree = IupTree(); + + IupSetCallback(tree, "EXECUTELEAF_CB", (Icallback) executeleaf_cb); + IupSetCallback(tree, "RENAMENODE_CB", (Icallback) renamenode_cb); + IupSetCallback(tree, "RENAME_CB", (Icallback) rename_cb); + IupSetCallback(tree, "BRANCHCLOSE_CB", (Icallback) branchclose_cb); + IupSetCallback(tree, "BRANCHOPEN_CB", (Icallback) branchopen_cb); + IupSetCallback(tree, "DRAGDROP_CB", (Icallback) dragdrop_cb); + IupSetCallback(tree, "RIGHTCLICK_CB", (Icallback) rightclick_cb); + IupSetCallback(tree, "K_ANY", (Icallback) k_any_cb); + IupSetCallback(tree, "SHOWRENAME_CB", (Icallback) showrename_cb); + IupSetCallback(tree, "SELECTION_CB", (Icallback) selection_cb); + IupSetCallback(tree, "MULTISELECTION_CB", (Icallback) multiselection_cb); + IupSetCallback(tree, "GETFOCUS_CB", (Icallback) getfocus_cb); + IupSetCallback(tree, "KILLFOCUS_CB", (Icallback) killfocus_cb); + //IupSetCallback(tree, "ENTERWINDOW_CB", (Icallback) enterwindow_cb); + //IupSetCallback(tree, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); + //IupSetCallback(tree, "BUTTON_CB", (Icallback)button_cb); + //IupSetCallback(tree, "MOTION_CB", (Icallback)motion_cb); + + IupSetCallback(tree, "HELP_CB", (Icallback)help_cb); + +// IupSetAttribute(tree, "FONT", "COURIER_NORMAL_14"); +// IupSetAttribute(tree, "FGCOLOR", "255 0 0"); +// IupSetAttribute(tree, "SPACING", "10"); +// IupSetAttribute(tree, "BGCOLOR", "255 255 255"); + + IupSetAttribute(tree, "MARKMODE", "MULTIPLE"); + //IupSetAttribute(tree, "SHOWDRAGDROP", "YES"); + IupSetAttribute(tree, "SHOWRENAME", "YES"); + //IupSetAttribute(tree, "AUTODRAGDROP", "YES"); /* Gtk Only */ + + //IupSetAttribute(tree, "ADDEXPANDED", "NO"); +// IupSetAttribute(tree, "HIDELINES", "YES"); +// IupSetAttribute(tree, "HIDEBUTTONS", "YES"); +// IupSetAttribute(tree, "INDENTATION", "40"); + + IupSetHandle("tree", tree); +} + +/* Initializes the dlg */ +static void init_dlg(void) +{ + Ihandle* butactv, *butnext, *butprev, *butmenu; + Ihandle* tree = IupGetHandle("tree"); + Ihandle* box = IupHbox(tree, IupVbox(butactv = IupButton("Active", NULL), + butnext = IupButton("Next", NULL), + butprev = IupButton("Prev", NULL), + butmenu = IupButton("Menu", NULL), + NULL), NULL); + Ihandle* dlg = IupDialog(box) ; + IupSetAttribute(dlg, "TITLE", "IupTree"); + IupSetAttribute(box, "MARGIN", "10x10"); + IupSetAttribute(box, "GAP", "10"); +// IupSetAttribute(box, "BGCOLOR", "92 92 255"); +// IupSetAttribute(dlg, "BGCOLOR", "92 92 255"); +// IupSetAttribute(dlg, "BACKGROUND", "200 10 80"); +// IupSetAttribute(dlg, "BGCOLOR", "173 177 194"); // Motif BGCOLOR for documentation + IupSetCallback(butactv, "ACTION", active); + IupSetCallback(butnext, "ACTION", next); + IupSetCallback(butprev, "ACTION", prev); + IupSetCallback(butmenu, "ACTION", (Icallback)rightclick_cb); + + IupSetHandle("dlg", dlg); +} + +static void init_tree_nodes(void) +{ + Ihandle* tree = IupGetHandle("tree"); + +#if 0 + /* create from bottom to top */ + /* the current node is the ROOT */ + //IupSetAttribute(tree, "VALUE", "0"); + IupSetAttribute(tree, "TITLE", "Figures"); /* title of the root, id=0 */ + IupSetAttribute(tree, "ADDBRANCH", "3D"); /* 3D=1 */ + IupSetAttribute(tree, "ADDBRANCH", "2D"); /* add to the root, so it will be before "3D", now 2D=1, 3D=2 */ + IupSetAttribute(tree, "ADDBRANCH", "parallelogram"); /* id=1 */ + IupSetAttribute(tree, "ADDLEAF1", "diamond"); + IupSetAttribute(tree, "ADDLEAF1", "square"); + IupSetAttribute(tree, "ADDBRANCH", "triangle"); + IupSetAttribute(tree, "ADDLEAF1", "scalenus"); + IupSetAttribute(tree, "ADDLEAF1", "isoceles"); + IupSetAttribute(tree, "ADDLEAF1", "equilateral"); + IupSetAttribute(tree, "ADDLEAF", "Other (ηγι)"); +#else + /* create from top to bottom */ + IupSetAttribute(tree, "TITLE0", "Figures"); + IupSetAttribute(tree, "ADDLEAF0", "Other"); /* new id=1 */ + IupSetAttribute(tree, "ADDBRANCH1", "triangle"); /* new id=2 */ + IupSetAttribute(tree, "ADDLEAF2", "equilateral"); /* ... */ + IupSetAttribute(tree, "ADDLEAF3", "isoceles"); + IupSetAttribute(tree, "ADDLEAF4", "scalenus"); + IupSetAttribute(tree, "INSERTBRANCH2","parallelogram"); /* same depth as id=2, new id=6 */ + IupSetAttribute(tree, "ADDLEAF6", "square"); + IupSetAttribute(tree, "ADDLEAF7", "diamond"); + IupSetAttribute(tree, "INSERTBRANCH6","2D"); /* new id=9 */ + IupSetAttribute(tree, "INSERTBRANCH9","3D"); +#endif + + IupSetAttribute(tree, "VALUE", "6"); + IupSetAttribute(tree, "RASTERSIZE", NULL); /* remove the minimum size limitation */ + IupSetAttribute(tree, "COLOR8", "92 92 255"); + IupSetAttribute(tree, "TITLEFONT8", "Courier, 14"); + IupSetAttributeHandle(tree, "IMAGE8", load_image_LogoTecgraf()); + IupSetAttributeHandle(tree, "IMAGE7", load_image_TestImage()); + IupSetAttribute(tree, "IMAGE6", IupGetAttribute(tree, "IMAGE8")); +} + +void TreeTest(void) +{ + Ihandle* dlg; + + init_tree(); /* Initializes IupTree */ + init_dlg(); /* Initializes the dlg */ + dlg = IupGetHandle("dlg"); /* Retrieves the dlg handle */ + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); /* Displays the dlg */ + init_tree_nodes(); /* Initializes attributes, can be done here or anywhere */ +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupControlsOpen(); + + TreeTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/val.c b/iup/test/val.c new file mode 100755 index 0000000..2f0b500 --- /dev/null +++ b/iup/test/val.c @@ -0,0 +1,199 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "iup.h" +#include "iupkey.h" + + +static Ihandle *lbl_h=NULL, *lbl_v=NULL; + +static void print_value(Ihandle *ih, double a) +{ + char *type = IupGetAttribute(ih, "TYPE"); + + switch(type[0]) + { + case 'V': + IupSetfAttribute(lbl_v, "TITLE", "VALUE=%.2f", a); + break; + case 'H': + IupSetfAttribute(lbl_h, "TITLE", "VALUE=%.2f", a); + break; + } +} + +static int mousemove(Ihandle *ih, double a) +{ + printf("mousemove %.2f\n", a); + print_value(ih, a); + return IUP_DEFAULT; +} + +static int button_press(Ihandle *ih, double a) +{ + char *type = IupGetAttribute(ih, "TYPE"); + + printf("button_press %.2f\n", a); + + switch(type[0]) + { + case 'V': + IupSetAttribute(lbl_v, "FGCOLOR", "255 0 0"); + break; + + case 'H': + IupSetAttribute(lbl_h, "FGCOLOR", "255 0 0"); + break; + } + + print_value(ih, a); + + return IUP_DEFAULT; +} + +static int button_release(Ihandle *ih, double a) +{ + char *type = IupGetAttribute(ih, "TYPE"); + + printf("button_release %.2f\n", a); + + switch(type[0]) + { + case 'V': + IupSetAttribute(lbl_v, "FGCOLOR", "0 0 0"); + break; + + case 'H': + IupSetAttribute(lbl_h, "FGCOLOR", "0 0 0"); + break; + } + + print_value(ih, a); + + return IUP_DEFAULT; +} + +char *iupKeyCodeToName(int code); + +static int k_any(Ihandle *ih, int c) +{ + if (iup_isprint(c)) + printf("K_ANY(%d = %s \'%c\')\n", c, iupKeyCodeToName(c), (char)c); + else + printf("K_ANY(%d = %s)\n", c, iupKeyCodeToName(c)); + return IUP_CONTINUE; +} + +static int getfocus_cb(Ihandle *ih) +{ + printf("GETFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int help_cb(Ihandle* ih) +{ + printf("HELP_CB()\n"); + return IUP_DEFAULT; +} + +static int killfocus_cb(Ihandle *ih) +{ + printf("KILLFOCUS_CB()\n"); + return IUP_DEFAULT; +} + +static int leavewindow_cb(Ihandle *ih) +{ + printf("LEAVEWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +static int enterwindow_cb(Ihandle *ih) +{ + printf("ENTERWINDOW_CB()\n"); + return IUP_DEFAULT; +} + +void ValTest(void) +{ + Ihandle *dlg, *val_h, *val_v; + +// IupOldValOpen(); + + lbl_v = IupLabel("VALUE="); + IupSetAttribute(lbl_v, "SIZE", "70x"); + + lbl_h = IupLabel("VALUE="); + IupSetAttribute(lbl_h, "SIZE", "70x"); + + val_v = IupVal("VERTICAL"); + IupSetAttribute(val_v, "MAX", "10.0"); + IupSetAttribute(val_v, "STEP", ".02"); + IupSetAttribute(val_v, "PAGESTEP", ".2"); + IupSetAttribute(val_v, "SHOWTICKS", "5"); +// IupSetAttribute(val_v, "TICKSPOS", "REVERSE"); + IupSetCallback(val_v, "HELP_CB", (Icallback)help_cb); + IupSetCallback(val_v, "GETFOCUS_CB", (Icallback)getfocus_cb); + IupSetCallback(val_v, "KILLFOCUS_CB", (Icallback)killfocus_cb); + IupSetCallback(val_v, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); + IupSetCallback(val_v, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); + IupSetCallback(val_v, "K_ANY", (Icallback)k_any); +// IupSetAttribute(val_v, "INVERTED", "NO"); + IupSetAttribute(val_v, "EXPAND", "VERTICAL"); + + val_h = IupVal("HORIZONTAL"); + IupSetAttribute(val_h, "MAX", "100.0"); + IupSetAttribute(val_h, "SHOWTICKS", "10"); + IupSetAttribute(val_h, "TICKSPOS", "BOTH"); /* Windows Only */ +// IupSetAttribute(val_h, "INVERTED", "YES"); + IupSetAttribute(val_h, "EXPAND", "HORIZONTAL"); + + dlg = IupDialog + ( + IupHbox + ( + IupSetAttributes(IupHbox + ( + val_v, + lbl_v, + NULL + ), "ALIGNMENT=ACENTER"), + IupSetAttributes(IupVbox + ( + val_h, + lbl_h, + NULL + ), "ALIGNMENT=ACENTER"), + NULL + ) + ); + + IupSetCallback(val_v, "BUTTON_PRESS_CB", (Icallback) button_press); + IupSetCallback(val_v, "BUTTON_RELEASE_CB", (Icallback) button_release); + IupSetCallback(val_v, "MOUSEMOVE_CB", (Icallback) mousemove); + + IupSetCallback(val_h, "BUTTON_PRESS_CB", (Icallback) button_press); + IupSetCallback(val_h, "BUTTON_RELEASE_CB", (Icallback) button_release); + IupSetCallback(val_h, "MOUSEMOVE_CB", (Icallback) mousemove); + + IupSetAttribute(dlg, "TITLE", "IupVal Test"); +// IupSetAttribute(IupGetChild(dlg, 0), "BGCOLOR", "50 50 255"); +// IupSetAttribute(IupGetChild(dlg, 0), "ACTIVE", "NO"); + IupSetAttribute(dlg, "MARGIN", "10x10"); + IupShowXY(dlg,IUP_CENTER,IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + ValTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/vbox.c b/iup/test/vbox.c new file mode 100755 index 0000000..3040ea6 --- /dev/null +++ b/iup/test/vbox.c @@ -0,0 +1,122 @@ +#include <stdlib.h> +#include <stdio.h> +#include <iup.h> + +void VboxTest(void) +{ + /* IUP identifiers */ + Ihandle *dlg; + Ihandle *fr1, *fr2, *fr3; + Ihandle *btn_11, *btn_12, *btn_13; + Ihandle *btn_21, *btn_22, *btn_23; + Ihandle *btn_31, *btn_32, *btn_33; + Ihandle *vbox_1, *vbox_2, *vbox_3; + + /* Creates frame 1 */ + fr1 = IupFrame + ( + vbox_1 = IupVbox + ( + IupFill(), + btn_11=IupButton("1", NULL), + btn_12=IupButton("2", NULL), + btn_13=IupButton("3", NULL), + IupFill(), + NULL + ) + ); + + IupSetAttribute(fr1, "TITLE", "ALIGNMENT=ALEFT"); + IupSetAttribute(btn_11, "SIZE", "20x10"); + IupSetAttribute(btn_12, "SIZE", "30x20"); + IupSetAttribute(btn_13, "SIZE", "40x30"); + IupSetAttribute(vbox_1, "ALIGNMENT", "ALEFT"); +// IupSetAttribute(vbox_1, "MARGIN", "20x20"); +// IupSetAttribute(vbox_1, "GAP", "10"); + IupSetAttribute(vbox_1, "HOMOGENEOUS", "YES"); + IupSetAttribute(vbox_1, "EXPANDCHILDREN", "YES"); +// IupSetAttribute(btn_12, "VISIBLE", "NO"); +// IupSetAttribute(btn_12, "FLOATING", "YES"); + + /* Creates frame 2 */ + fr2 = IupFrame + ( + vbox_2 = IupVbox + ( + IupFill(), + btn_21 = IupButton ("1", NULL), + btn_22 = IupButton ("2", NULL), + btn_23 = IupButton ("3", NULL), + IupFill(), + NULL + ) + ); + + IupSetAttribute(fr2, "TITLE", "ALIGNMENT=ACENTER"); + IupSetAttribute(btn_21, "SIZE", "20x30"); + IupSetAttribute(btn_22, "SIZE", "30x30"); + IupSetAttribute(btn_23, "SIZE", "40x30"); + IupSetAttribute(vbox_2, "ALIGNMENT", "ACENTER"); + + /* Creates frame 3 */ + fr3 = IupFrame + ( + vbox_3 = IupVbox + ( + IupFill (), + btn_31=IupButton ("1", NULL), + btn_32=IupButton ("2", NULL), + btn_33=IupButton ("3", NULL), + IupFill (), + NULL + ) + ); + + IupSetAttribute(fr3, "TITLE", "ALIGNMENT=ARIGHT"); + IupSetAttribute(btn_31, "SIZE", "20x30"); + IupSetAttribute(btn_32, "SIZE", "30x30"); + IupSetAttribute(btn_33, "SIZE", "40x30"); + IupSetAttribute(vbox_3, "ALIGNMENT", "ARIGHT"); + + dlg = IupDialog + ( + IupHbox + ( + fr1, + IupFill (), + fr2, + IupFill (), + fr3, + IupFill (), + NULL + ) + ); + + IupSetAttribute(dlg, "TITLE", "IupVbox Test"); /* Sets dlg's title */ + IupSetAttribute(dlg, "MARGIN", "10x10"); + IupSetAttribute(dlg, "GAP", "10"); + IupSetAttribute(fr1, "MARGIN", "0x0"); /* avoid attribute propagation */ + IupSetAttribute(fr2, "MARGIN", "0x0"); + IupSetAttribute(fr3, "MARGIN", "0x0"); + IupSetAttribute(fr1, "GAP", "0"); + IupSetAttribute(fr2, "GAP", "0"); + IupSetAttribute(fr3, "GAP", "0"); + + /* Shows dlg in the center of the screen */ + IupShowXY(dlg, IUP_CENTER, IUP_CENTER); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + VboxTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif diff --git a/iup/test/zbox.c b/iup/test/zbox.c new file mode 100755 index 0000000..0451277 --- /dev/null +++ b/iup/test/zbox.c @@ -0,0 +1,98 @@ +#include <stdlib.h> +#include <stdio.h> +#include "iup.h" + +static int list_cb (Ihandle *h, char *t, int o, int selected) +{ + if (selected == 1) + { + Ihandle* zbox = IupGetHandle ("zbox"); + IupSetAttribute (zbox, "VALUE", t); + } + + return IUP_DEFAULT; +} + +void ZboxTest(void) +{ + Ihandle *dlg; + Ihandle *frm; + Ihandle *zbox; + Ihandle *text; + Ihandle *list; + Ihandle *lbl; + Ihandle *btn; + Ihandle *frame; + + frame = IupFrame(IupSetAttributes(IupList(NULL), "DROPDOWN=YES, 1=Test, 2=XXX, VALUE=1")); + IupSetAttribute (frame, "TITLE", "List"); + + text = IupText(""); + + IupSetAttributes (text, "EXPAND = YES, VALUE = \"Enter your text here\""); + + /* Creates a label */ + lbl = IupLabel("This element is a label"); + + /* Creatas a button */ + btn = IupButton ("This button does nothing", ""); + + /* Creates handles for manipulating the zbox VALUE */ + IupSetHandle ("frame", frame); + IupSetHandle ("text", text); + IupSetHandle ("lbl", lbl); + IupSetHandle ("btn", btn); + + /* Creates zbox with four elements */ + zbox = IupZbox (frame, text, lbl, btn, NULL); + + /* Associates handle "zbox" with zbox */ + IupSetHandle ("zbox", zbox); + + /* Sets zbox alignment */ + IupSetAttribute (zbox, "ALIGNMENT", "ACENTER"); + IupSetAttribute (zbox, "VALUE", "text"); + + /* Creates frame */ + frm = IupFrame + ( + IupHbox + ( + list = IupList(NULL), + NULL + ) + ), + + /* Creates dialog */ + dlg = IupDialog + ( + IupVbox + ( + frm, + zbox, + NULL + ) + ); + + IupSetAttributes (list, "1 = frame, 2 = text, 3 = lbl, 4 = btn, VALUE=2"); + IupSetAttribute (frm, "TITLE", "Select an element"); + IupSetAttributes (dlg, "MARGIN=10x10, GAP=10, TITLE = \"IupZbox Example\""); + IupSetCallback (list, "ACTION", (Icallback) list_cb); + + IupShowXY (dlg, IUP_CENTER, IUP_CENTER ); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + + ZboxTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif |