summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern/modern_newrowopts.cpp
blob: fac4015bad3b0575922e180644a8d38a45919678 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*

Miranda IM: the free IM client for Microsoft* Windows*

Copyright 2000-2003 Miranda ICQ/IM project, 
all portions of this codebase are copyrighted to the people 
listed in contributors.txt.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/************************************************************************/
/*        Author Artem Shpynov (shpynov@nm.ru)                          */
/************************************************************************/

/************************************************************************/
/*********      New row design options file handle               ********/
/************************************************************************/
 

#include "hdr/modern_commonheaders.h"
#include "m_clui.h"
#include "hdr/modern_clist.h"
#include "m_clc.h"

#define EMPTY_PLACE 255
#define COLUMNS_PLACE 254
#define ROWS_PLACE 253

typedef struct _NodeList 
{
	BYTE				bType;
	int					pData;
	DWORD				AllocatedChilds;
	struct _NodeList *	childNodes;
	struct _NodeList *  itemParent;
} NodeList;

NodeList * RootNode = NULL;

NodeList * AddNode(NodeList * Parent)
{
	NodeList * res;
	if (!Parent) 
	{
		res = (NodeList *)mir_alloc(sizeof(NodeList));
		memset(res,0,sizeof(NodeList));
		return res;
	}
	Parent->childNodes = (NodeList*) mir_realloc(Parent->childNodes,sizeof(NodeList)*(Parent->AllocatedChilds+1));
	memset(&(Parent->childNodes[Parent->AllocatedChilds]),0,sizeof(NodeList));
	Parent->childNodes[Parent->AllocatedChilds].itemParent = Parent;
	Parent->AllocatedChilds++;
	return &(Parent->childNodes[Parent->AllocatedChilds-1]);
}


BOOL RemoveChildNode(NodeList * FromList, DWORD index)
{
	DWORD i;
	NodeList * work;
	if (!FromList) return FALSE;
	if (FromList->AllocatedChilds <= index) return FALSE;
	work = &(FromList->childNodes[index]);
	for(i=0; i < work->AllocatedChilds; i++)
	{
		if (work->childNodes[i].AllocatedChilds)
			RemoveChildNode(work->childNodes,i);
	}
	if (work->AllocatedChilds) 
	{
		mir_free_and_nill(work->childNodes);
		work->AllocatedChilds = 0;
	}
	//mir_free_and_nill(work);
	memmove(FromList->childNodes+index,FromList->childNodes+index+1,sizeof(NodeList)*(FromList->AllocatedChilds-index-1));
	FromList->AllocatedChilds--;
	return TRUE;
}


BOOL RemoveNode(NodeList * FromList)
{
	if (!FromList)  return FALSE;
	if (FromList->itemParent)
	{
		DWORD k;
		for (k = 0;k < FromList->itemParent->AllocatedChilds;k++)
			if (&(FromList->itemParent->childNodes[k]) == FromList)
			{
				BOOL res = RemoveChildNode(FromList->itemParent,k);				
				return res;
			}
	}
	do 
	{
		RemoveChildNode(FromList,0);
	}while (FromList->AllocatedChilds>0);
	mir_free_and_nill(FromList->childNodes);
	mir_free_and_nill(FromList);
	return TRUE;
}
int ident = 0;
void PrintIdent()
{
	int k;
	for (k = 0;k < ident;k++)
		TRACE("-");
}

void TraceTreeLevel(NodeList * node)
{
	DWORD i;
	if (!node) return;
	PrintIdent();
	{
		char buf[255];
		mir_snprintf(buf,SIZEOF(buf),"%d\n",node->pData);
		TRACE(buf);
	}
	ident += 5;
	for(i=0; i < node->AllocatedChilds;i++)
	{

		if (node->childNodes[i].AllocatedChilds>0)
			TraceTreeLevel(&(node->childNodes[i]));	
		else
		{
			PrintIdent();
			{
				char buf[255];
				mir_snprintf(buf,SIZEOF(buf),"%d\n",node->childNodes[i].pData);
				TRACE(buf);
			}
		}
	}
	ident -= 5;
}

BOOL CALLBACK DlgProcItemNewRowOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	case WM_INITDIALOG:
		{
			NodeList * res1,*res2, *res3;
			int i=0;
			RootNode = AddNode(NULL);
			RootNode->pData = i++;
			res1 = AddNode(RootNode);
			res1->pData = i++;
			res1 = AddNode(RootNode);
			res1->pData = i++;
				res2 = AddNode(res1);
				res2->pData = i++;
				res2 = AddNode(res1);
				res2->pData = i++;
					res3 = AddNode(res2);
					res3->pData = i++;
				res3 = AddNode(res1);
				res3->pData = i++;
			res3 = AddNode(RootNode);
			res3->pData = i++;
			TRACE("*********** Nodes DUMP 1 ***********\n");
			TraceTreeLevel(RootNode);
			if (RemoveNode(res1)) res1 = 0;
			TRACE("*********** Nodes DUMP 2 ***********\n");
			TraceTreeLevel(RootNode);
			//CheckDlgButton(hwndDlg, IDC_HIDE_ICON_ON_AVATAR, DBGetContactSettingByte(NULL,"CList","IconHideOnAvatar",SETTING_HIDEICONONAVATAR_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED );
			MessageBox(hwndDlg,TEXT("Init NewRow Dialog"),TEXT("Notify"),MB_OK);
			break;
		}
	case WM_NOTIFY:
		{
			switch (((LPNMHDR)lParam)->idFrom) 
			{
			case 0:
				{
					switch (((LPNMHDR)lParam)->code)
					{
					case PSN_APPLY:
						{
							return TRUE;
						}
					}
				}
			}
		}
	}
	return 0;
};