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

Last change on this file since 452 was 438, checked in by dmik, 15 years ago

Brushed up r436:437.

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#include <string>
41
42#include "globals.h"
43#include "luutils.h"
44#include "lucide_res.h"
45
46extern "C" void setLinkPointer( HPOINTER hp );
47extern "C" void toLink( HWND hwnd );
48BOOL DrawTransparentBitmap( HAB hab, HPS hpsDraw, PPOINTL drawptl, HBITMAP hbmp );
49
50typedef struct
51{
52 PFNWP oldLogoProc;
53 HBITMAP image;
54} logoData;
55
56#define IMAGE_X 52
57#define IMAGE_Y 52
58
59static MRESULT EXPENTRY LogoProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
60{
61 logoData *ld = (logoData *)WinQueryWindowULong( hwnd, QWL_USER );
62 switch ( msg )
63 {
64 case WM_PAINT:
65 {
66 HPS hps;
67 RECTL rect;
68 WinQueryWindowRect( hwnd, &rect );
69 hps = WinBeginPaint( hwnd, 0L, 0L );
70 if ( ld->image != NULLHANDLE )
71 {
72 LONG xPos = ( rect.xRight - IMAGE_X ) / 2;
73 LONG yPos = ( rect.yTop - IMAGE_Y ) / 2;
74 POINTL ptl = { xPos, yPos };
75 DrawTransparentBitmap( hab, hps, &ptl, ld->image );
76 //WinDrawBitmap( hps, ld->image, NULL, &ptl, 0, 0, DBM_NORMAL );
77 }
78 WinEndPaint( hps );
79 }
80 return (MRESULT)FALSE;
81
82 case WM_DESTROY:
83 ld->oldLogoProc( hwnd, msg, mp1, mp2 );
84 if ( ld->image != NULLHANDLE ) {
85 GpiDeleteBitmap( ld->image );
86 }
87 free( ld );
88 return (MRESULT)FALSE;
89 }
90 return ld->oldLogoProc( hwnd, msg, mp1, mp2 );
91}
92
93void logoImageCreate( HWND hwnd )
94{
95 logoData *ld;
96 ld = (logoData *)malloc( sizeof( logoData ) );
97 memset( ld, 0, sizeof( logoData ) );
98 ld->oldLogoProc = WinSubclassWindow( hwnd, LogoProc );
99 WinSetWindowULong( hwnd, QWL_USER, (ULONG)ld );
100 HPS hps = WinGetPS( hwnd );
101 ld->image = GpiLoadBitmap( hps, _hmod, IDB_LOGO, 0, 0 );
102 WinReleasePS( hps );
103 WinInvalidateRect( hwnd, NULL, FALSE );
104}
105
106
107static HWND hWndFrame = NULLHANDLE;
108
109static MRESULT EXPENTRY AboutProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
110{
111 switch ( msg )
112 {
113 case WM_INITDLG:
114 {
115 localizeDialog( hwnd );
116 centerWindow( hWndFrame, hwnd );
117
118 std::string ver = appName;
119 (ver += ' ') += appVersion;
120 if ( strlen( appBuild ) > 0 ) {
121 (ver += ' ') += appBuild;
122 }
123 if ( strlen( appDate ) > 0 ) {
124 ((ver += " (") += appDate) += ')';
125 }
126 WinSetDlgItemText( hwnd, IDT_LUCIDEVERSION, ver.c_str() );
127
128 HPOINTER p = WinLoadPointer( HWND_DESKTOP, _hmod, IDP_HAND );
129 setLinkPointer( p );
130
131 toLink( WinWindowFromID( hwnd, IDC_NETLABSURL ) );
132
133 LONG cpr_clrback = SYSCLR_DIALOGBACKGROUND;
134 WinSetPresParam( WinWindowFromID( hwnd, IDC_COPYRIGHTS ),
135 PP_BACKGROUNDCOLORINDEX,
136 sizeof( cpr_clrback ), (PVOID)&cpr_clrback );
137
138 logoImageCreate( WinWindowFromID( hwnd, IDC_LOGO ) );
139 }
140 return (MRESULT)FALSE;
141 }
142 return WinDefDlgProc( hwnd, msg, mp1, mp2 );
143}
144
145
146void AboutBox( HWND _hWndFrame )
147{
148 hWndFrame = _hWndFrame;
149 WinDlgBox( HWND_DESKTOP, hWndFrame, AboutProc,
150 _hmod, IDD_ABOUT, NULL );
151}
152
153
154
Note: See TracBrowser for help on using the repository browser.