summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern/src/modern_popup.cpp
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-07-13 07:39:26 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-07-13 07:39:26 +0000
commit2ab468f0ac05d1f257fbf8aa6add9512eabbcc20 (patch)
tree7eb6482089b07994ae77d264e120f3e7772c2fd6 /plugins/Clist_modern/src/modern_popup.cpp
parentccb4003b6178f4c195350ae29896fdd442412af4 (diff)
Clist_modern: changed folder structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@939 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern/src/modern_popup.cpp')
-rw-r--r--plugins/Clist_modern/src/modern_popup.cpp131
1 files changed, 131 insertions, 0 deletions
diff --git a/plugins/Clist_modern/src/modern_popup.cpp b/plugins/Clist_modern/src/modern_popup.cpp
new file mode 100644
index 0000000000..9da27e5ff9
--- /dev/null
+++ b/plugins/Clist_modern/src/modern_popup.cpp
@@ -0,0 +1,131 @@
+/*
+Copyright (C) 2005 Ricardo Pescuma Domenecci
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+*/
+#include "hdr/modern_commonheaders.h"
+#include "hdr/modern_popup.h"
+
+
+BOOL EnablePopups = FALSE;
+
+static LRESULT CALLBACK DumbPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+
+// Show an error popup
+void ShowErrPopup(const char *title, const char *description)
+{
+ ShowPopup(title == NULL ? "Modern Contact List Error" : title, description, POPUP_TYPE_ERROR);
+}
+
+
+// Show an trace popup
+void ShowTracePopup(const char *text)
+{
+#ifdef _DEBUG
+ static int num = 0;
+ char tmp[1024];
+
+ mir_snprintf(tmp, SIZEOF(tmp), "CM TRACE %d: %s", num, text);
+ TRACE(tmp);
+ TRACE("\n");
+ num++;
+
+ ShowPopup(tmp, "", POPUP_TYPE_NORMAL);
+#endif
+}
+
+
+// Show an popup
+void ShowPopup(const char *title, const char *description, int type)
+{
+ POPUPDATAEX ppd;
+ int ret;
+
+ if ( !ServiceExists(MS_POPUP_ADDPOPUPEX) || !EnablePopups)
+ {
+ return;
+ }
+
+ // Make popup
+ ZeroMemory(&ppd, sizeof(ppd));
+ ppd.lchContact = 0;
+ ppd.lchIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+
+ strncpy(ppd.lpzContactName, title == NULL ? "Modern Contact List" : title, SIZEOF(ppd.lpzContactName)-1);
+ ppd.lpzContactName[SIZEOF(ppd.lpzContactName)-1] = '\0';
+
+ if (description != NULL)
+ {
+ strncpy(ppd.lpzText, description, SIZEOF(ppd.lpzText)-1);
+ ppd.lpzText[SIZEOF(ppd.lpzText)-1] = '\0';
+ }
+
+ if (type == POPUP_TYPE_NORMAL || type == POPUP_TYPE_TEST)
+ {
+ ppd.colorBack = 0;
+ ppd.colorText = 0;
+ }
+ else // if (type == POPUP_TYPE_ERROR)
+ {
+ ppd.colorBack = -1;
+ ppd.colorText = RGB(255,255,255);
+ }
+
+ ppd.PluginWindowProc = DumbPopupDlgProc;
+
+ if (type == POPUP_TYPE_NORMAL || type == POPUP_TYPE_TEST)
+ {
+ ppd.iSeconds = 0;
+ }
+ else // if (type == POPUP_TYPE_ERROR)
+ {
+ ppd.iSeconds = 0;
+ }
+
+ // Now that every field has been filled, we want to see the popup.
+ ret = CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd,0);
+
+ ret++;
+}
+
+
+
+// Handle to popup events
+static LRESULT CALLBACK DumbPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch(message) {
+ case WM_COMMAND:
+ {
+ PUDeletePopUp(hWnd);
+ return TRUE;
+ }
+
+ case WM_CONTEXTMENU:
+ {
+ PUDeletePopUp(hWnd);
+ return TRUE;
+ }
+
+ case UM_FREEPLUGINDATA:
+ {
+ return TRUE;
+ }
+ }
+
+ return DefWindowProc(hWnd, message, wParam, lParam);
+}
+