SCROLLER - Usage DefaultWidgets (Sample)

From SEGGER Wiki
Jump to: navigation, search
SCROLLER_Usage_DefaultWidgets.c
SCROLLER Custom.png
File(s) required
  • SCROLLER_Usage_DefaultWidgets.c
Runs in simulation Yes
Runs on target Yes
Download SCROLLER_Usage_DefaultWidgets.c

This sample demonstrates how SCROLLER widgets can be attached to predefined emWin widgets. SCROLLERs can be attached to LISTVIEW, LISTBOX, SWIPELIST, DROPDOWN and MULTIEDIT widgets.

Demo

Code

/*********************************************************************
*                    SEGGER Microcontroller GmbH                     *
*        Solutions for real time microcontroller applications        *
**********************************************************************
*                                                                    *
*        (c) 1996 - 2022  SEGGER Microcontroller GmbH                *
*                                                                    *
*        Internet: www.segger.com    Support:  support@segger.com    *
*                                                                    *
**********************************************************************

** emWin V6.26 - Graphical user interface for embedded applications **
emWin 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  re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
File        : SCROLLER_Usage_DefaultWidgets.c
Purpose     : Sample that demonstrates how SCROLLER widgets can be
              attached to emWin widgets.
Requirements: WindowManager - (x)
              MemoryDevices - ( )
              AntiAliasing  - ( )
              VNC-Server    - ( )
              PNG-Library   - ( )
              TrueTypeFonts - ( )
Wiki link   : https://wiki.segger.com/SCROLLER_-_Usage_DefaultWidgets_(Sample)
---------------------------END-OF-HEADER------------------------------
*/

