source: trunk/Lucide/SOURCE/gui/aboutDlg.cpp @ 242

Last change on this file since 242 was 138, checked in by Eugene Romanenko, 15 years ago

Better solution for #78, move GUI to DLL, executor sets BeginLibPath? and loads GUI DLL (closes #78)

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