2001-09-09 15:48 GMT+2 Maurilio Longo <maurilio.longo@libero.it>

+ contrib/hgf/os2pm/winctrl.prg
     + added
   + contrib/hgf/os2pm/button.prg
     + added
   + contrib/hgf/os2pm/edit.prg
     + added
   * contrib/hgf/os2pm/Makefile
     + added new files
   * contrib/hgf/os2pm/os2pm.c
     * modified and added new functions already added to win32.c
   * contrib/hgf/os2pm/os2pm.ch
     - removed all defines which are not currently needed, this makes
       os2pm.ch smaller and faster to compile.
This commit is contained in:
Maurilio Longo
2001-09-09 13:53:22 +00:00
parent c1b4099607
commit 0256691709
10 changed files with 958 additions and 5705 deletions

View File

@@ -1,3 +1,18 @@
2001-09-09 15:48 GMT+2 Maurilio Longo <maurilio.longo@libero.it>
+ contrib/hgf/os2pm/winctrl.prg
+ added
+ contrib/hgf/os2pm/button.prg
+ added
+ contrib/hgf/os2pm/edit.prg
+ added
* contrib/hgf/os2pm/Makefile
+ added new files
* contrib/hgf/os2pm/os2pm.c
* modified and added new functions already added to win32.c
* contrib/hgf/os2pm/os2pm.ch
- removed all defines which are not currently needed, this makes
os2pm.ch smaller and faster to compile.
2001-09-08 12:01 UTC-0800 Brian Hays <bhays@abacuslaw.com>
- hb_slex.bc
Removed unneeded file since Simplex uses makefile.bc now

View File

@@ -11,6 +11,9 @@ PRG_SOURCES=\
tform.prg \
tmenu.prg \
tmenuitm.prg \
winctrl.prg \
button.prg \
edit.prg \
LIBNAME=os2pm

View File

@@ -0,0 +1,93 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Harbour GUI framework for IBM OS/2 Presentation Manager
* Class HBButton
*
* Copyright 2001 Antonio Linares <alinares@fivetech.com>
* Copyright 2001 Maurilio Longo <maurilio.longo@libero.it>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#include "common.ch"
#include "hbclass.ch"
#include "os2pm.ch"
// NOTE: Be sure they are the same
#define WS_CHILD WS_DISABLED //0x40000000
CLASS HBButton FROM HBWinControl
DATA OnClick PROPERTY
METHOD New( oContainer )
ENDCLASS
METHOD New( oContainer ) CLASS HBButton
::hWnd = WinCreateWindow(oContainer:hWndClient,; /* Parent window */
WC_BUTTON,; /* Class window */
"",; /* Button text */
WS_VISIBLE + WS_TABSTOP+; /* Visible style */
BS_PUSHBUTTON + BS_AUTOSIZE,; /* Button style */
0, 0,; /* x, y */
80, 30,; /* cx, cy */
oContainer:hWndClient,; /* Owner window */
HWND_TOP,; /* Top of z-order */
::GetNewId(),; /* Identifier */
nil,; /* Control data */
nil) /* parameters */
// NOTE: There is no need to modify it later since I can give it an initial
// size during window creartion
//::Width = 80
//::Height = 25
return Self

View File

@@ -0,0 +1,83 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Harbour GUI framework for IBM OS/2 Presentation Manager
* Class HBEdit
*
* Copyright 2001 Antonio Linares <alinares@fivetech.com>
* Copyright 2001 Maurilio Longo <maurilio.longo@libero.it>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#include "common.ch"
#include "hbclass.ch"
#include "os2pm.ch"
CLASS HBEdit FROM HBWinControl
METHOD New( oContainer )
ENDCLASS
METHOD New( oContainer ) CLASS HBEdit
::hWnd = WinCreateWindow(oContainer:hWndClient,; /* Parent window */
WC_ENTRYFIELD,; /* Class window */
"",; /* Button text */
WS_VISIBLE + WS_TABSTOP+; /* Visible style */
ES_MARGIN,; /* window style */
0, 0,; /* x, y */
121, 21,; /* cx, cy */
oContainer:hWndClient,; /* Owner window */
HWND_TOP,; /* Top of z-order */
::GetNewId(),; /* Identifier */
nil,; /* Control data */
nil) /* parameters */
//::Width = 121
//::Height = 21
return Self

View File

@@ -59,29 +59,50 @@
#include <os2.h>
#include "hbapi.h"
#include "hbvm.h"
#include "hbstack.h"
#define LOWORD(l) ((USHORT)l)
#define HIWORD(l) ((USHORT)((ULONG)l >> 16))
HAB hb_pm_GetHab( void );
MRESULT EXPENTRY WndProc( HWND, ULONG, MPARAM, MPARAM );
MRESULT EXPENTRY WindowProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
MRESULT EXPENTRY WndProc( HWND hWnd, ULONG Msg, MPARAM mp1, MPARAM mp2 )
{
static PHB_DYNS pDynSym = 0;
HPS hps;
switch( msg )
{
case WM_ERASEBACKGROUND:
return FALSE;
if( ! pDynSym )
pDynSym = hb_dynsymFind( "HB_GUI" );
switch (Msg) {
case WM_PAINT:
hps = WinBeginPaint( hwnd, 0L, NULL );
GpiErase( hps );
WinEndPaint( hps );
return 0;
{
hps = WinBeginPaint( hWnd, 0L, NULL );
GpiErase( hps );
WinEndPaint( hps );
return 0;
}
}
default:
{
hb_vmPushSymbol( pDynSym->pSymbol );
hb_vmPushNil();
hb_vmPushLong( (LONG) hWnd );
hb_vmPushLong( (LONG) Msg );
hb_vmPushLong( (LONG) mp1 );
hb_vmPushLong( (LONG) mp2 );
hb_vmDo( 4 );
if( hb_arrayGetType( &hb_stack.Return, 1 ) == HB_IT_NIL )
return WinDefWindowProc( hWnd, Msg, mp1, mp2 );
else
return (MRESULT) hb_parnl( -1, 1 );
}
}
return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}
@@ -90,7 +111,7 @@ HB_FUNC( WINREGISTERCLASS )
hb_retl( WinRegisterClass( hb_pm_GetHab(), /* anchor block handle */
hb_parc( 1 ), /* Class Name */
( PFNWP ) WindowProc, /* default Class procedure */
( PFNWP ) WndProc, /* default Class procedure */
hb_parnl( 2 ), /* style */
hb_parnl( 3 ) ) ); /* extra bytes */
}
@@ -98,47 +119,52 @@ HB_FUNC( WINREGISTERCLASS )
HB_FUNC(WINCREATEWINDOW)
{
hb_retnl((LONG) WinCreateWindow( (HWND) hb_parnl(1), /* hWnd parent */
(PCSZ) hb_parc(2), /* pszClass */
(PCSZ) hb_parc(3), /* pszName */
(ULONG) hb_parnl(4), /* flStyle */
(LONG) hb_parnl(5), /* x */
(LONG) hb_parnl(6), /* y */
(LONG) hb_parnl(7), /* cx */
(LONG) hb_parnl(8), /* cy */
(HWND) hb_parnl(9), /* hwndOwner */
(HWND) hb_parnl(10), /* hwndInsertBehind */
(ULONG) hb_parnl(11), /* id */
(PVOID) hb_parnl(12), /* pCtlData, */
(PVOID) hb_parnl(13))); /* pPresParams */
HWND hwnd;
hwnd = WinCreateWindow( (HWND) hb_parnl(1), /* hWnd parent */
(PCSZ) hb_parc(2), /* pszClass */
(PCSZ) hb_parc(3), /* pszName */
(ULONG) hb_parnl(4), /* flStyle */
(LONG) hb_parnl(5), /* x */
(LONG) hb_parnl(6), /* y */
(LONG) hb_parnl(7), /* cx */
(LONG) hb_parnl(8), /* cy */
(HWND) hb_parnl(9), /* hwndOwner */
(HWND) hb_parnl(10), /* hwndInsertBehind */
(ULONG) hb_parnl(11), /* id */
(PVOID) hb_parnl(12), /* pCtlData, */
(PVOID) hb_parnl(13)); /* pPresParams */
hb_retnl((LONG) hwnd);
}
HB_FUNC( WINCREATESTDWINDOW )
{
ULONG lFrame = hb_parnl( 3 );
HWND hWndClient;
HWND hWndClient, hWndFrame;
hb_retnl( ( LONG ) WinCreateStdWindow( ( HWND ) hb_parnl( 1 ), /* hWndParent */
hb_parnl( 2 ), /* style */
&lFrame, /* lFrame */
hb_parc( 4 ), /* cClassName */
hb_parc( 5 ), /* cCaption */
hb_parnl( 6 ), /* lStyleClient */
hb_parnl( 7 ), /* hModule */
hb_parnl( 8 ), /* nId */
( PHWND ) &hWndClient ) ); /* Window client handle */
hWndFrame = WinCreateStdWindow( ( HWND ) hb_parnl( 1 ), /* hWndParent */
hb_parnl( 2 ), /* style */
&lFrame, /* lFrame */
hb_parc( 4 ), /* cClassName */
hb_parc( 5 ), /* cCaption */
hb_parnl( 6 ), /* lStyleClient */
hb_parnl( 7 ), /* hModule */
hb_parnl( 8 ), /* nId */
( PHWND ) &hWndClient ); /* Window client handle */
hb_retnl( (LONG) hWndFrame);
hb_stornl( ( LONG ) hWndClient, 9 );
}
HB_FUNC( HB_PM_SHOWMODAL )
HB_FUNC( HB_FORMSHOWMODAL )
{
QMSG qmsg;
HAB hab = hb_pm_GetHab();
WinShowWindow( ( HWND ) hb_parnl( 1 ), 1 );
while( WinGetMsg( hab, &qmsg, 0, 0, 0 ) )
{
WinDispatchMsg( hab, &qmsg );
@@ -200,8 +226,7 @@ HB_FUNC( GETHAB )
HB_FUNC( WINCREATEMENU )
{
hb_retnl( ( LONG ) WinCreateMenu( ( HWND ) hb_parnl( 1 ),
(PVOID) NULL /*( PVOID ) hb_parnl( 2 )*/ ) );
hb_retnl( (LONG) WinCreateMenu((HWND) hb_parnl(1), (PVOID) NULL));
}
@@ -265,7 +290,7 @@ HB_FUNC( WINSETOWNER )
HB_FUNC( WINSENDMSG )
{
hb_retnl( ( LONG ) WinSendMsg( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ),
hb_retnl( ( LONG ) WinSendMsg( ( HWND ) hb_parnl( 1 ), hb_parnl( 2 ),
( MPARAM ) IF( ISCHAR( 3 ), (ULONG) hb_parc( 3 ), hb_parnl( 3 ) ),
( MPARAM ) IF( ISCHAR( 4 ), (ULONG) hb_parc( 4 ), hb_parnl( 4 ) ) ) );
}
@@ -291,3 +316,114 @@ HB_FUNC( WINSETWIDTH )
swp.y, (LONG) hb_parnl( 2 ), swp.cy,
SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER );
}
HB_FUNC( SENDMESSAGE )
{
hb_retnl( (LONG) WinSendMsg(
(HWND) hb_parnl( 1 ), // handle of destination window
(ULONG) hb_parnl( 2 ), // message to send
(MPARAM) hb_parnl( 3 ), // first message parameter
(MPARAM) hb_parnl( 4 ) // second message parameter
) );
}
HB_FUNC( NLOWORD )
{
hb_retnl( LOWORD( hb_parnl( 1 ) ) );
}
HB_FUNC( NHIWORD )
{
hb_retnl( HIWORD( hb_parnl( 1 ) ) );
}
HB_FUNC( WINGETHEIGHT )
{
HWND hWnd = ( HWND ) hb_parnl( 1 );
RECTL rct;
WinQueryWindowRect( hWnd, &rct );
hb_retnl( rct.yBottom - rct.yTop );
}
HB_FUNC( WINSETHEIGHT )
{
HWND hWnd = ( HWND ) hb_parnl( 1 );
SWP swp;
WinQueryWindowPos( hWnd, &swp );
WinSetWindowPos( hWnd, HWND_TOP, swp.x,
swp.y, swp.cx, hb_parnl( 2 ),
SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER );
}
HB_FUNC( WINGETTOP )
{
HWND hWnd = ( HWND ) hb_parnl( 1 );
RECTL rct;
WinQueryWindowRect( hWnd, &rct );
hb_retnl( rct.yTop );
}
HB_FUNC( WINSETTOP )
{
HWND hWnd = ( HWND ) hb_parnl( 1 );
SWP swp;
WinQueryWindowPos( hWnd, &swp );
WinSetWindowPos( hWnd, HWND_TOP, hb_parnl( 2 ),
swp.y, swp.cx, swp.cy,
SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER );
}
HB_FUNC( WINGETLEFT )
{
HWND hWnd = ( HWND ) hb_parnl( 1 );
RECTL rct;
WinQueryWindowRect( hWnd, &rct );
hb_retnl( rct.xLeft );
}
HB_FUNC( WINSETLEFT )
{
HWND hWnd = ( HWND ) hb_parnl( 1 );
SWP swp;
WinQueryWindowPos( hWnd, &swp );
WinSetWindowPos( hWnd, HWND_TOP, swp.x,
hb_parnl( 2 ), swp.cx, swp.cy,
SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER );
}
HB_FUNC( POSTQUITMESSAGE )
{
WinPostMsg((HWND) hb_parnl( 1 ), WM_QUIT, 0L, 0L);
//PostQuitMessage( hb_parnl( 1 ) );
}
HB_FUNC( SHOWWINDOW )
{
hb_retl( WinShowWindow( ( HWND ) hb_parnl( 1 ), hb_parl( 2 ) ) );
}
HB_FUNC( WINGETLASTERROR )
{
hb_retnl((LONG) WinGetLastError( hb_pm_GetHab() ) );
}

File diff suppressed because it is too large Load Diff

View File

@@ -57,69 +57,158 @@
#include "hbclass.ch"
#include "os2pm.ch" // Needed to store some OS/2 PM constant values
CLASS TForm
DATA hWnd
DATA oMainMenu
// Win32 compatibility Message redefinition
#define WM_LBUTTONDOWN WM_BUTTON1DOWN
static aForms := {}
CLASS HBForm FROM HBWinControl
DATA oMainMenu
DATA OnClick PROPERTY
DATA aControls PROPERTY
CLASSDATA lRegistered
METHOD New()
METHOD Close() INLINE SendMessage( ::hWnd, WM_CLOSE )
METHOD Command( nNotifyCode, nId, hWndCtl )
METHOD HandleEvent( nMsg, nParam1, nParam2 )
METHOD InsertControl( oControl )
METHOD LButtonDown( nKeyFlags, nXPos, nYPos )
METHOD ShowModal()
ACCESS cCaption() INLINE WinGetText( ::hWnd )
ASSIGN cCaption( cNewCaption ) INLINE ;
WinSetWindowText( ::hWnd, cNewCaption )
ACCESS oMenu() INLINE ::oMainMenu
ASSIGN oMenu( oNewMenu )
ACCESS nWidth() INLINE WinGetWidth( ::hWnd )
ASSIGN nWidth( nNewWidth ) INLINE ;
WinSetWidth( ::hWnd, nNewWidth )
ACCESS Menu() INLINE ::oMainMenu PROPERTY
ASSIGN Menu( oNewMenu )
ENDCLASS
METHOD New() CLASS TForm
METHOD New() CLASS HBForm
local hWndClient
local hWC
DEFAULT ::lRegistered TO .f.
if ! ::lRegistered
if ! ::lRegistered
// Notice that this code may be moved to a method Register()
// so we hide again the OS API details
WinRegisterClass( "HB_TFORM",;
(CS_SIZEREDRAW + 0x2000001), 0 )
WinRegisterClass("HB_HBForm", CS_SIZEREDRAW, 0, 0 )
::lRegistered = .t.
endif
// Again this code may be moved to a method Create() to hide the
// OS API details
::hWnd = WinCreateStdWindow( HWND_DESKTOP,;
WS_VISIBLE,;
(FCF_TITLEBAR + FCF_SYSMENU +;
FCF_SIZEBORDER + FCF_TASKLIST +;
FCF_MINMAX + FCF_SHELLPOSITION ),;
"HB_TFORM", "Harbour TForm",;
"HB_HBForm", "Harbour HBForm",;
(WS_SYNCPAINT + WS_VISIBLE ),,,;
@hWndClient ) // Not used yet
@hWC )
::hWndClient := hWC
AAdd(aForms, Self)
return Self
METHOD ShowModal() CLASS TForm
METHOD Command( nNotifyCode, nId, hWndCtl ) CLASS HBForm
HB_PM_ShowModal()
local oMenuItem, nAt, oControl
do case
case nNotifyCode == CMDSRC_MENU // Menu command
if ::Menu != nil
if( oMenuItem := ::Menu:FindItem( nId ) ) != nil
if oMenuItem:OnClick != nil
__ObjSendMsg( Self, oMenuItem:OnClick, oMenuItem )
endif
endif
endif
case nNotifyCode == CMDSRC_PUSHBUTTON
nAt = AScan( ::aControls, { | o | o:nId == nId } )
if nAt != 0
oControl = ::aControls[ nAt ]
if oControl:OnClick != nil
__ObjSendMsg( Self, oControl:OnClick, oControl )
endif
endif
otherwise
endcase
return nil
ASSIGN oMenu( oNewMenu ) CLASS TForm
METHOD InsertControl( oControl ) CLASS HBForm
DEFAULT ::aControls TO {}
AAdd( ::aControls, oControl )
oControl:Show()
return nil
METHOD LButtonDown( nKeyFlags, nXPos, nYPos ) CLASS HBForm
if ::OnClick != nil
return __ObjSendMsg( Self, ::OnClick, Self, nXPos, nYPos )
endif
return nil
METHOD HandleEvent( nMsg, nParam1, nParam2 ) CLASS HBForm
do case
case nMsg == WM_COMMAND
/*
param1
USHORT uscmd // Command value.
param2
USHORT ussource // Source type.
USHORT uspointer // Pointer-device indicator.
returns
ULONG ulReserved // Reserved value, should be 0.
*/
::Command( nLoWord( nParam2 ), nLoWord( nParam1 ), nil )
return 0
case nMsg == WM_LBUTTONDOWN
/*
param1
POINTS ptspointerpos // Pointer position.
param2
USHORT fsHitTestres // Hit-test result.
USHORT fsflags // Keyboard control codes.
returns
BOOL rc // Processed indicator.
*/
return ::LButtonDown( nHiWord(nParam2), nLoWord( nParam1 ), nHiWord( nParam1 ) )
case nMsg == WM_DESTROY
PostQuitMessage( 0 )
return 0
endcase
return nil
METHOD ShowModal() CLASS HBForm
HB_FormShowModal(::hWnd)
return nil
ASSIGN Menu( oNewMenu ) CLASS HBForm
::oMainMenu := oNewMenu
@@ -128,3 +217,16 @@ ASSIGN oMenu( oNewMenu ) CLASS TForm
WinSendMsg( ::hWnd, WM_UPDATEFRAME, FCF_MENU, 0 )
return nil
function HB_GUI( hWnd, nMsg, nParam1, nParam2 ) // messages entry point
static aReturn := { nil, nil }
local nForm := AScan( aForms, { | oForm | oForm:hWndClient == hWnd } )
if nForm != 0
aReturn[ 1 ] = aForms[ nForm ]:HandleEvent( nMsg, nParam1, nParam2 )
endif
return aReturn

