📄 wdefordr.c
字号:
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include <windows.h>
#include <win1632.h>
#include <stdlib.h>
#include <string.h>
#include "wdeglbl.h"
#include "wdemem.h"
#include "wderesin.h"
#include "wdelist.h"
#include "wdedebug.h"
#include "wdefdiag.h"
#include "wdefont.h"
#include "wdeedit.h"
#include "wdefutil.h"
#include "wdestyle.h"
#include "wdefordr.h"
/****************************************************************************/
/* macro definitions */
/****************************************************************************/
#define TAG_FACENAME "Helv"
#define TAG_POINTSIZE 8
#define TAG_WIDTH 32
#define TAG_HEIGHT 17
/****************************************************************************/
/* external function prototypes */
/****************************************************************************/
extern LRESULT WINEXPORT WdeTagProc ( HWND, UINT, WPARAM, LPARAM );
/****************************************************************************/
/* type definitions */
/****************************************************************************/
/****************************************************************************/
/* static function prototypes */
/****************************************************************************/
/****************************************************************************/
/* external variables */
/****************************************************************************/
extern char WdeTagClass[] = "wdetag";
/****************************************************************************/
/* static variables */
/****************************************************************************/
static int WdeTagExtra = 0;
static WNDPROC WdeOriginalButtonProc = NULL;
static HINSTANCE WdeAppInst = NULL;
static HFONT WdeTagFont = NULL;
static void WdeSetTagState( WdeOrderedEntry *oe )
{
LRESULT result;
Bool pressed;
if( oe && ( oe->tag != (HWND)NULL ) ) {
if( oe->mode == WdeSetOrder ) {
result = SendMessage( oe->tag, BM_GETSTATE, 0, 0 );
pressed = ( ( result & 0x0004 ) != 0 );
if( pressed && !oe->pos_set ) {
SendMessage( oe->tag, BM_SETSTATE, FALSE, 0 );
} else if( !pressed && oe->pos_set ) {
SendMessage( oe->tag, BM_SETSTATE, TRUE, 0 );
}
} else {
SendMessage( oe->tag, BM_SETSTATE, FALSE, 0 );
}
}
}
static void WdeSetTagText( WdeOrderedEntry *oe )
{
char str[10];
int len;
if( oe && ( oe->tag != (HWND)NULL ) ) {
itoa( oe->pos, str, 10 );
len = strlen ( str );
switch( oe->mode ) {
case WdeSetTabs:
if( oe->tab_set ) {
strcat( str, ":T" );
}
break;
case WdeSetGroups:
if( oe->grp_set ) {
strcat( str, ":G" );
}
break;
}
SendMessage( oe->tag, WM_SETTEXT, 0, (LPARAM) (LPCSTR) str );
}
}
static void WdeSetTagOrder( WdeSetOrderStruct *o, Bool reorder )
{
if( o->new_oe ) {
ListRemoveElt( &o->lists->newlist, o->new_oe );
WdeMemFree( o->new_oe );
o->new_oe = NULL;
o->old_oe->present = TRUE;
o->old_oe->pos_set = FALSE;
} else {
o->new_oe = (WdeOrderedEntry *) WdeMemAlloc(sizeof(WdeOrderedEntry));
if( o->new_oe ) {
o->old_oe->pos_set = TRUE;
memcpy( o->new_oe, o->old_oe, sizeof ( WdeOrderedEntry ) );
o->old_oe->present = FALSE;
o->old_oe->pos = 0;
WdeInsertObject( &o->lists->newlist, o->new_oe );
}
}
if( reorder ) {
WdeReorderTags( o->lists, FALSE );
}
return;
}
static void WdeOrderPrevTags( WdeSetOrderStruct *o )
{
LIST *olist;
WdeOrderedEntry *oentry;
WdeSetOrderStruct *os;
if( o == NULL || o->lists == NULL ) {
return;
}
for( olist = o->lists->oldlist; olist; olist = ListNext( olist ) ) {
oentry = (WdeOrderedEntry *) ListElement( olist );
os = WdeGetTagInfo( oentry->tag );
if( os == o ) {
break;
}
if( !oentry->pos_set ) {
WdeSetTagOrder( os, FALSE );
}
}
return;
}
static void WdeTagDblClicked( WdeSetOrderStruct *o )
{
LIST *olist;
WdeOrderedEntry *oentry;
WdeSetOrderStruct *os;
if( o == NULL || o->lists == NULL ) {
return;
}
if( o->old_oe->mode != WdeSetOrder ) {
return;
}
if( o->lists->newlist ) {
WdeFreeOrderedList( o->lists->newlist );
o->lists->newlist = NULL;
}
for( olist = o->lists->oldlist; olist; olist = ListNext( olist ) ) {
oentry = (WdeOrderedEntry *) ListElement( olist );
oentry->present = TRUE;
oentry->pos_set = FALSE;
os = WdeGetTagInfo( oentry->tag );
if( os ) {
os->new_oe = NULL;
}
}
WdeTagPressed( o );
WdeReorderTags( o->lists, TRUE );
}
void WdeFreeOrderedList( LIST *l )
{
LIST *olist;
WdeOrderedEntry *oe;
for( olist = l; olist; olist = ListNext( olist ) ) {
oe = (WdeOrderedEntry *)ListElement( olist );
if( oe ) {
WdeMemFree( oe );
}
}
ListFree( l );
return;
}
LIST *WdeCopyOrderedList ( LIST *src )
{
LIST *dest;
dest = NULL;
if ( !WdeListConcat ( &dest, src, sizeof ( WdeOrderedEntry ) ) ) {
WdeFreeOrderedList ( dest );
dest = NULL;
}
return ( dest );
}
LIST *WdeFindOrderedEntry ( LIST *l, OBJPTR obj )
{
WdeOrderedEntry *oentry;
LIST *olist;
for ( olist = l; olist; olist = ListNext ( olist ) ) {
oentry = (WdeOrderedEntry *) ListElement ( olist );
if ( oentry->obj == obj ) {
return ( olist );
}
}
return ( NULL );
}
Bool WdeAddOrderedEntry ( LIST **l, OBJPTR obj )
{
WdeOrderedEntry *oentry;
LIST *olist;
if ( !l ) {
return ( FALSE );
}
if ( olist = WdeFindOrderedEntry ( *l, obj ) ) {
oentry = (WdeOrderedEntry *) ListElement ( olist );
oentry->present = TRUE;
return ( TRUE );
}
oentry = (WdeOrderedEntry *) WdeMemAlloc ( sizeof ( WdeOrderedEntry ) );
if ( oentry ) {
memset ( oentry, 0, sizeof ( WdeOrderedEntry ) );
oentry->obj = obj;
oentry->present = TRUE;
WdeInsertObject ( l, oentry );
}
return ( oentry != NULL );
}
Bool WdeRemoveOrderedEntry ( LIST *l, OBJPTR obj )
{
WdeOrderedEntry *oentry;
LIST *olist;
if ( olist = WdeFindOrderedEntry ( l, obj ) ) {
oentry = (WdeOrderedEntry *) ListElement ( olist );
oentry->present = FALSE;
return ( TRUE );
}
return ( FALSE );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -