source: trunk/Lucide/gui/aboutDlg.cpp @ 399

Last change on this file since 399 was 385, checked in by Silvan Scherrer, 12 years ago

updated aboutdlg ticket:174

File size: 5.1 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: CDDL 1.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the COMMON DEVELOPMENT AND
5 * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6 * this file except in compliance with the License. You may obtain a copy of
7 * the License at http://www.sun.com/cddl/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Initial Developer of the Original Code is
15 * Eugene Romanenko, netlabs.org.
16 * Portions created by the Initial Developer are Copyright (C) 2006
17 * the Initial Developer. All Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 * Alternatively, the contents of this file may be used under the terms of
22 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
23 * in which case the provisions of the LGPL are applicable instead of those
24 * above. If you wish to allow use of your version of this file only under the
25 * terms of the LGPL, and not to allow others to use your version of this file
26 * under the terms of the CDDL, indicate your decision by deleting the
27 * provisions above and replace them with the notice and other provisions
28 * required by the LGPL. If you do not delete the provisions above, a recipient
29 * may use your version of this file under the terms of any one of the CDDL
30 * or the LGPL.
31 *
32 * ***** END LICENSE BLOCK ***** */
33
34
35#include "os2all.h"
36
37#include <stdio.h>
38#include <string.h>
39#include <malloc.h>
40
41#include "globals.h"
42#include "luutils.h"
43#include "lucide_res.h"
44
45extern "C" void setLinkPointer( HPOINTER hp );
46extern "C" void toLink( HWND hwnd );
47BOOL DrawTransparentBitmap( HAB hab, HPS hpsDraw, PPOINTL drawptl, HBITMAP hbmp );
48
49typedef struct
50{
51    PFNWP oldLogoProc;
52    HBITMAP image;
53} logoData;
54
55#define IMAGE_X 52
56#define IMAGE_Y 52
57
58static MRESULT EXPENTRY LogoProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
59{
60    logoData *ld = (logoData *)WinQueryWindowULong( hwnd, QWL_USER );
61    switch ( msg )
62    {
63        case WM_PAINT:
64            {
65                HPS hps;
66                RECTL rect;
67                WinQueryWindowRect( hwnd, &rect );
68                hps = WinBeginPaint( hwnd, 0L, 0L );
69                if ( ld->image != NULLHANDLE )
70                {
71                    LONG xPos = ( rect.xRight - IMAGE_X ) / 2;
72                    LONG yPos = ( rect.yTop - IMAGE_Y ) / 2;
73                    POINTL ptl = { xPos, yPos };
74                    DrawTransparentBitmap( hab, hps, &ptl, ld->image );
75                    //WinDrawBitmap( hps, ld->image, NULL, &ptl, 0, 0, DBM_NORMAL );
76                }
77                WinEndPaint( hps );
78            }
79            return (MRESULT)FALSE;
80
81        case WM_DESTROY:
82            ld->oldLogoProc( hwnd, msg, mp1, mp2 );
83            if ( ld->image != NULLHANDLE ) {
84                GpiDeleteBitmap( ld->image );
85            }
86            free( ld );
87            return (MRESULT)FALSE;
88    }
89    return ld->oldLogoProc( hwnd, msg, mp1, mp2 );
90}
91
92void logoImageCreate( HWND hwnd )
93{
94    logoData *ld;
95    ld = (logoData *)malloc( sizeof( logoData ) );
96    memset( ld, 0, sizeof( logoData ) );
97    ld->oldLogoProc = WinSubclassWindow( hwnd, LogoProc );
98    WinSetWindowULong( hwnd, QWL_USER, (ULONG)ld );
99    HPS hps = WinGetPS( hwnd );
100    ld->image = GpiLoadBitmap( hps, _hmod, IDB_LOGO, 0, 0 );
101    WinReleasePS( hps );
102    WinInvalidateRect( hwnd, NULL, FALSE );
103}
104
105
106static HWND hWndFrame = NULLHANDLE;
107
108static MRESULT EXPENTRY AboutProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
109{
110    switch ( msg )
111    {
112        case WM_INITDLG:
113            {
114                localizeDialog( hwnd );
115                centerWindow( hWndFrame, hwnd );
116
117                char buf[ 256 ];
118                if (strlen(appDate) >=1)
119                {
120                        snprintf( buf, sizeof buf, "%s %s (%s)", appName, appVersion, appDate );
121                } else
122                {
123                        snprintf( buf, sizeof buf, "%s %s", appName, appVersion );
124                }
125                WinSetDlgItemText( hwnd, IDT_LUCIDEVERSION, buf );
126
127                HPOINTER p = WinLoadPointer( HWND_DESKTOP, _hmod, IDP_HAND );
128                setLinkPointer( p );
129
130                toLink( WinWindowFromID( hwnd, IDC_NETLABSURL ) );
131
132                LONG cpr_clrback = SYSCLR_DIALOGBACKGROUND;
133                WinSetPresParam( WinWindowFromID( hwnd, IDC_COPYRIGHTS ),
134                                 PP_BACKGROUNDCOLORINDEX,
135                                 sizeof( cpr_clrback ), (PVOID)&cpr_clrback );
136
137                logoImageCreate( WinWindowFromID( hwnd, IDC_LOGO ) );
138            }
139            return (MRESULT)FALSE;
140    }
141    return WinDefDlgProc( hwnd, msg, mp1, mp2 );
142}
143
144
145void AboutBox( HWND _hWndFrame )
146{
147    hWndFrame = _hWndFrame;
148    WinDlgBox( HWND_DESKTOP, hWndFrame, AboutProc,
149               _hmod, IDD_ABOUT, NULL );
150}
151
152
153
Note: See TracBrowser for help on using the repository browser.