View File

@@ -57,34 +57,55 @@
#include "os2pm.ch"
CLASS TMenu
CLASS HBMenu FROM HBPersistent
DATA nHandle // Handle of MIS_ACTIONBAR
DATA aItems // Items inside this menu
DATA oParent // Parent/Owner of menu
DATA nHandle // Handle of MIS_ACTIONBAR
DATA Items PROPERTY // Items inside this menu
METHOD New(oForm)
METHOD Add(oMenuItem)
METHOD FindItem( nId ) // Searches for a sub menuitem given its id
ENDCLASS
METHOD New( oForm ) CLASS TMenu
METHOD New( oForm ) CLASS HBMenu
::aItems := {}
::oParent := oForm
::nHandle := WinCreateMenu( oForm:hWnd )
::Items := {}
if oForm != nil
::nHandle = WinCreateMenu( oForm:hWnd )
endif
return Self
METHOD Add( oMenuItem ) CLASS TMenu
METHOD Add( oMenuItem ) CLASS HBMenu
WinAddMenuItem( ::nHandle, oMenuItem:cCaption, MIT_END,;
nil, oMenuItem:nId, oMenuItem:lEnabled )
WinAddMenuItem( ::nHandle, oMenuItem:Caption, MIT_END,;
nil, oMenuItem:nId, oMenuItem:Enabled )
AAdd( ::aItems, oMenuItem )
AAdd( ::Items, oMenuItem )
return nil
METHOD FindItem( nId ) CLASS HBMenu
local oMenuItem, n
for n = 1 to Len( ::Items )
if ( oMenuItem := ::Items[ n ] ):nId == nId
return oMenuItem
else
if oMenuItem:Items != nil
if ( oMenuItem := oMenuItem:FindItem( nId ) ) != nil
return oMenuItem
endif
endif
endif
next
return oMenuItem

View File

@@ -58,40 +58,44 @@
#include "os2pm.ch"
CLASS TMenuItem
DATA cCaption // Specifies the text of the menu item
DATA OnClick // A character description of the method to invoke
DATA nId // Command value to send to the container form
DATA lEnabled // Specifies whether the menu item is enabled
CLASS HBMenuItem FROM HBPersistent
DATA aItems // Contains the menu items in the submenu of the menu item
DATA oParent // Identifies the parent menu item of this menu item
DATA nHandle // The handle of submenu window (if there is any)
DATA Caption PROPERTY // Specifies the text of the menu item
DATA Name PROPERTY // The name of this component
DATA OnClick PROPERTY // A character description of the method to invoke
DATA Enabled PROPERTY // Specifies whether the menu item is enabled
DATA Items PROPERTY // Contains the menu items in the submenu of the menu item
CLASSDATA nIdStart // start value for commands value to assign to menu items
DATA nId // Command value to send to the container form
DATA oParent // Identifies the parent menu item of this menu item
DATA nHandle // The handle of the submenu of this menu item
METHOD New( oOwner ) // Creates a new menu item
METHOD Add( oMenuItem ) // Adds a new drop down menu item
CLASSDATA nIdStart // start value for commands value to assign to menu items
METHOD New( oOwner ) // Creates a new menu item
METHOD Add( oMenuItem ) // Adds a new drop down menu item
METHOD FindItem( nId ) // Searches for a sub menuitem given its id
ENDCLASS
METHOD New( oOwner ) CLASS TMenuItem
METHOD New( oOwner ) CLASS HBMenuItem
DEFAULT ::nIdStart TO 110
::cCaption = ""
::nId = ::nIdStart++
::lEnabled = .t.
::oParent = oOwner
::Caption = ""
::nId = ::nIdStart++
::Enabled = .t.
::oParent = oOwner
::nHandle = nil
return Self
METHOD Add( oMenuItem ) CLASS TMenuItem
METHOD Add( oMenuItem ) CLASS HBMenuItem
DEFAULT ::aItems TO {}
DEFAULT ::Items TO {}
if ::nHandle == nil
::nHandle := WinCreateMenu( ::oParent:nHandle )
@@ -99,14 +103,31 @@ METHOD Add( oMenuItem ) CLASS TMenuItem
endif
WinAddMenuItem(::nHandle, oMenuItem:cCaption, MIT_END,;
nil, oMenuItem:nId, oMenuItem:lEnabled )
WinAddMenuItem(::nHandle, oMenuItem:Caption, MIT_END,;
nil, oMenuItem:nId, oMenuItem:Enabled )
AAdd( ::aItems, oMenuItem )
AAdd( ::Items, oMenuItem )
return nil
METHOD FindItem( nId ) CLASS HBMenuItem
local oMenuItem, n
for n = 1 to Len( ::Items )
if ( oMenuItem := ::Items[ n ] ):nId == nId
return oMenuItem
else
if oMenuItem:Items != nil
if ( oMenuItem := oMenuItem:FindItem( nId ) ) != nil
return oMenuItem
endif
endif
endif
next
return oMenuItem

