From 61738894118c0342dffdcbde5af45150828b4fc0 Mon Sep 17 00:00:00 2001 From: kichik Date: Tue, 11 Jan 2005 16:28:10 +0000 Subject: [PATCH] components functions that don't rely on the TreeView git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3854 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/exehead/components.c | 142 +++++++++++++++++++++++++++++++ Source/exehead/components.h | 9 ++ Source/exehead/exehead-bzip2.dsp | 8 ++ Source/exehead/exehead-lzma.dsp | 8 ++ Source/exehead/exehead-zlib.dsp | 8 ++ 5 files changed, 175 insertions(+) create mode 100644 Source/exehead/components.c create mode 100644 Source/exehead/components.h diff --git a/Source/exehead/components.c b/Source/exehead/components.c new file mode 100644 index 00000000..16cb4ffe --- /dev/null +++ b/Source/exehead/components.c @@ -0,0 +1,142 @@ +#include "../Platform.h" +#include "config.h" +#include "ui.h" +#include "fileform.h" + +void NSISCALL SectionFlagsChanged(unsigned int index) { + section *sections = g_sections; + + int flags = sections[index].flags; + + if (flags & SF_SECGRP) { + unsigned int i = index + 1; + unsigned int level = 0; + + for (; i < (unsigned int) num_sections; i++) { + if (sections[i].flags & SF_SECGRP) { + level++; + continue; + } + + if (sections[i].flags & SF_SECGRPEND) { + if (level-- == 0) { + break; + } + + continue; + } + + if ((sections[i].flags & SF_RO) == 0) { + sections[i].flags &= ~SF_SELECTED; + sections[i].flags |= (flags & SF_SELECTED); + } + } + } +} + +unsigned int NSISCALL RefreshSectionGroups(unsigned int i) { + unsigned int selected = 0; + unsigned int not_selected = 0; + + section *sections = g_sections; + + unsigned int sec = i; + + if (sections[sec].flags & SF_SECGRP) { + sections[sec].flags &= ~(SF_SELECTED | SF_PSELECTED); + i++; + } + + while (i < (unsigned int) num_sections) { + int flags = sections[i].flags; + int ni = i + 1; + + if (flags & SF_SECGRP) { + ni = RefreshSectionGroups(i); + } + + if (flags & SF_SECGRPEND) { + if (sections[sec].flags & SF_SECGRP) { + if (selected) { + if (not_selected) { + sections[sec].flags |= SF_PSELECTED; + } else { + sections[sec].flags |= SF_SELECTED; + } + } + } + + return ni; + } + + if (flags & SF_PSELECTED) { + selected++; + } + + if (flags & SF_SELECTED) { + selected++; + } else { + not_selected++; + } + + i = ni; + } + + return 0; +} + +void NSISCALL SetInstType(int inst_type) { + unsigned int i = 0; + + section *sections = g_sections; + + if ((unsigned int) inst_type >= NSIS_MAX_INST_TYPES) { + return; + } + + for (; i < (unsigned int) num_sections; i++) { + if (sections[i].flags & (SF_SECGRP | SF_SECGRPEND)) { + continue; + } + + if (sections[i].install_types & (1 << inst_type)) { + sections[i].flags |= SF_SELECTED; + } else { + sections[i].flags &= ~SF_SELECTED; + } + } +} + +unsigned int NSISCALL GetInstType(HTREEITEM *items) { + unsigned int i, j; + + section *sections = g_sections; + + for (i = 0; i < NSIS_MAX_INST_TYPES; i++) { + if (!g_header->install_types[i]) { + continue; + } + + for (j = 0; j < (unsigned int) num_sections; j++) { + if (sections[j].flags & (SF_SECGRP | SF_SECGRPEND)) { + continue; + } + + if (items && !items[j]) { + continue; + } + + if ((sections[j].install_types & (1 << i)) == ((sections[j].flags & SF_SELECTED) << i)) { + continue; + } else { + break; + } + } + + if (j == (unsigned int) num_sections) { + break; + } + } + + return i; +} diff --git a/Source/exehead/components.h b/Source/exehead/components.h new file mode 100644 index 00000000..40764713 --- /dev/null +++ b/Source/exehead/components.h @@ -0,0 +1,9 @@ +#ifndef ___COMPONENTS_H___ +#define ___COMPONENTS_H___ + +void NSISCALL SectionFlagsChanged(unsigned int index); +unsigned int NSISCALL RefreshSectionGroups(unsigned int i); +void NSISCALL SetInstType(int inst_type); +unsigned int NSISCALL GetInstType(HTREEITEM *items); + +#endif//!___COMPONENTS_H___ diff --git a/Source/exehead/exehead-bzip2.dsp b/Source/exehead/exehead-bzip2.dsp index 4e2029e4..6035221e 100644 --- a/Source/exehead/exehead-bzip2.dsp +++ b/Source/exehead/exehead-bzip2.dsp @@ -91,6 +91,10 @@ SOURCE=.\bgbg.c # End Source File # Begin Source File +SOURCE=.\components.c +# End Source File +# Begin Source File + SOURCE=..\crc32.c # End Source File # Begin Source File @@ -119,6 +123,10 @@ SOURCE=.\util.c # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=.\components.h +# End Source File +# Begin Source File + SOURCE=.\config.h # End Source File # Begin Source File diff --git a/Source/exehead/exehead-lzma.dsp b/Source/exehead/exehead-lzma.dsp index 82921b44..fed44a37 100644 --- a/Source/exehead/exehead-lzma.dsp +++ b/Source/exehead/exehead-lzma.dsp @@ -81,6 +81,10 @@ SOURCE=.\bgbg.c # End Source File # Begin Source File +SOURCE=.\components.c +# End Source File +# Begin Source File + SOURCE=..\crc32.c # End Source File # Begin Source File @@ -109,6 +113,10 @@ SOURCE=.\util.c # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=.\components.h +# End Source File +# Begin Source File + SOURCE=.\config.h # End Source File # Begin Source File diff --git a/Source/exehead/exehead-zlib.dsp b/Source/exehead/exehead-zlib.dsp index 39530efe..8e280718 100644 --- a/Source/exehead/exehead-zlib.dsp +++ b/Source/exehead/exehead-zlib.dsp @@ -93,6 +93,10 @@ SOURCE=.\bgbg.c # End Source File # Begin Source File +SOURCE=.\components.c +# End Source File +# Begin Source File + SOURCE=..\crc32.c # End Source File # Begin Source File @@ -121,6 +125,10 @@ SOURCE=.\util.c # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=.\components.h +# End Source File +# Begin Source File + SOURCE=.\config.h # End Source File # Begin Source File