📄 ebcontrol.c
字号:
// $Id: ebcontrol.c,v 1.1.1.1 2005/01/18 11:47:58 tangjb Exp $
//
// edit.c: the Single Line Edit Control module.
//
// Copyright (C) 1999, 2000, 2001, 2002 Wei Yongming.
//
// Current maintainer: Wei Yongming.
//
/*
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library 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
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the Free
** Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
** MA 02111-1307, USA
*/
/*
** Alternatively, the contents of this file may be used under the terms
** of the Mozilla Public License (the "MPL License") in which case the
** provisions of the MPL License are applicable instead of those above.
*/
// Note:
// Although there was a version by Zhao Jianghua, this version of
// EDIT control is written by Wei Yongming from scratch.
//
// Create date: 1999/8/26
//
// Modify records:
//
// Who When Where For What Status
//-----------------------------------------------------------------------------
// WEI Yongming 2000/02/24 Tsinghua Add MPL License Finished
//
//
// TODO:
// * Selection.
// * Undo.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
static int ebinit_count = 0;
extern BOOL RegisterBmpButtonControl (void);
extern void BmpButtonControlCleanup (void);
extern BOOL RegisterEBEditControl (void);
extern void EBEditControlCleanup (void);
extern BOOL RegisterEBListViewControl (void);
extern void EBListViewControlCleanup (void);
extern BOOL RegisterEBProgressBarControl (void);
extern void EBProgressBarControlCleanup (void);
extern BOOL RegisterEBStaticControl (void);
extern void EBStaticControlCleanup (void);
extern BOOL RegisterEBTrackBarControl (void);
extern void EBTrackBarControlCleanup (void);
//add by tjb
extern BOOL RegisterEBCheckBoxControl (void);
extern void EBCheckboxControlCleanup (void);
extern BOOL RegisterPlayGifControl(void);
extern void PlayGifControlCleanup(void);
//add by srz
extern BOOL RegisterEBFlashplayerControl (void);
extern void EBFlashplayerControlCleanup (void);
BOOL InitEbControl ( void )
{
if (ebinit_count > 0)
goto success;
if (!RegisterBmpButtonControl ()) {
return FALSE;
}
if (!RegisterEBEditControl ()) {
BmpButtonControlCleanup ();
return FALSE;
}
if(!RegisterEBListViewControl())
{
BmpButtonControlCleanup ();
EBEditControlCleanup ();
return FALSE;
}
if(!RegisterEBProgressBarControl())
{
BmpButtonControlCleanup ();
EBEditControlCleanup ();
EBListViewControlCleanup ();
return FALSE;
}
if(!RegisterEBStaticControl())
{
BmpButtonControlCleanup ();
EBEditControlCleanup ();
EBListViewControlCleanup ();
EBProgressBarControlCleanup();
return FALSE;
}
if(!RegisterEBTrackBarControl())
{
BmpButtonControlCleanup ();
EBEditControlCleanup ();
EBListViewControlCleanup ();
EBProgressBarControlCleanup();
EBStaticControlCleanup();
return FALSE;
}
if (! RegisterEBCheckBoxControl())
{
BmpButtonControlCleanup ();
EBEditControlCleanup ();
EBListViewControlCleanup ();
EBProgressBarControlCleanup();
EBStaticControlCleanup();
EBTrackBarControlCleanup();
return FALSE;
}
if (! RegisterEBMLEditControl())
{
BmpButtonControlCleanup ();
EBEditControlCleanup ();
EBListViewControlCleanup ();
EBProgressBarControlCleanup();
EBStaticControlCleanup();
EBTrackBarControlCleanup();
EBCheckboxControlCleanup();
return FALSE;
}
if (! RegisterEBFlashplayerControl())
{
BmpButtonControlCleanup ();
EBEditControlCleanup ();
EBListViewControlCleanup ();
EBProgressBarControlCleanup();
EBStaticControlCleanup();
EBTrackBarControlCleanup();
EBCheckboxControlCleanup();
EBMLEditControlCleanup();
return FALSE;
}
if (! RegisterPlayGifControl())
{
BmpButtonControlCleanup ();
EBEditControlCleanup ();
EBListViewControlCleanup ();
EBProgressBarControlCleanup();
EBStaticControlCleanup();
EBTrackBarControlCleanup();
EBCheckboxControlCleanup();
EBMLEditControlCleanup();
EBFlashplayerControlCleanup();
return FALSE;
}
success:
ebinit_count ++;
return TRUE;
}
void EbControlCleanUp (void)
{
ebinit_count --;
if (ebinit_count != 0)
return;
BmpButtonControlCleanup ();
EBEditControlCleanup ();
EBListViewControlCleanup ();
EBProgressBarControlCleanup();
EBStaticControlCleanup();
EBTrackBarControlCleanup();
EBCheckboxControlCleanup();
EBMLEditControlCleanup();
EBFlashplayerControlCleanup();
PlayGifControlCleanup();
}
void CtrlDrawPictrueToBK(HDC hdc, RECT * rect, const char * picname, int bmtype, int alpha)
{
PBITMAP pbmp;
if (picname != NULL)
{
pbmp = malloc(sizeof(BITMAP));
if (pbmp == NULL)
{
printf(" CtrlDrawPictrueToBK() malloc failed! \n");
return;
}
if ( LoadBitmap(hdc, pbmp, picname) < 0 )
{
printf(" CtrlDrawPictrueToBK() LoadBitmap failed! \n");
return;
}
pbmp->bmType = bmtype;
if (bmtype & BMP_TYPE_COLORKEY)//transparent bitmap
{
pbmp->bmColorKey = GetPixelInBitmap (pbmp, 0, 0);
}
else if (bmtype & BMP_TYPE_ALPHACHANNEL)//Alpha Blended Bitmaps
{
pbmp->bmAlpha = alpha;
}
else if ((bmtype & BMP_TYPE_COLORKEY) &&
(bmtype & BMP_TYPE_ALPHACHANNEL))//Alpha Blended Transparent Bitmap
{
pbmp->bmColorKey = GetPixelInBitmap (pbmp, 0, 0);
pbmp->bmAlpha = alpha;
}
FillBoxWithBitmap(hdc, 0, 0, rect->right-rect->left,
rect->bottom-rect->top, pbmp);
UnloadBitmap(pbmp);
free(pbmp);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -