📄 asix_mn.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "asixwin.h"
#include "asixapp.h"
#include "keydef.h"
//#include <bitmap.h>
//#include <hc.h>
#include "disp.h"
#include "asix_mn.h"
#include "xasixmn.h"
#include "gpc.h"
//static const U8 menu_down[] = {0xff,0xff,0xf7,0xf9,0xfe,0x3f,0xf,0xc1,0xe0,0x78,0xc,0x3,0x2,0x00};
//static const U8 menu_up[] = {0xc,0x3,0x1,0xe0,0x78,0x3f,0xf,0xc7,0xf9,0xfe,0xff,0xff,0xf2,0x00};
static const U8 menu_down7x7[] = {
// 头信息
0x42,0x4D, // 位图的标识符('BM')
0x07,0x00, // 位图的宽度(7 pixels)
0x07,0x00, // 位图的高度(7 pixels)
0x01, // 位图的像素深度(1 bits/pixel)
0x00, // 位图的状态标志位
// |7|6|5|4|3|2|1|0|
// 0位:使用系统调色板
// 1位:不使用压缩算法
0x02,0x00,0x00,0x00, // 位图实际使用到的颜色数(2 colors)
0x10,0x00,0x00,0x00, // 数据区的偏移量(16 bytes)
// 数据区
0xff,0xfd,0xf3,0xe3,0x87,0x4,0x20
};
static const U8 menu_up7x7[] = {
// 头信息
0x42,0x4D, // 位图的标识符('BM')
0x07,0x00, // 位图的宽度(7 pixels)
0x07,0x00, // 位图的高度(7 pixels)
0x01, // 位图的像素深度(1 bits/pixel)
0x00, // 位图的状态标志位
// |7|6|5|4|3|2|1|0|
// 0位:使用系统调色板
// 1位:不使用压缩算法
0x02,0x00,0x00,0x00, // 位图实际使用到的颜色数(2 colors)
0x10,0x00,0x00,0x00, // 数据区的偏移量(16 bytes)
// 数据区
0x10,0x70,0xe3,0xe7,0xdf,0xff,0xa0
};
static STATUS menu_calculate( struct MENU_STRUCTURE *p_str );
static STATUS menu_hide( struct MENU_STRUCTURE *p_str );
static STATUS menu_show( struct MENU_STRUCTURE *p_str );
static STATUS menu_drawicon( U16 cycle, struct MENU_STRUCTURE *p_str, U8 flag );
static STATUS menu_cutstring( char * string_input, U8 n, char * dispbuf );
/**********************************************************************/
/*显示弹出框************************************************************/
static STATUS menu_show( struct MENU_STRUCTURE *p_str )
{
//struct MENU_ITEM * p_input = p_str->menu_item;
// U8 i=0;
U8 cycle=0;
U32 pGC;
U16 cursor_status;
if ( p_str->pop_status == POP_SHOW ) return ASIX_ERROR;
menu_calculate( p_str );
// bitmap pixel is 2 bytes
// p_str->menu_coveredmap = (U8 *)Lcalloc( (p_str->pop_width+2)*(p_str->pop_height+2)*2 + 2);//by zl 2002.3.19
// p_str->menu_coveredmap = (U8 *)Lcalloc( (p_str->pop_width) * (p_str->pop_height) * 2 + 2);
p_str->menu_coveredmap = (U8 *)GetBlock( p_str->pop_width, p_str->pop_height );
if (p_str->menu_coveredmap == NULL)
{
ActiveAreaDisable( (p_str->menu_start).icon_id );
Lfree((void *)p_str->menu_item);
// longn_qi 2002/01/25 for monitor memory leak
asix_mn_memdbgprintf( "asix_mn free mem of its menu item" );
Lfree((void *)p_str);
// longn_qi 2002/01/25 for monitor memory leak
asix_mn_memdbgprintf( "asix_wn free mem of itself" );
PenIrptEnable( );
return ASIX_ERROR;
};
// longn_qi 2002/01/25 for monitor memory leak
asix_mn_memdbgprintf( "asix_mn appeal mem of menu_coveredmap" );
pGC = GetGC();
if( GetCursorStatus( pGC, &cursor_status ) == GPC_ERR_OK )
{
if( cursor_status == ASIX_CURSOR_ON )
StopCursor( pGC );
}
// SaveRec(pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, (p_str->pop_width+2), (p_str->pop_height+2), 0 );//by zl 2002.3.19
SaveRec(pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, (p_str->pop_width), (p_str->pop_height), 0 );
//ClearRec(pGC, GPC_LIGHTGREY, p_str->pop_x, p_str->pop_y, (p_str->pop_width+1),
//(p_str->pop_height+1), GPC_REPLACE_STYLE);//modified by LM for Light Grey background 01/05/17
/* 2001-11-24 16:22 */
// ClearRec(pGC, ColorTheme.menu, p_str->pop_x, p_str->pop_y, (p_str->pop_width+1), (p_str->pop_height+1), GPC_REPLACE_STYLE);//by zl 2002.3.19
//by zl 2002/4/4
if (ClearRec(pGC, ColorTheme.menu, p_str->pop_x, p_str->pop_y, (p_str->pop_width), (p_str->pop_height), GPC_REPLACE_STYLE) != ASIX_OK)
{
ActiveAreaDisable( (p_str->menu_start).icon_id );
Lfree((void *)p_str->menu_item);
// longn_qi 2002/01/25 for monitor memory leak
asix_mn_memdbgprintf( "asix_mn free mem of its menu item" );
Lfree((void *)p_str);
// longn_qi 2002/01/25 for monitor memory leak
asix_mn_memdbgprintf( "asix_wn free mem of itself" );
PenIrptEnable( );
return ASIX_ERROR;
}
if ( ActiveAreaEnable( &((p_str->menu_mask).icon_id), ICON_AREA,
0, 0, 0, ASIX_LCD_W-1, ASIX_LCD_H-1, p_str->windowid ) != PPSM_OK )
{
// PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width+2,p_str->pop_height+2, GPC_REPLACE_STYLE, 0 );//by zl 2002.3.19
PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width,p_str->pop_height, GPC_REPLACE_STYLE, 0 );
return ASIX_ERROR;
}
(p_str->menu_mask).icon_status = ICON_ENABLE;
// Draw the menu frame
// DrawRec( pGC, GPC_BLACK, p_str->pop_x, p_str->pop_y, p_str->pop_x+p_str->pop_width,p_str->pop_y+p_str->pop_height, GPC_SOLID_LINE, GPC_REPLACE_STYLE ); //by zl 2002.3.19
// DrawLine( pGC, GPC_WHITE, p_str->pop_x+1, p_str->pop_y+1, p_str->pop_x+p_str->pop_width-1, p_str->pop_y+1, GPC_SOLID_LINE, GPC_REPLACE_STYLE); //by zl 2002.3.19
// DrawLine( pGC, GPC_WHITE, p_str->pop_x+1, p_str->pop_y+1, p_str->pop_x+1, p_str->pop_y+p_str->pop_height-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE);//by zl 2002.3.19
// DrawLine( pGC, GPC_DARKGREY, p_str->pop_x+1, p_str->pop_y+p_str->pop_height-1, p_str->pop_x+p_str->pop_width-1, p_str->pop_y+p_str->pop_height-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE); //by zl 2002.3.19
// DrawLine( pGC, GPC_DARKGREY, p_str->pop_x+p_str->pop_width-1, p_str->pop_y+1, p_str->pop_x+p_str->pop_width-1, p_str->pop_y+p_str->pop_height-1, GPC_SOLID_LINE, GPC_REPLACE_STYLE); //by zl 2002.3.19
DrawRec( pGC, ColorTheme.form_board, p_str->pop_x, p_str->pop_y, p_str->pop_x + p_str->pop_width - 1,p_str->pop_y + p_str->pop_height - 1, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
DrawHorz( pGC, ColorTheme.obj3D_highlight, p_str->pop_x + 1, p_str->pop_y + 1,p_str->pop_width - 2, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
DrawVert( pGC, ColorTheme.obj3D_highlight, p_str->pop_x + 1, p_str->pop_y + 1, p_str->pop_height - 2, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
DrawHorz( pGC, ColorTheme.obj3D_shadow, p_str->pop_x + 1, p_str->pop_y + p_str->pop_height -2, p_str->pop_width -2, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
DrawVert( pGC, ColorTheme.obj3D_shadow, p_str->pop_x + p_str->pop_width - 2, p_str->pop_y + 1, p_str->pop_height - 2, GPC_SOLID_LINE, GPC_REPLACE_STYLE);
// if ( p_str->total_line > 5)// by zl 2002.3.19
if ( p_str->total_line > ITEMDISPLAY_MAX )
{
// if ( ActiveAreaEnable( &((p_str->menu_up).icon_id), ICON_AREA, 0, p_str->pop_x, p_str->pop_y, p_str->pop_x+p_str->pop_width, p_str->pop_y+ITEM_0 ) != PPSM_OK )//by zl 2002.3.19
if ( ActiveAreaEnable( &((p_str->menu_up).icon_id), ICON_AREA, 0, p_str->pop_x, p_str->pop_y,
p_str->pop_x + p_str->pop_width - 1, p_str->pop_y + ITEM_0 - 1, p_str->windowid) != PPSM_OK )
{
ActiveAreaDisable( (p_str->menu_mask).icon_id );
(p_str->menu_mask).icon_id = 0;
(p_str->menu_mask).icon_status = ICON_DISABLE;
// PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width+2,p_str->pop_height+2, GPC_REPLACE_STYLE, 0 ); //by zl 2002.3.19
PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width,p_str->pop_height, GPC_REPLACE_STYLE, 0 );
return ASIX_ERROR;
};
// DrawLine( pGC, GPC_BLACK, p_str->pop_x, p_str->pop_y+ITEM_0, p_str->pop_x+p_str->pop_width, p_str->pop_y+ITEM_0, GPC_SOLID_LINE, GPC_REPLACE_STYLE );//by zl 2002.3.19
DrawHorz( pGC, ColorTheme.form_line, p_str->pop_x + 2, p_str->pop_y + ITEM_0 + 1, p_str->pop_width - 4, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
// longn_qi 2001/11/15 revised
//Advswitchonetotwo( menu_up, p_str->pop_x+(p_str->pop_width/2)-5,
// p_str->pop_y+2, 10, 10, BLACK_TO_GREY, WHITE_TO_WHITE);
// DrawMonoImage( pGC, menu_up, p_str->pop_x + (p_str->pop_width/2)-5, p_str->pop_y+2, 10, 10, ColorTheme.form_text, ColorTheme.menu );// by zl 2002.3.19
// DrawMonoImage( pGC, menu_up7x7, p_str->pop_x + (p_str->pop_width - ARROW_WIDTH)/ 2 + 1, p_str->pop_y + (ITEM_0 - ARROW_HEIGHT) / 2 + 1,ARROW_WIDTH, ARROW_HEIGHT, ColorTheme.form_disablecolor, ColorTheme.menu );
{
U32 hbmp;
//U32 trColor;
U16 x = p_str->pop_x + (p_str->pop_width - ARROW_WIDTH)/ 2 + 1;
U16 y = p_str->pop_y + (ITEM_0 - ARROW_HEIGHT) / 2 + 1;
U32 palette[2];
palette[0] = ColorTheme.menu;
palette[1] = ColorTheme.obj3D_disablecolor;
hbmp = LoadBitmap( menu_up7x7, palette );
if( hbmp != 0 )
{
//SetBMPPalette( hbmp, palette, NULL );
//SetBkFillMode( pGC, MAKELONG( GPC_REPLACE_STYLE, GPC_TRANSPARENT_STYLE ) );
//GetBMPPixel( pGC, 0, 0, hbmp, &trColor );
//DisplayBMPEx( pGC, x, y, hbmp, GPC_TRANSPARENT_STYLE, trColor );
DisplayBMP( pGC, x, y, hbmp );
FreeBitmap( hbmp );
}
}
(p_str->menu_up).icon_status = ICON_DISABLE;
// if ( ActiveAreaEnable( &((p_str->menu_down).icon_id), ICON_AREA, 0, p_str->pop_x, p_str->pop_y+5*ITEM_1+ITEM_0, p_str->pop_x+p_str->pop_width, p_str->pop_y+2*ITEM_0+5*ITEM_1) != PPSM_OK )// by zl 2002.3.19
if ( ActiveAreaEnable( &((p_str->menu_down).icon_id), ICON_AREA, 0, p_str->pop_x + 2,
p_str->pop_y + 5 * ITEM_1 + ITEM_0 + 1, p_str->pop_x + p_str->pop_width - 2, p_str->pop_y + 2 * ITEM_0 + ITEMDISPLAY_MAX * ITEM_1 + 1, p_str->windowid) != PPSM_OK )
{
ActiveAreaDisable( (p_str->menu_mask).icon_id );
(p_str->menu_mask).icon_id = 0;
(p_str->menu_mask).icon_status = ICON_DISABLE;
ActiveAreaDisable( (p_str->menu_up).icon_id );
(p_str->menu_up).icon_id = 0;
(p_str->menu_up).icon_status = ICON_DISABLE;
// PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width+2,p_str->pop_height+2, GPC_REPLACE_STYLE, 0 ); // by zl 2002.3.19
PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width,p_str->pop_height, GPC_REPLACE_STYLE, 0 );
return ASIX_ERROR;
};
// DrawLine( pGC, GPC_BLACK, p_str->pop_x, p_str->pop_y+ITEM_0+5*ITEM_1, p_str->pop_x+p_str->pop_width, p_str->pop_y+ITEM_0+5*ITEM_1, GPC_SOLID_LINE, GPC_REPLACE_STYLE );// by zl 2002.3.19
DrawHorz( pGC, ColorTheme.form_line, p_str->pop_x + 2, p_str->pop_y + ITEM_0 + ITEMDISPLAY_MAX * ITEM_1 + 1, p_str->pop_width - 4, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
// longn_qi 2001/11/15 revised
//switchonetotwo( menu_down, p_str->pop_x+(p_str->pop_width/2)-5,
// p_str->pop_y+5*ITEM_1+ITEM_0+2, 10, 10);
// DrawMonoImage( pGC, menu_down, p_str->pop_x+(p_str->pop_width/2)-5, p_str->pop_y+5*ITEM_1+ITEM_0+2, 10, 10, ColorTheme.form_text, ColorTheme.menu);// by zl 2002.3.19
// DrawMonoImage( pGC, menu_down7x7, p_str->pop_x + (p_str->pop_width - ARROW_WIDTH) / 2 + 1, p_str->pop_y + ITEMDISPLAY_MAX * ITEM_1 + ITEM_0 + ( ITEM_0 - ARROW_HEIGHT ) / 2 + 1, ARROW_WIDTH, ARROW_HEIGHT, ColorTheme.form_frontcolor, ColorTheme.menu);
{
U32 hbmp;
//U32 trColor;
U16 x = p_str->pop_x + (p_str->pop_width - ARROW_WIDTH) / 2 + 1;
U16 y = p_str->pop_y + ITEMDISPLAY_MAX * ITEM_1 + ITEM_0 + ( ITEM_0 - ARROW_HEIGHT ) / 2 + 1;
U32 palette[2];
palette[0] = ColorTheme.menu;
palette[1] = ColorTheme.obj3D_frontcolor;
hbmp = LoadBitmap( menu_down7x7, palette );
if( hbmp != 0 )
{
//SetBMPPalette( hbmp, palette, NULL );
//SetBkFillMode( pGC, MAKELONG( GPC_REPLACE_STYLE, GPC_TRANSPARENT_STYLE ) );
//GetBMPPixel( pGC, 0, 0, hbmp, &trColor );
//DisplayBMPEx( pGC, x, y, hbmp, GPC_TRANSPARENT_STYLE, trColor );
DisplayBMP( pGC, x, y, hbmp );
FreeBitmap( hbmp );
}
}
(p_str->menu_down).icon_status = ICON_ENABLE;
// if ( menu_drawicon( 5, p_str, 1 ) != ASIX_OK )// by zl 2002.3.19
if ( menu_drawicon( ITEMDISPLAY_MAX, p_str, 1 ) != ASIX_OK )
{
ActiveAreaDisable( (p_str->menu_mask).icon_id );
(p_str->menu_mask).icon_id = 0;
(p_str->menu_mask).icon_status = ICON_DISABLE;
ActiveAreaDisable( (p_str->menu_up).icon_id );
(p_str->menu_up).icon_id = 0;
(p_str->menu_up).icon_status = ICON_DISABLE;
ActiveAreaDisable( (p_str->menu_down).icon_id );
(p_str->menu_down).icon_id = 0;
(p_str->menu_down).icon_status = ICON_DISABLE;
// PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width+2,p_str->pop_height+2, GPC_REPLACE_STYLE, 0 ); // by zl 2002.3.19
PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width,p_str->pop_height, GPC_REPLACE_STYLE, 0 );
return ASIX_ERROR;
}
}
else
{
cycle = p_str->total_line;
if ( menu_drawicon( cycle, p_str, 0) != ASIX_OK )
{
ActiveAreaDisable( (p_str->menu_mask).icon_id );
(p_str->menu_mask).icon_id = 0;
(p_str->menu_mask).icon_status = ICON_DISABLE;
/*
ActiveAreaDisable( (p_str->menu_up).icon_id );
(p_str->menu_up).icon_id = 0;
(p_str->menu_up).icon_status = ICON_DISABLE;
ActiveAreaDisable( (p_str->menu_down).icon_id );
(p_str->menu_down).icon_id = 0;
(p_str->menu_down).icon_status = ICON_DISABLE;
*/
// PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width+2,p_str->pop_height+2, GPC_REPLACE_STYLE, 0 ); // by zl 2002.3.19
PutRec( pGC, p_str->menu_coveredmap, p_str->pop_x, p_str->pop_y, p_str->pop_width,p_str->pop_height, GPC_REPLACE_STYLE, 0 );
return ASIX_ERROR;
}
}
p_str->offset = 0;
p_str->pop_status = POP_SHOW;
return ASIX_OK;
}
/*********************************************************************/
/*画每个菜单栏*********************************************************/
static STATUS menu_drawicon( U16 cycle, struct MENU_STRUCTURE *p_str, U8 flag )
{
U16 item, i=0, j=0;
struct MENU_ITEM * p_input = p_str->menu_item;
char * dispbuf;
U32 pGC;
// if ( p_str == NULL || p_str->windowid == 0 ) return ASIX_ERROR; //by zl 2002.3.19
if ( flag == 1 ) item = ITEM_0;
else item = 0;
pGC = GetGC( );
if ((dispbuf = (char *)Lmalloc( ITEMTEXT_MAX + 1 )) == NULL) return ASIX_ERROR;
for ( i = 0; i < cycle; i++ )
{
// if ( ActiveAreaEnable( &((p_str->menu_icon[i]).icon_id), ICON_AREA, 0, p_str->pop_x, p_str->pop_y+i*ITEM_1+item, p_str->pop_x+p_str->pop_width, p_str->pop_y+(i+1)*ITEM_1+item) != PPSM_OK )// by zl 2002.3.19
if ( ActiveAreaEnable( &((p_str->menu_icon[i]).icon_id), ICON_AREA, 0, p_str->pop_x + 2, p_str->pop_y + i * ITEM_1 + item + 1, p_str->pop_x + p_str->pop_width - 2, p_str->pop_y + (i + 1) * ITEM_1 + item + 1, p_str->windowid) != PPSM_OK )
{
for ( j = 0; j < i; j++)
{
ActiveAreaDisable( (p_str->menu_icon[j]).icon_id );
(p_str->menu_icon[j]).icon_id = 0;
(p_str->menu_icon[j]).icon_status = ICON_DISABLE;
}
return ASIX_ERROR;
}
(p_str->menu_icon[i]).icon_status = p_input->item_status;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -