硬汉嵌入式论坛

 找回密码
 立即注册
查看: 1571|回复: 4
收起左侧

EDIT立体感

[复制链接]

6

主题

20

回帖

38

积分

新手上路

积分
38
发表于 2019-8-11 08:40:52 | 显示全部楼层 |阅读模式
请教大家,如何让EDIT有立体感。

Image 2.bmp
回复

使用道具 举报

6

主题

20

回帖

38

积分

新手上路

积分
38
 楼主| 发表于 2019-8-11 08:43:44 | 显示全部楼层
下面是上图的例程,试验时没立体感。

/*  
*********************************************************************************************************  
*                                             uC/GUI V3.98  
*                        Universal graphic software for embedded applications  
*  
*                       (c) Copyright 2002, Micrium Inc., Weston, FL  
*                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH  
*  
*              ?C/GUI is protected by international copyright laws. Knowledge of the  
*              source code may not be used to write a similar product. This file may  
*              only be used in accordance with a license and should not be redistributed  
*              in any way. We appreciate your understanding and fairness.  
*  
----------------------------------------------------------------------  
File        : WIDGET_EditWinmode.c  
Purpose     : Demonstrates how to use a edit widget in 'windows' mode  
----------------------------------------------------------------------  
*/   
   
#include <stddef.h>   
   
#include "GUI.h"   
#include "WM.h"   
#include "DIALOG.h"   
   
/*********************************************************************  
*  
*       Static data  
*  
**********************************************************************  
*/   
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {   
  { FRAMEWIN_CreateIndirect, "Edit winmode", 0,         90,  90, 140, 130, FRAMEWIN_CF_MOVEABLE},   
  { EDIT_CreateIndirect,     NULL,     GUI_ID_EDIT0,    10,  10, 110,  20, 0, 15},   
  { EDIT_CreateIndirect,     NULL,     GUI_ID_EDIT1,    10,  40, 110,  20, 0, 15},   
  { BUTTON_CreateIndirect,   "Ok",     GUI_ID_OK,       10,  80,  50,  20 },   
  { BUTTON_CreateIndirect,   "Cancel", GUI_ID_CANCEL,   70,  80,  50,  20 },   
};   
   
static WM_CALLBACK * _pEditCallback;   
   
static char * _apExplain[] = {   
  {"This sample shows how to use edit widgets with a"},   
  {"user defined callback function and how to set a"},   
  {"user defined AddKey function. It selects the"},   
  {"contents of the edit field on receiving the focus"},   
  {"and overwrites the contents if a key other than"},   
  {"a cursor key is pressed."},   
};   
   
/*********************************************************************  
*  
*       Static code  
*  
**********************************************************************  
*/   
/*********************************************************************  
*  
*       _cbEditAddKey  
*  
* Purpose:  
*   This function is called by the edit widget if a character should be added to the contents of the widget.  
*/   
static void _cbEditAddKey(EDIT_Handle hObj, int Key) {   
  char acBuffer[2] = {0};   
  switch (Key) {   
  case GUI_KEY_LEFT:   
    EDIT_SetpfAddKeyEx(hObj, 0);                            /* Clear user defined AddKey function */   
    EDIT_SetCursorAtChar(hObj, EDIT_GetNumChars(hObj) - 1); /* Set cursor if GUI_KEY_LEFT has been pressed */   
    break;   
  case GUI_KEY_RIGHT:   
    EDIT_SetpfAddKeyEx(hObj, 0);                            /* Clear user defined AddKey function */   
    EDIT_SetCursorAtChar(hObj, 1);                          /* Set cursor if GUI_KEY_RIGHT has been pressed */   
    break;   
  case GUI_KEY_UP:                                          /* Do not react on GUI_KEY_UP and GUI_KEY_DOWN */   
  case GUI_KEY_DOWN:   
    break;   
  default:   
    acBuffer[0] = (U8)Key;   
    EDIT_SetpfAddKeyEx(hObj, 0);                            /* Clear user defined AddKey function */   
    EDIT_SetText(hObj, acBuffer);                           /* Overwrite contents of edit widget with pressed key */   
  }   
}   
   
/*********************************************************************  
*  
*       _cbEdit  
*  
* Purpose:  
*   New callback function of edit widgets which should work in 'windows' mode.  
*/   
static void _cbEdit(WM_MESSAGE * pMsg) {   
  switch (pMsg->MsgId) {   
  case WM_PID_STATE_CHANGED:   
    if (((const WM_PID_STATE_CHANGED_INFO*)pMsg->Data.p)->State) {   
      return; /* Do not call edit callback */   
    }   
    break;   
  case WM_TOUCH:   
    if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */   
      const GUI_PID_STATE* pState;   
      pState = (const GUI_PID_STATE*)pMsg->Data.p;   
      if (pState->Pressed) {   
        if (WM_GetFocussedWindow() != pMsg->hWin) {   
          WM_SetFocus(pMsg->hWin);   
          return; /* Do not call edit callback */   
        }   
      }   
    }   
    break;   
  case WM_SET_FOCUS:   
    if (pMsg->Data.v == 1) {   
      EDIT_SetpfAddKeyEx(pMsg->hWin, _cbEditAddKey); /* Set function pointer for a user defined AddKey function */   
      EDIT_SetSel(pMsg->hWin, 0, -1);             /* Select the whole contents of the edit field */   
    }   
  }   
  if (_pEditCallback) {   
    _pEditCallback(pMsg);   
  }   
}   
   
/*********************************************************************  
*  
*       _cbDialog  
*/   
static void _cbDialog(WM_MESSAGE * pMsg) {   
  int i;   
  int NCode, Id;   
  WM_HWIN hDlg, hItem;   
  hDlg = pMsg->hWin;   
  switch (pMsg->MsgId) {   
  case WM_INIT_DIALOG:   
    FRAMEWIN_SetFont(pMsg->hWin, &GUI_Font13_ASCII);   
    FRAMEWIN_SetTextAlign(pMsg->hWin, GUI_TA_HCENTER);   
    for (i = 0; i < 2; i++) {   
      hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + i);  /* Get the handle of the edit widget */   
      if (!_pEditCallback) {   
        _pEditCallback = WM_SetCallback(hItem, _cbEdit); /* Overwrite callback function and remember original function */   
      } else {   
        WM_SetCallback(hItem, _cbEdit);                  /* Overwrite callback function */   
      }   
      EDIT_SetText(hItem, "Hello world!");               /* Fill widget with text */   
      EDIT_SetpfAddKeyEx(hItem, _cbEditAddKey);          /* Set function pointer for a user defined AddKey function */   
      EDIT_SetSel(hItem, 0, -1);                         /* Select the whole contents of the edit field */   
    }   
    break;   
  case WM_NOTIFY_PARENT:   
    Id    = WM_GetId(pMsg->hWinSrc);      /* Id of widget */   
    NCode = pMsg->Data.v;                 /* Notification code */   
    switch (NCode) {   
      case WM_NOTIFICATION_RELEASED:      /* React only if released */   
        if (Id == GUI_ID_OK) {            /* OK Button */   
          GUI_EndDialog(hDlg, 0);   
        }   
        if (Id == GUI_ID_CANCEL) {        /* Cancel Button */   
          GUI_EndDialog(hDlg, 1);   
        }   
        break;   
    }   
    break;   
  default:   
    WM_DefaultProc(pMsg);   
  }   
}   
   
/*********************************************************************  
*  
*       _cbDesktop  
*  
* Purpose:  
*   This routine handles the drawing of the desktop window.  
*/   
static void _cbDesktop(WM_MESSAGE * pMsg) {   
  int i;   
  switch (pMsg->MsgId) {   
  case WM_PAINT:   
    GUI_SetBkColor(GUI_RED);   
    GUI_Clear();   
    GUI_SetFont(&GUI_Font24_ASCII);   
    GUI_DispStringHCenterAt("WIDGET_EditWinmode", 160, 5);   
    GUI_DispNextLine();   
    GUI_SetFont(GUI_DEFAULT_FONT);   
    GUI_DispNextLine();   
    for (i = 0; i < GUI_COUNTOF(_apExplain); i++) {   
      GUI_DispStringHCenterAt(_apExplain[i], 160, GUI_GetDispPosY());   
      GUI_DispNextLine();   
    }   
    break;   
  }   
}   
   
/*********************************************************************  
*  
*       Exported code  
*  
**********************************************************************  
*/   
/*********************************************************************  
*  
*       MainTask  
*/   
void MainTask(void) {   
  int Result;   
  GUI_Init();   
  WM_SetCallback(WM_HBKWIN, _cbDesktop);   
  while(1) {   
    Result = GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, 0, 0, 0);   
    GUI_Delay(1000);   
  }   
}   
   
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117546
QQ
发表于 2019-8-11 09:39:36 | 显示全部楼层
使用经典皮肤就有立体感了。
回复

使用道具 举报

6

主题

20

回帖

38

积分

新手上路

积分
38
 楼主| 发表于 2019-8-11 10:41:03 | 显示全部楼层
本帖最后由 xjfpic 于 2019-8-11 10:52 编辑

请问,是在哪里设置?!
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117546
QQ
发表于 2019-8-11 11:00:42 | 显示全部楼层
xjfpic 发表于 2019-8-11 10:41
请问,是在哪里设置?!

为什么设置控件的颜色,却没有变化,比如按钮颜色设置,太多人问了,发帖说明下but
https://forum.anfulai.cn/forum.p ... 0669&fromuid=58
(出处: 硬汉嵌入式论坛)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-8-14 03:11 , Processed in 0.040464 second(s), 27 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表