diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-06-08 13:55:50 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-06-08 13:55:50 +0000 |
commit | 47739a02585405a13b81123da3a9f3ff97cea0b9 (patch) | |
tree | 026bae1bdea9f3f7b1a167325fbd2a9a95921dc3 /plugins/TopToolBar/separators.c | |
parent | fa488438351d7d5930a281b9293e7fb853f41eed (diff) |
TopToolBar added
git-svn-id: http://svn.miranda-ng.org/main/trunk@360 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TopToolBar/separators.c')
-rw-r--r-- | plugins/TopToolBar/separators.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/plugins/TopToolBar/separators.c b/plugins/TopToolBar/separators.c new file mode 100644 index 0000000000..3be5e056a3 --- /dev/null +++ b/plugins/TopToolBar/separators.c @@ -0,0 +1,111 @@ +
+#include "common.h"
+#pragma hdrstop
+
+extern HINSTANCE hInst;
+#define MAXSEPS 32
+int Separators[MAXSEPS];
+
+static int SeparatorCnt=0;
+
+int InsertSeparator(int id)
+{
+ TTBButton ttb;
+ char buf[255];
+
+ HBITMAP Separator=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_SEP));
+ //itoa(SeparatorCnt++,buf,10);
+
+ wsprintf(buf,"%s %d",Translate("Separator"),id);
+ memset(&ttb,0,sizeof(ttb));
+ ttb.cbSize=sizeof(ttb);
+ ttb.hbBitmapDown=Separator;
+ ttb.hbBitmapUp=Separator;
+ ttb.dwFlags=TTBBF_VISIBLE|TTBBF_ISSEPARATOR;
+ ttb.pszServiceDown="";
+ ttb.pszServiceUp="";
+ ttb.lParamDown=id;
+ ttb.name=buf;
+ SeparatorCnt++;
+ return(TTBAddButton(&ttb,0));
+};
+
+INT_PTR DeleteSeparator(WPARAM id,LPARAM lParam)
+{
+ if ((id<0)||(id>=MAXSEPS))
+ {
+ MessageBoxA(0,"Wrong id","Error",0);
+ return(0);
+ };
+
+ if (Separators[id]!=0)
+ {
+ TTBRemoveButton(Separators[id],0);
+ Separators[id]=0;
+ SeparatorCnt--;
+ };
+ SaveAllSeparators();
+ return (1);
+};
+int LoadAllSeparators()
+{
+ char buf[255];
+ char buf1[10];
+ int id,i;
+
+ //must be locked
+ memset(buf,0,sizeof(buf));
+
+ memset(Separators,0,sizeof(Separators));
+ for (i=0;i<MAXSEPS;i++)
+ {
+ memset(buf1,0,sizeof(buf1));
+ _itoa(i,buf1,10);
+ id=DBGetContactSettingWord(0,TTB_OPTDIR,AS(buf,"Sep",buf1),-1);
+ if (id==i)
+ {
+ Separators[i]=InsertSeparator(i);
+ };
+ };
+ return 0;
+};
+int SaveAllSeparators()
+{
+ char buf[255];
+ char buf1[10];
+ int i;
+ for (i=0;i<MAXSEPS;i++)
+ {
+ memset(buf1,0,sizeof(buf1));
+ _itoa(i,buf1,10);
+ if (Separators[i]!=0)
+ {
+ DBWriteContactSettingWord(0,TTB_OPTDIR,AS(buf,"Sep",buf1),i);
+ }
+ else
+ {
+ DBWriteContactSettingWord(0,TTB_OPTDIR,AS(buf,"Sep",buf1),-1);
+ DBDeleteContactSetting(0,TTB_OPTDIR,AS(buf,"Sep",buf1));
+ };
+ };
+ return 0;
+};
+//return 0 on success,-1 on error
+INT_PTR InsertNewFreeSeparator(WPARAM wParam,LPARAM lParam)
+{
+ if (SeparatorCnt<MAXSEPS)
+ {
+ int i;
+ for (i=0;i<MAXSEPS;i++)
+ {
+ if (Separators[i]==0)
+ {
+ Separators[i]=InsertSeparator(i);
+ SaveAllSeparators();
+ return(0);
+ };
+ };
+ };
+
+ return(-1);
+};
|