|
![]() |
| Latest News : | Date: | Bookmark |
|
void MainTask(void) {
GUI_Init();
/* Draw something on default layer 0 */
GUI_SetBkColor(GUI_GREEN);
GUI_Clear();
GUI_DispStringHCenterAt("Layer 0", 100, 46);
/* Draw something on layer 1 */
GUI_SelLayer(1); /* Select layer 1 */
GUI_SetBkColor(GUI_RED);
GUI_Clear();
GUI_SetColor(GUI_BLUE);
GUI_FillRect(20, 20, 179, 79);
GUI_SetColor(GUI_WHITE);
GUI_SetTextMode(GUI_TM_TRANS);
GUI_DispStringHCenterAt("Layer 1", 100, 46);
while(1) {
GUI_Delay(100);
}
}
|
The window manager automatically keeps track of which window is located in which layer. This is done in a fairly easy way: If the window manager is used, every layer has a top level (desktop) window. Any other window in this layer is visible only if it is a descendent (a child or grand- child or ...) of one of these desktop windows. Which layer a window is in depends solely on which desktop window it is a descendent of.
The following sample shows how to create 3 windows on 2 different desktop windows:
hWin0 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(0), WM_CF_SHOW, _cbWin0, 0); /* Create 2 child windows on destop 1 */ hWin1 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin1, 0); hWin2 = WM_CreateWindowAsChild(110, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin2, 0); |
| Screenshot | Window hierarchy |
![]() |
![]() |
This can sometime be very desireable and can easily be accomplished: If a window is detached from its parent (The desktop window of one layer or any descenedent of this ldesktop window) and attached to a window which lies in an other layer, this win- dow actually moves from one layer to an other layer.
The following sample shows how to detach a window from its parent window and how to attach it to a new parent window:
/* Create 1 child window on destop 0 */ hWin0 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(0), WM_CF_SHOW, _cbWin0, 0); /* Create 2 child windows on destop 1 */ hWin1 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin1, 0); hWin2 = WM_CreateWindowAsChild(110, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin2, 0); GUI_Delay(1000); |
Any other window in this layer is visible only if it is a descendent (a child or grand- child or ...) of one of these desktop windows. Which layer a window is in depends solely on which desktop window it is a descendent of.
| Screenshot | Window hierarchy |
![]() |
![]() |
The next table shows the screenshot and the window hierarchy of the above sample after attaching the window to the new parent:
| Screenshot | Window hierarchy |
![]() |
![]() |
emWin does not distinguish between multiple layers or multiple displays. When using multiple layers normally the size and the driver for each layer is the same. The viewer shows each layer in a separate window. The composite window of the viewer shows the layers one above the other:
The emWin viewer treats pixels with index 0 in a layer above layer 0 as transparent. This means in the composite view the pixels of the layers below are visible.
The following sample shows how to draw transparent and non transparent:
GUI_SelLayer(1);
GUI_SetBkColor(GUI_WHITE); /* Select white for the background */
GUI_Clear();
GUI_SetColor(GUI_BLACK); /* Select black for the text */
GUI_SetFont(&GUI_FontComic24B_ASCII);
GUI_DispStringHCenterAt("Layer#:1",
XSize / 2, 5);
GUI_SetColorIndex(0); /* Select transparency */
GUI_FillCircle(LCD_GetXSize() / 2,
YSize / 2 + 15,
YSize / 2 - 20); /* A transparent circle will be drawn */
|
The sample below contains a screenshot of the viewer with 2 layers. The simulated LCD-controller is the integrated LCD-controller of a Toshiba TMPR3916 (Capricorn 2). Layer 0(E) shows color bars with a high color configuration. Layer 1(B) shows a transparent circle on a white background with colored rectangles. The composite win- dow shows the result which is actually visible on the display:
| Layer 0
Layer 1 |
![]() |
Composite view
|
Since for all but layer 0 Index 0 means transparency, Index 0 can not be used to dis- play colors. This also means that the color conversion should never yield 0 as best match for a color, since this would result in a transparent pixel. This means that only some fixed palette modes should be used and that you need to be careful when defining you own palette. You need to make sure that the color conversion (24 bit RGB -> Index) never yields 0 as result.
8666_1 is currently the only available mode. For details please take a look at chapter colors.
If a custom palette should be used in a layer > 0, the first color should not be used from the color conversion routines. The following shows a sample definition for a cus- tom palette with 15 gray scales:
#define LCD_FIXEDPALETTE_1 0 #define LCD_PHYSCOLORS_1 0x000000, /* Transparency, not black */ \ 0x000000, 0x222222, 0x333333, \ 0x444444, 0x555555, 0x666666, 0x777777, \ 0x888888, 0x999999, 0xAAAAAA, 0xBBBBBB, \ 0xCCCCCC, 0xDDDDDD, 0xEEEEEE, 0xFFFFFF |
If you need to draw some black items with this palette you can not use GUI_SetColor(0x000000). The result from the color conversion routines would be index 0 (transparent). You should use GUI_SetColorIndex(1).
Each display can be accessed with its own driver and with its own settings. You can define up to 5 different displays.
The sample below shows a screenshot of the simulation with 2 displays. The fist dis- play is a 8bpp color display with a size of 320 x 240 pixel. The driver is LCD13XX.c configured for an Epson S1D13705 LCD-controller. The second display is a 1bpp bw- display with a size of 240 x 128 pixels. The driver is LCDSlin.c configured for a Toshiba T6963 LCD-controller:
Return to main emWin page...
You can download an evaluation
version of emWin from our Literature/Download section....
Abatron | Adeneo
Embedded | ADI
Engineering | Blackhawk | Corelis | Domain
Technologies | e-con
Systems
EMA
TimingDesigner | Embedded
Planet | Entrek | EPI/Mentor |
FlatOak |
Intel
Software | IntervalZero
Microcross | Microsoft
Embedded | Segger | Signum | Sophia | SwiftModule | Tasking | TRITON
Modules
Products
by Processor | Products
by Supplier | Boards & Modules
| Segger News |
| NEWS: Tools |
| 30-day free evaluation |
| Literature Centre |
|
| << Backward | Forward >> | Top of Page |
|
Copyright
© 2001 -
Direct Insight Ltd |