#include "DIALOG.h"

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/
/*********************************************************************
*
*       _acContent_Listview
*/
static const char * _acContent[][6] = {
  { "1002", "Murphy",    "Diane",    "x5800", "President",            "dmurphy@classicmodelcars.com"    },
  { "1056", "Patterson", "Mary",     "x4611", "VP Sales",             "mpatterso@classicmodelcars.com"  },
  { "1076", "Firrelli",  "Jeff",     "x9273", "VP Marketing",         "jfirrelli@classicmodelcars.com"  },
  { "1088", "Patterson", "William",  "x4871", "Sales Manager (APAC)", "wpatterson@classicmodelcars.com" },
  { "1102", "Bondur",    "Gerard",   "x5408", "Sale Manager (EMEA)",  "gbondur@classicmodelcars.com"    },
  { "1143", "Bow",       "Anthony",  "x5428", "Sales Manager (NA)",   "abow@classicmodelcars.com"       },
  { "1165", "Jennings",  "Leslie",   "x3291", "Sales Rep",            "ljennings@classicmodelcars.com"  },
  { "1166", "Thompson",  "Leslie",   "x4065", "Sales Rep",            "lthompson@classicmodelcars.com"  },
  { "1188", "Firrelli",  "Julie",    "x2173", "Sales Rep",            "jfirrelli@classicmodelcars.com"  },
  { "1216", "Patterson", "Steve",    "x4334", "Sales Rep",            "spatterson@classicmodelcars.com" },
  { "1286", "Tseng",     "Foon Yue", "x2248", "Sales Rep",            "ftseng@classicmodelcars.com"     },
  { "1002", "Murphy",    "Diane",    "x5800", "President",            "dmurphy@classicmodelcars.com"    },
  { "1056", "Patterson", "Mary",     "x4611", "VP Sales",             "mpatterso@classicmodelcars.com"  },
  { "1076", "Firrelli",  "Jeff",     "x9273", "VP Marketing",         "jfirrelli@classicmodelcars.com"  },
  { "1088", "Patterson", "William",  "x4871", "Sales Manager (APAC)", "wpatterson@classicmodelcars.com" },
  { "1102", "Bondur",    "Gerard",   "x5408", "Sale Manager (EMEA)",  "gbondur@classicmodelcars.com"    },
  { "1143", "Bow",       "Anthony",  "x5428", "Sales Manager (NA)",   "abow@classicmodelcars.com"       },
  { "1165", "Jennings",  "Leslie",   "x3291", "Sales Rep",            "ljennings@classicmodelcars.com"  },
  { "1166", "Thompson",  "Leslie",   "x4065", "Sales Rep",            "lthompson@classicmodelcars.com"  },
  { "1188", "Firrelli",  "Julie",    "x2173", "Sales Rep",            "jfirrelli@classicmodelcars.com"  },
  { "1216", "Patterson", "Steve",    "x4334", "Sales Rep",            "spatterson@classicmodelcars.com" },
  { "1286", "Tseng",     "Foon Yue", "x2248", "Sales Rep",            "ftseng@classicmodelcars.com"     },
  { "1002", "Murphy",    "Diane",    "x5800", "President",            "dmurphy@classicmodelcars.com"    },
  { "1056", "Patterson", "Mary",     "x4611", "VP Sales",             "mpatterso@classicmodelcars.com"  },
  { "1076", "Firrelli",  "Jeff",     "x9273", "VP Marketing",         "jfirrelli@classicmodelcars.com"  },
  { "1088", "Patterson", "William",  "x4871", "Sales Manager (APAC)", "wpatterson@classicmodelcars.com" },
  { "1102", "Bondur",    "Gerard",   "x5408", "Sale Manager (EMEA)",  "gbondur@classicmodelcars.com"    },
  { "1143", "Bow",       "Anthony",  "x5428", "Sales Manager (NA)",   "abow@classicmodelcars.com"       },
  { "1165", "Jennings",  "Leslie",   "x3291", "Sales Rep",            "ljennings@classicmodelcars.com"  },
  { "1166", "Thompson",  "Leslie",   "x4065", "Sales Rep",            "lthompson@classicmodelcars.com"  },
  { "1188", "Firrelli",  "Julie",    "x2173", "Sales Rep",            "jfirrelli@classicmodelcars.com"  },
  { "1216", "Patterson", "Steve",    "x4334", "Sales Rep",            "spatterson@classicmodelcars.com" },
  { "1286", "Tseng",     "Foon Yue", "x2248", "Sales Rep",            "ftseng@classicmodelcars.com"     },
};

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/
/*********************************************************************
*
*       _CreateListview
*/
static LISTVIEW_Handle _CreateListview(void) {
  LISTVIEW_Handle hListview;
  int             i;

  //
  // Create listview widget
  //
  hListview = LISTVIEW_CreateEx(0, 0, LCD_GetXSize(), LCD_GetYSize(), WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_LISTVIEW0);
  //
  // Add columns to listview
  //
  LISTVIEW_AddColumn(hListview, 45, "Emp. Nr.", GUI_TA_LEFT);
  LISTVIEW_AddColumn(hListview, 60, "Last Name", GUI_TA_LEFT);
  LISTVIEW_AddColumn(hListview, 60, "First Name", GUI_TA_LEFT);
  LISTVIEW_AddColumn(hListview, 40, "Ext.", GUI_TA_LEFT);
  LISTVIEW_AddColumn(hListview, 110, "Title", GUI_TA_LEFT);
  LISTVIEW_AddColumn(hListview, 180, "Email", GUI_TA_LEFT);
  //
  // Add rows to listview
  //
  for (i = 0; i < GUI_COUNTOF(_acContent); i++) {
    LISTVIEW_AddRow(hListview, _acContent[i]);
  }
  //
  // Set compare functions
  //
  LISTVIEW_SetCompareFunc(hListview, 0, LISTVIEW_CompareDec);
  LISTVIEW_SetCompareFunc(hListview, 1, LISTVIEW_CompareText);
  LISTVIEW_SetCompareFunc(hListview, 2, LISTVIEW_CompareText);
  LISTVIEW_SetCompareFunc(hListview, 3, LISTVIEW_CompareText);
  LISTVIEW_SetCompareFunc(hListview, 4, LISTVIEW_CompareText);
  LISTVIEW_SetCompareFunc(hListview, 5, LISTVIEW_CompareText);
  //
  // Enable sorting
  //
  LISTVIEW_EnableSort(hListview);
  //
  // Enable motion
  //
  LISTVIEW_EnableMotion(hListview, LISTVIEW_CF_MOTION_V);
  return hListview;
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  LISTVIEW_Handle hListview;
  SCROLLER_Handle hScroller;

  //
  // Init GUI
  //
  GUI_Init();
  WM_SetDesktopColor(GUI_WHITE);
  //
  // Enable multi-buffering
  //
  WM_MULTIBUF_Enable(1);
  //
  // Create LISTVIEW
  //
  hListview = _CreateListview();
  //
  // Attach SCROLLER to LISTVIEW with fading and touch enabled.
  // The same way a SCROLLER can be attached to the widgets LISTBOX,
  // MULTIEDIT, SWIPELIST and DROPDOWN.
  //
  hScroller = SCROLLER_CreateAttached(hListview, SCROLLER_CF_VERTICAL | SCROLLER_CF_FADING | SCROLLER_CF_TOUCH);

  while (1) {
    GUI_Delay(100);
  }
}

/*************************** End of file ****************************/