#ifdef NOMINGW static const char * buildString = "ECERE SDK v0.43 (Without MinGW) -- built on September 3, 2008 "; #else static const char * buildString = "ECERE SDK v0.43 -- built on September 3, 2008 "; #endif #define WIN32_LEAN_AND_MEAN #define GetFreeSpace _GetFreeSpace #include #undef GetFreeSpace #ifdef ECERE_STATIC import static "ecere" #else import "ecere" #endif import "Settings" import "createLink" import "licenseBox" class CheckListBox : ListBox { fullRowSelect = false, collapseControl = true, treeBranches = true, rootCollapseButton = true, noDragging = true; rowHeight = 18; void ToggleCheck(DataRow row) { Button checkBox = (Button)row.tag; DataRow parent; bool checked = !(checkBox.checked) || checkBox.buttonState == down; if(!checkBox.disabled) { SetCheck(row, checked); checkBox.buttonState = up; for(parent = row; parent; parent = parent.parent) { for(row = parent.firstRow; row; row = row.next) { checkBox = (Button)row.tag; if(checkBox.checked != checked) break; } checkBox = (Button)parent.tag; if(row) { checkBox.checked = true; NotifyChecked(master, this, parent); checkBox.buttonState = down; checked = true; } else { checkBox.checked = checked; NotifyChecked(master, this, parent); checkBox.buttonState = up; } } } } void SetCheck(DataRow row, bool checked) { Button checkBox = (Button)row.tag; DataRow subRow; if(!checkBox.disabled && (checkBox.checked != checked || checkBox.buttonState == down)) { checkBox.checked = checked; for(subRow = row.firstRow; subRow; subRow = subRow.next) SetCheck(subRow, checked); NotifyChecked(master, this, row); } } DataRow AddRow(DataRow parentRow) { DataRow row = parentRow ? parentRow.AddRow() : ListBox::AddRow(); int c; DataRow parent; int indent = 20; for(parent = row.parent; parent; parent = parent.parent) indent += 20; row.tag = (int)Button { this, isCheckbox = true, inactive = true, checked = true, position = { 2 + indent, 1+(row.index + hasHeader) * rowHeight }, size = { 12, 12 }; id = (int)row; bool NotifyPushed(Button button, int x, int y, Modifiers mods) { currentRow = (DataRow)button.id; ToggleCheck(currentRow); return false; } bool NotifyReleased(Button button, int x, int y, Modifiers mods) { return false; } bool OnMouseOver(int x, int y, Modifiers mods) { return true; } bool OnMouseLeave(Modifiers mods) { return true; } }; return row; } bool NotifyKeyDown(CheckListBox listBox, DataRow row, Key key, unichar ch) { if(key == space) { listBox.ToggleCheck(row); return false; } return true; } bool OnKeyHit(Key key, unichar ch) { if(key == space) return false; return ListBox::OnKeyHit(key, ch); } bool NotifyDoubleClick(CheckListBox listBox, int x, int y, Modifiers mods) { listBox.OnLeftButtonDown(x, y, mods); return false; } bool NotifyReclick(CheckListBox listBox, DataRow row, Modifiers mods) { listBox.ToggleCheck(row); return true; } bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed) { DataRow r; for(r = row.firstRow; r && r != row; ) { Button checkBox = (Button)r.tag; checkBox.visible = !collapsed; if(r.firstRow && !r.collapsed) row = r.firstRow; else for(; r != row; r = r.parent) if(r.next) { r = r.next; break; } } for(r = row.GetNextRow(); r; r = r.GetNextRow()) { Button checkBox = (Button)r.tag; checkBox.position.y = 1 + (r.index + listBox.hasHeader) * listBox.rowHeight; } return true; } virtual void Window::NotifyChecked(CheckListBox listBox, DataRow row); }; struct CheckItem { char * name; void * data; char * OnGetString(char * tempString, void * fieldData, bool * needClass) { return name; } void OnDisplay(Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags displayFlags) { if(!displayFlags.active) displayFlags.current = false; class::OnDisplay(surface, x + 22, y, width - 22, fieldData, alignment, displayFlags); } }; //#define BUFFERSIZE 0x10000 #define BUFFERSIZE 0x1000 bool abortInstall = false; void ExtractFileFromArchive(ProgressBar progressBar, char * path, char * outputFile) { char fileName[MAX_LOCATION]; FileAttribs exists = FileExists(path); bool setTime = false; FileStats stats; if(exists.isDirectory) { FileListing listing { path }; if(outputFile[0]) { if(MakeDir(outputFile)) { setTime = true; FileGetStats(path, &stats); } } while(listing.Find() && !abortInstall) { strcpy(fileName, outputFile); // Tweak file name if out if(outputFile[0]) { if(!strcmp(fileName, ".")) fileName[0] = '\0'; if(listing.name[0] == '/' || listing.name[0] == '\\') { char * afterSlash, rest[MAX_LOCATION]; for(afterSlash = fileName; *afterSlash == '/' || *afterSlash == '\\'; afterSlash++); strcpy(rest, afterSlash); PathCat(fileName, "_root"); PathCat(fileName, rest); } else if(listing.name[1] == ':') { char letter[10]; sprintf(letter, "_%cdrive", toupper(listing.name[0])); PathCat(fileName, letter); PathCat(fileName, listing.name[2] ? (listing.name + 3) : (listing.name + 2)); } else PathCat(fileName, listing.name); } else PathCat(fileName, listing.name); if(!strcmp(fileName, "/") || !strcmp(fileName, "\\")) strcpy(fileName, DIR_SEPS); ExtractFileFromArchive(progressBar, listing.path, fileName); } listing.Stop(); } else if(exists) { File input = FileOpen(path, read); if(input) { File output = FileOpen(outputFile, write); if(output) { char fileName[MAX_FILENAME]; uint position = progressBar.progress; FileSize dataSize; int c; byte buffer[BUFFERSIZE]; FileGetSize(path, &dataSize); GetLastDirectory(outputFile, fileName); ((GuiApplication)__thisModule).SignalEvent(); //((GuiApplication)__thisModule).ProcessInput(); //((GuiApplication)__thisModule).UpdateDisplay(); for(c = 0; c c + BUFFERSIZE) ? BUFFERSIZE : (dataSize - c); ((GuiApplication)__thisModule).Unlock(); input.Read(buffer, 1, size); output.Write(buffer, 1, size); ((GuiApplication)__thisModule).Lock(); progressBar.progress = position + c + size; ((GuiApplication)__thisModule).SignalEvent(); //((GuiApplication)__thisModule).ProcessInput(); //((GuiApplication)__thisModule).UpdateDisplay(); } delete output; setTime = true; FileGetStats(path, &stats); } delete input; } } if(setTime) FileSetTime(outputFile, stats.created, 0, stats.modified); } struct Component { char * name; char * dataPath; char * defInstallPath; Component * subComponents; bool mandatory; bool selected; Component * parent; uint requiredSize; uint size; char installPath[MAX_LOCATION]; DataRow row; void GetFullPath(char * path) { if(this != null && parent) parent->GetFullPath(path); else strcpy(path, installDir); if(this != null) PathCat(path, installPath); } void Install(char * parentPath) { int c; if(selected) { char path[MAX_LOCATION]; strcpy(path, parentPath); PathCat(path, installPath); installProgress.installing.SetText("Installing %s...", name); ((GuiApplication)__thisModule).UpdateDisplay(); if(dataPath) { char source[MAX_LOCATION]; strcpy(source, ":"); strcat(source, dataPath); MakeDir(path); if(FileExists(source).isFile) { char name[MAX_FILENAME]; GetLastDirectory(source, name); PathCat(path, name); } ExtractFileFromArchive(installProgress.progressBar, source, path); } if(subComponents) { for(c = 0; subComponents[c].name; c++) subComponents[c].Install(path); } } } }; Component samples[] = { { "Hello World", "samples/HelloWorld", "HelloWorld", null, false, true }, { "Hello Form", "samples/HelloForm", "HelloForm", null, false, true }, { "Test3D", "samples/Test3D", "Test3D", null, false, true }, { "Blank", "samples/Blank", "Blank", null, false, true }, { "Start", "samples/Start", "Start", null, false, true }, { "Animate3DS", "samples/Animate3DS", "Animate3DS", null, false, true }, { "Balls", "samples/Balls", "Balls", null, false, true }, { "Chess", "samples/Chess", "Chess", null, false, true }, { "Clock", "samples/Clock", "Clock", null, false, true }, { "Othello", "samples/Othello", "Othello", null, false, true }, { "eCom", "samples/eCom", "eCom", null, false, true }, { "ModelViewer", "samples/ModelViewer", "ModelViewer", null, false, true }, { "HTTPServer", "samples/HTTPServer", "HTTPServer", null, false, true }, { "Fractals", "samples/Fractals", "Fractals", null, false, true }, { "ColorSpheres", "samples/ColorSpheres", "ColorSpheres", null, false, true }, { "HiraganaCube", "samples/HiraganaCube", "HiraganaCube", null, false, true }, { "MedDB", "samples/MedDB", "MedDB", null, false, true }, { "EDATest", "samples/EDATest", "EDATest", null, false, true }, { "DCOMSample", "samples/DCOMSample", "DCOMSample", null, false, true }, { "ContainersTest", "samples/ContainersTest", "ContainersTest", null, false, true }, /* { "Find", "samples/Find", "Find", null, false, true }, { "Notepad", "samples/Notepad", "Notepad", null, false, true }, { "Bomb", "samples/Bomb", "Bomb", null, false, true }, { "TongIts", "samples/TongIts", "TongIts", null, false, true }, { "War2", "samples/War2", "War2", null, false, true }, { "Poker", "samples/Poker", "Poker", null, false, true }, { "Ruff", "samples/Ruff", "Ruff", null, false, true }, { "Scrabble", "samples/Scrabble", "Scrabble", null, false, true }, { "ICQ", "samples/ICQ", "ICQ", null, false, true }, { "Browser", "samples/Browser", "Browser", null, false, true }, { "Replace", "samples/Replace", "Replace", null, false, true }, { "FliPlay", "samples/FliPlay", "FliPlay", null, false, true }, { "SlideShow", "samples/SlideShow", "SlideShow", null, false, true }, */ { null } }; public enum CoreSDKID { ide, runtime, eda, ec, #ifndef NOMINGW gcc, gdb, mingw, binutils, make, upx, #endif none }; Component coreSDK[CoreSDKID] = { { "ECERE IDE", "ecere_bin/ide", "bin", null, true, true }, { "Runtime Library", "ecere_bin/ecere.dll", "bin", null, true, true }, { "Data Access", "ecere_bin/EDA.dll", "bin", null, true, true }, { "eC Compiler", "ecere_bin/compiler", "bin", null, true, true }, #ifndef NOMINGW { "GNU C Compiler", "mingw/gcc", "mingw", null, true, true }, { "GNU Debugger", "mingw/gdb", "mingw", null, true, true }, { "MinGW Runtime", "mingw/MinGW", "mingw", null, true, true }, { "Binary Utils", "mingw/binutils", "mingw", null, true, true }, { "GNU Make", "mingw/make", "mingw", null, true, true }, { "UPX", "upx/upx.exe", "mingw/bin", null, true, true }, #endif { null } }; #ifndef NOMINGW Component additional[] = { { "C++ Compiler", "mingw/g++", "mingw", null, false, true }, { "Win32 APIs", "mingw/win32", "mingw", null, false, true }, { "GCC I18n", "mingw/i18n", "mingw", null, false, true }, { null } }; #endif public enum DocumentationID { #ifndef NOMINGW gccDoc, gppDocs, gdbDocs, makeDocs, binDocs, mingwDocs, upxDocs, #endif ecereBook, none }; Component documentation[DocumentationID] = { #ifndef NOMINGW { "GCC Docs", "mingw/doc/gcc", "mingw", null, false, true }, { "G++ Docs", "mingw/doc/g++", "mingw", null, false, true }, { "GDB Docs", "mingw/doc/gdb", "mingw", null, false, true }, { "Make Docs", "mingw/doc/make", "mingw", null, false, true }, { "Binutils Docs", "mingw/doc/binutils", "mingw", null, false, true }, { "MinGW Docs", "mingw/doc/mingw", "mingw", null, false, true }, { "UPX Docs", "upx/doc", "mingw/doc/upx", null, false, true }, #endif { "Ecere Book", "ecere_bin/book", "doc", null, false, true }, { null } }; public enum ComponentID { coreSDK, #ifndef NOMINGW additional, #endif documentation, samples, none }; Component components[ComponentID] = { { "Core SDK Files", null, null, coreSDK, true, true }, #ifndef NOMINGW { "Additional Support", null, null, additional, false, true }, #endif { "Documentation", null /*"doc"*/, null /*"doc"*/, documentation, false, true }, { "Samples", null, "samples", samples, false, true }, { null } }; FileSize totalSize; FileSize totalInstalled; struct InstallOption { char * name; InstallOption * subOptions; bool selected; DataRow row; }; enum AssociateOptions { AssociateEPJ, AssociateEC, AssociateC, AssociateCPP, AssociateTXT, Associate3DS, AssociateIMG }; InstallOption associateOptions[] = { { "Associate with ECERE Project Files (*.epj)", null, true }, { "Associate with eC Files (*.ec, *.eh)", null, true }, { "Associate with C files (*.c, *.h)", null, false }, { "Associate with C++ Files (*.cpp, *.hpp, *.cc, *.hh, *.cxx, *.hxx)", null, false }, { "Associate with text files (*.txt)", null, false }, { "Associate with 3D Studio Model Files (*.3ds)", null, true }, { "Associate with Image Files (*.png, *.jpg, *.pcx, *.bmp, *.gif)", null, false }, { null } }; enum PathOptions { AddECEREPaths #ifndef NOMINGW , AddMinGWPaths #endif }; InstallOption pathOptions[] = { { "Add ECERE binaries location to the system path", null, true }, { "Add MinGW to the system path", null, true } { null } }; enum IconOptions { StartMenuIcon, DesktopIcon, QuickLaunchIcon }; InstallOption options[] = { { "Start Menu Group", null, true }, { "Desktop Icon", null, true }, { "Quicklaunch Icon", null, true }, { "Associate the ECERE IDE with Supported File Types", associateOptions, true }, #ifndef NOMINGW { "Add binaries location to the system paths", pathOptions, true }, #endif { null } }; char sourceDir[MAX_LOCATION] = ":"; char installDir[MAX_LOCATION]; class Installer : Window { text = "ECERE Software Development Kit Setup"; background = activeBorder; borderStyle = fixed; hasMinimize = true; hasClose = true; tabCycle = true; size = { 640, 480 }; FileDialog fileDialog { master = this, type = selectDir, text = "Select a new location" }; Button browse { master = this, autoCreate = false, inactive = true, /*hotKey = F2,*/ text = "..."; bool NotifyClicked(Button button, int x, int y, Modifiers mods) { DataRow row = componentsBox.currentRow; Component * component = ((CheckItem *)row.GetData(componentField))->data; component->GetFullPath(fileDialog.filePath); StripLastDirectory(fileDialog.filePath, fileDialog.currentDirectory); if(fileDialog.Modal() == ok) { componentsBox.StopEditing(false); row.SetData(locationField, fileDialog.filePath); componentsBox.NotifyChanged(this, componentsBox, row); componentsBox.currentField = componentsBox.currentField; } return true; } }; CheckListBox componentsBox { this, size = { 460, 112 }, position = { 160, 160 }, hasHeader = true; alwaysEdit = true; bool NotifyChanged(ListBox listBox, DataRow row) { Component * component = ((CheckItem *)listBox.GetData(componentField))->data; char path[MAX_LOCATION], relative[MAX_LOCATION] = "", ** newPath; char fullPath[MAX_LOCATION]; component->parent->GetFullPath(path); strcpy(fullPath, path); newPath = (char **)row.GetData(locationField); if(newPath && *newPath) { PathCat(fullPath, *newPath); MakePathRelative(fullPath, path, relative); } listBox.SetData(locationField, relative); strcpy(component->installPath, relative); //SetAvailableSpace(component, path); { ComponentID c; install.disabled = false; for(c = 0; components[c].name; c++) { SetAvailableSpace(components[c], installDir); } } return true; } bool NotifyEditDone(ListBox listBox, DataRow row) { browse.Destroy(0); return true; } bool NotifyEdited(ListBox listBox, DataRow row) { browse.parent = listBox; browse.position = { componentField.width + locationField.width + 18, (listBox.currentIndex+1) * listBox.rowHeight - 2 }; browse.size = { 30, listBox.rowHeight + 3 }; browse.Create(); return true; } void NotifyChecked(CheckListBox listBox, DataRow row) { Component * component = ((CheckItem *)row.GetData(componentField))->data; int c; Button checkBox = (Button)row.tag; component->selected = checkBox.checked; if(!component->parent) totalSize -= component->requiredSize; component->requiredSize = 0; if(component->selected) { component->requiredSize += component->size; if(component->subComponents) for(c = 0; component->subComponents[c].name; c++) component->requiredSize += component->subComponents[c].requiredSize; } if(component->requiredSize) row.SetData(reqField, (void *)component->requiredSize); else row.UnsetData(reqField); if(!component->parent) { totalSize += component->requiredSize; { char sizeString[100]; PrintSize(sizeString, totalSize, 2); totalSpaceValue.text = sizeString; } } } }; Label agreementLbl { parent = this, text = "By installing the ECERE SDK, you agree to the terms and conditions.", anchor = Anchor { left = 24, top = 424 } }; Button licenseButton { this, inactive = true, offset = false, bevel = false, foreground = blue, font = { "Tahoma", 8.25f, underline = true }, text = "terms and conditions", anchor = Anchor { left = 241, top = 421 }; cursor = ((GuiApplication)__thisModule).GetCursor(hand); bool NotifyClicked(Button button, int x, int y, Modifiers mods) { LicenseBox { master = this, sourceFile = ":LICENSE" }.Modal(); return true; } }; CheckListBox optionsBox { this, size = { 460, 94 }, position = { 160, 284 }; void NotifyChecked(CheckListBox listBox, DataRow row) { CheckItem * item = row.GetData(optionField); InstallOption * option = item->data; int c; Button checkBox = (Button)row.tag; option->selected = checkBox.checked; } }; Button install { parent = this, text = "Install", isDefault = true, size = { 75, 23 }, position = { 432, 416 }; bool NotifyClicked(Button button, int x, int y, Modifiers mods) { installProgress.Create(); Destroy(0); // installProgress.thread.Main(); installProgress.thread.Create(); return true; } }; Button button3 { parent = this, text = "Cancel", hotKey = altX, size = Size { 75, 23 }, anchor = Anchor { left = 544, top = 416 }, NotifyClicked = ButtonCloseDialog }; Label label1 { labeledWindow = destBox, tabCycle = true, isGroupBox = true, parent = this, inactive = false, size = Size { 458, 50 }, anchor = Anchor { left = 160, top = 96 } }; EditBox destBox { parent = label1, master = this, text = " Destination Folder", size = Size { 336, 19 }, anchor = Anchor { left = 12, top = 20 }; bool NotifyModified(EditBox editBox) { ComponentID c; strcpy(installDir, destBox.contents); install.disabled = false; for(c = 0; components[c].name; c++) { SetAvailableSpace(components[c], installDir); } return true; } }; Button button1 { label1, this, "Browse", altB, size = { 83, 24 }, position = { 360, 16 }; bool NotifyClicked(Button button, int x, int y, Modifiers mods) { strcpy(fileDialog.filePath, installDir); StripLastDirectory(installDir, fileDialog.currentDirectory); if(fileDialog.Modal()) { strcpy(installDir, fileDialog.filePath); destBox.contents = installDir; // TOCHECK: Should setting contents call NotifyModified? destBox.NotifyModified(destBox.master, destBox); } return true; } }; EditBox label5 { this, multiLine = true, opacity = 0, borderStyle = none, inactive = true, size = { 136, 53 }, position = { 14, 96 }, noSelect = true, contents = "Select the default root\n" "folder where to install\n" "all components:" }; EditBox label6 { this, opacity = 0, borderStyle = none, inactive = true, size = { 136, 132 }, position = { 14, 152 }, noSelect = true, multiLine = true, contents = "Select the optional\n" "components you wish\n" "to install:\n\n" "You may customize the\n" "install location for each\n" "of them, or use the default\n" "based on the main\n" "destination folder." }; EditBox label7 { this, opacity = 0, borderStyle = none, inactive = true, size = { 136, 53 }, position = { 14, 280 }, noSelect = true, multiLine = true, contents = "Select icons to install, file\n" "associations, and system\n" "environment modifications:" }; Label totalSpaceLabel { this, position = { 18, 352 }, text = "Space Required: " }; Label totalSpaceValue { this, position = { 100, 352 }, text = "0 mb" }; EditBox editBox1 { inactive = true, noSelect = true, multiLine = true, parent = label3, text = "editBox1", opacity = 0, borderStyle = none, size = Size { 350, 35 }, anchor = Anchor { horz = 111, vert = 13 }, contents = "Choose in which folder to install the ECERE SDK, which features\n" "of the SDK to install, as well as where to install program icons." }; Label label2 { parent = this, text = buildString, position = { 16, 392 }, disabled = true, opacity = 1, background = activeBorder }; Picture picture1 { image = BitmapResource { ":ecere.bmp", transparent = true }, filter = true, parent = label3, text = "picture1", anchor = Anchor { left = 16, top = 4 } }; Label label4 { parent = label3, text = "Choose Components, Locations and Install Options", font = FontResource { "Tahoma", 8.25f, bold = true }, size = Size { 326, 16 }, anchor = Anchor { horz = 91, vert = -12 } }; DataField componentField { "CheckItem", width = 140, header = "Component" }; DataField locationField { "char *", width = 108, header = "Destination Folder", editable = true }; DataField reqField { "FileSize", width = 80, header = "Req. Space", alignment = right }; DataField avField { "FileSize", width = 80, header = "Avail. Space", alignment = right }; DataField optionField { "CheckItem" }; void SetAvailableSpace(Component component, char * parentPath) { char path[MAX_LOCATION]; int c; FileSize size = 0; strcpy(path, parentPath); PathCat(path, component.installPath); if(component.subComponents) for(c = 0; component.subComponents[c].name; c++) SetAvailableSpace(component.subComponents[c], path); while(!FileExists(path) && path[0]) StripLastDirectory(path, path); if(path[0]) GetFreeSpace(path, &size); component.row.SetData(avField, (void *)size); if(!size) install.disabled = true; } FileSize ComputeSize(char * path) { FileSize size = 0; FileAttribs attribs = FileExists(path); if(attribs.isDirectory) { FileListing listing { path }; while(listing.Find()) { if(listing.stats.attribs.isDirectory) size += ComputeSize(listing.path); else size += listing.stats.size; } } else FileGetSize(path, &size); return size; } void AddComponent(Component component, Component parent, char * parentPath) { DataRow row = component.row = componentsBox.AddRow((parent != null) ? parent.row : null); Button checkBox = (Button) row.tag; FileSize size = 0; char path[MAX_LOCATION]; strcpy(path, parentPath); if(component.defInstallPath) PathCat(path, component.defInstallPath); component.parent = parent; row.SetData(null, CheckItem { component.name, component } ); if(component.defInstallPath) { strcpy(component.installPath, component.defInstallPath); ChangeCh(component.installPath, '/', DIR_SEP); row.SetData(locationField, component.installPath); } if(component.mandatory) checkBox.disabled = true; if(!component.selected) componentsBox.ToggleCheck(row); if(component.dataPath) { char path[MAX_LOCATION]; strcpy(path, ":"); PathCat(path, component.dataPath); component.size = ComputeSize(path); } if(component.subComponents) { int c; for(c = 0; component.subComponents[c].name; c++) { AddComponent(component.subComponents[c], component, path); size += component.subComponents[c].requiredSize; } } component.requiredSize = component.selected ? (size + component.size) : 0; if(component.requiredSize) row.SetData(reqField, (void *)component.requiredSize); while(!FileExists(path) && path[0]) StripLastDirectory(path, path); if(path[0]) GetFreeSpace(path, &size); else size = 0; row.SetData(avField, (void *)size); row.collapsed = true; } void AddOption(InstallOption option, InstallOption parent) { DataRow row = option.row = optionsBox.AddRow((parent != null) ? parent.row : null); row.SetData(null, CheckItem { option.name, option } ); if(!option.selected) optionsBox.ToggleCheck(row); if(option.subOptions) { int c; for(c = 0; option.subOptions[c].name; c++) { AddOption(option.subOptions[c], option); } } row.collapsed = true; } Installer() { int c; char programFilesDir[MAX_LOCATION]; char appData[MAX_LOCATION]; // = getenv("APPDATA"); char homeDrive[MAX_LOCATION]; //= getenv("HOMEDRIVE"); char winDir[MAX_LOCATION]; //= getenv("windir"); GetEnvironment("APPDATA", appData, sizeof(appData)); GetEnvironment("HOMEDRIVE", homeDrive, sizeof(homeDrive)); GetEnvironment("windir", winDir, sizeof(winDir)); componentsBox.AddField(componentField); componentsBox.AddField(locationField); componentsBox.AddField(reqField); componentsBox.AddField(avField); optionsBox.AddField(optionField); if(GetEnvironment("ProgramFiles", programFilesDir, MAX_LOCATION)) { strcpy(installDir, programFilesDir); PathCat(installDir, "ECERE SDK"); } else if(homeDrive && homeDrive[0]) { strcpy(installDir, homeDrive); PathCat(installDir, "ECERE SDK"); } else if(winDir && winDir[0]) { strcpy(installDir, winDir); PathCat(installDir, "..\\ECERE SDK"); } else strcpy(installDir, "C:\\ECERE SDK"); if(appData && appData[0]) { static char defSamplesPath[MAX_LOCATION]; strcpy(defSamplesPath, appData); PathCat(defSamplesPath, "ECERE SDK\\Samples"); components[samples].defInstallPath = defSamplesPath; } destBox.contents = installDir; totalSize = 0; { ComponentID c; for(c = 0; components[c].name; c++) { AddComponent(components[c], null, installDir); totalSize += components[c].requiredSize; } } { char sizeString[100]; PrintSize(sizeString, totalSize, 2); totalSpaceValue.text = sizeString; } for(c = 0; options[c].name; c++) AddOption(options[c], null); } bool OnCreate() { destBox.Activate(); return true; } void OnRedraw(Surface surface) { ColorKey keys[2] = { { blue, 0 }, { darkBlue, 1 } }; //surface.Gradient(keys, sizeof(keys)/sizeof(ColorKey), 1.0f, Vertical, 0,0, clientSize.w, clientSize.h); surface.SetForeground(Color { 128, 128, 128 }); surface.HLine(160, 620, 400); surface.SetForeground(white); surface.HLine(160, 621, 401); surface.PutPixel(621, 400); } Label label3 { parent = this, opacity = 1, borderStyle = deep, size = Size { 644, 93 }, anchor = Anchor { left = -8, top = -8 }; void OnRedraw(Surface surface) { ColorKey keys[] = { { white, 0 }, { activeBorder, 1 } }; surface.Gradient(keys, sizeof(keys)/sizeof(ColorKey), 0, horizontal, 220,0, clientSize.w, clientSize.h); Label::OnRedraw(surface); } }; } class InstallProgress : Window { text = "ECERE Software Development Kit Setup"; background = activeBorder; borderStyle = fixed; hasMinimize = true; hasClose = true; tabCycle = true; size = Size { 640, 480 }; Label installing { this, position = { 32, 160 } }; ProgressBar progressBar { parent = this, text = "progressBar1", size = Size { 588, 24 }, anchor = Anchor { left = 24, top = 184 } }; Button finish { parent = this, text = "Install", disabled = true, isDefault = true, size = Size { 75, 23 }, anchor = Anchor { left = 432, top = 416 }; NotifyClicked = ButtonCloseDialog }; Button cancel { this, text = "Cancel", hotKey = altX, size = Size { 75, 23 }, anchor = Anchor { left = 544, top = 416 }; bool NotifyClicked(Button button, int x, int y, Modifiers mods) { abortInstall = true; return true; } }; EditBox titleInfo { inactive = true, noSelect = true, multiLine = true, parent = label3, text = "editBox1", opacity = 0, borderStyle = none, size = Size { 350, 35 }, anchor = Anchor { horz = 111, vert = 13 }, contents = "Please wait while the Ecere Software Development Kit is being installed." }; Label label2 { parent = this, text = buildString, position = { 16, 392 }, disabled = true, opacity = 1, background = activeBorder }; Picture picture1 { image = BitmapResource { ":ecere.bmp", transparent = true }, filter = true, parent = label3, text = "picture1", anchor = Anchor { left = 16, top = 4 } }; Label title { parent = label3, text = "Installing the ECERE SDK", font = FontResource { "Tahoma", 8.25f, bold = true }, size = Size { 326, 16 }, anchor = Anchor { horz = 91, vert = -12 } }; void OnRedraw(Surface surface) { ColorKey keys[2] = { { blue, 0 }, { darkBlue, 1 } }; //surface.Gradient(keys, sizeof(keys)/sizeof(ColorKey), 1.0f, Vertical, 0,0, clientSize.w, clientSize.h); surface.SetForeground(Color { 128, 128, 128 }); surface.HLine(160, 620, 400); surface.SetForeground(white); surface.HLine(160, 621, 401); surface.PutPixel(621, 400); } Label label3 { parent = this, opacity = 1, borderStyle = deep, size = Size { 644, 93 }, anchor = Anchor { left = -8, top = -8 }; void OnRedraw(Surface surface) { ColorKey keys[] = { { white, 0 }, { activeBorder, 1 } }; surface.Gradient(keys, sizeof(keys)/sizeof(ColorKey), 0, horizontal, 220,0, clientSize.w, clientSize.h); Label::OnRedraw(surface); } }; InstallThread thread { }; } Installer installer {}; InstallProgress installProgress { autoCreate = false }; void ModifyPath(char * newPath) { char * paths[100]; int p, count; char oldPath[4096]; CoreSDKID c; strcpy(oldPath, newPath); count = TokenizeWith(oldPath, sizeof(paths) / sizeof(char *), paths, ";", false); for(c = 0; coreSDK[c].name; c++) { char path[MAX_LOCATION]; coreSDK[c].GetFullPath(path); if(c != ide && c != runtime && c != eda && c != ec #ifndef NOMINGW && c != upx #endif ) { #ifndef NOMINGW if(!pathOptions[PathOptions::AddMinGWPaths].selected) #endif continue; PathCat(path, "bin"); } else if(!pathOptions[PathOptions::AddECEREPaths].selected) continue; for(p = 0; p