View File

@@ -0,0 +1,95 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Harbour GUI framework for IBM OS/2 Presentation Manager
* Class HBWinControl
*
* Copyright 2001 Antonio Linares <alinares@fivetech.com>
* Copyright 2001 Maurilio Longo <maurilio.longo@libero.it>
* www - http://www.harbour-project.org
*
* Copyright 2001 Antonio Linares <alinares@fivetech.com>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#include "common.ch"
#include "hbclass.ch"
// NOTE: What does this define do under Win32?
#define SW_SHOWNA 8
CLASS HBWinControl FROM HBPersistent
DATA hWnd // Frame Window Handle
DATA hWndClient // Client Window Handle
DATA nId
CLASSDATA nInitId
ACCESS Caption() INLINE WinGetText( ::hWnd ) PROPERTY
ASSIGN Caption( cNewCaption ) INLINE ;
WinSetWindowText( ::hWnd, cNewCaption )
ACCESS Top() INLINE WinGetTop( ::hWnd ) PROPERTY
ASSIGN Top( nNewTop ) INLINE WinSetTop( ::hWnd, nNewTop )
ACCESS Left() INLINE WinGetLeft( ::hWnd ) PROPERTY
ASSIGN Left( nNewLeft ) INLINE WinSetLeft( ::hWnd, nNewLeft )
ACCESS Height() INLINE WinGetHeight( ::hWnd ) PROPERTY
ASSIGN Height( nNewHeight ) INLINE WinSetHeight( ::hWnd, nNewHeight )
ACCESS Width() INLINE WinGetWidth( ::hWnd ) PROPERTY
ASSIGN Width( nNewWidth ) INLINE WinSetWidth( ::hWnd, nNewWidth )
METHOD GetNewId() INLINE ::nId := If( ::nInitId == nil, ::nInitId := 1,;
++::nInitId )
METHOD Show() INLINE ShowWindow( ::hWnd, .T. /*SW_SHOWNA*/ )
ENDCLASS