#include <libmb/mb.h>
#include <liberipc/eripc.h>
#include <liberipc/eripctoolbar.h>
#include <liberipc/eripcviewer.h>
#include <liberipc/eripcicons.h>
#include "ScribbleUI.h"
#include "ScribbleIPC.h"
#include "ScribbleLog.h"
#include "ScribbleUtils.h"
#include "displayUpdate.h"
Go to the source code of this file.
Defines | |
| #define | LIST_INDEX_ICON (0) |
| #define | LIST_INDEX_ICONLOW (1) |
| #define | LIST_INDEX_SETTING (2) |
Enumerations | |
| enum | ICONLIST_MODE { ICONS_FLDALL = 0, ICONLIST_UNFLDSIZE = 1, ICONLIST_UNFLDCOLOR = 2 } |
Functions | |
| OPERATION_MODE | getOperationMode () |
| void | setOperationMode (OPERATION_MODE iOpMode) |
| HW_COLOR | getPenColor () |
| void | setPenColor (HW_COLOR iHwColor) |
| PEN_SIZE | getPenSize () |
| void | setPenSize (PEN_SIZE iPenSize) |
| static int | getIconfromPenSize (PEN_SIZE iPenSize, int iListIndex) |
| static PEN_SIZE | getPenSizefromIcon (int iIconID) |
| static int | getIconfromPenColor (HW_COLOR iPenColor, int iListIndex) |
| static HW_COLOR | getPenColorfromIcon (int iIconID) |
| static void | addIcons (const int *pIcons, unsigned int iSize) |
| static void | addIcon (const int iconID) |
| gboolean | toolbar_is_waitconfirmdel () |
| void | toolbar_confirm_delpage () |
| gboolean | toolbar_is_erasing () |
| gboolean | toolbar_is_drawing () |
| void | activeIcon (int iconID) |
| void | disableIcon (int iconID) |
| void | normalIcon (int iconID) |
| void | addIconsByListMode (const ICONLIST_MODE iListMode) |
| void | drawIconsByMode (int iTotalPage) |
| void | toolbar_clearall () |
| void | toolbar_firstinit (int iTotalPage) |
| void | toolbar_reinit (int iTotalPage) |
| void | toolbar_init () |
| void | toolbar_key_selected (int iconID, int iconState, PScribbleUICtx pScribbleUICtx) |
Variables | |
| static erClientChannel_t | toolbarChannel = NULL |
| static OPERATION_MODE | s_OperationMode = MODE_DRAW |
| static HW_COLOR | s_PenColor = COLOR_BLACK |
| static PEN_SIZE | m_PenSize = SIZE_3PIX |
| static const int | s_InitIcons [] |
| static const int | s_PenList [][4] |
| static const int | s_ColorList [][4] |
| static gboolean | ispagedel_confirmed = FALSE |
Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.
<File description>="">
Definition in file toolbar.c.
| enum ICONLIST_MODE |
Definition at line 46 of file toolbar.c.
00046 { 00047 ICONS_FLDALL=0, //folder all icon 00048 ICONLIST_UNFLDSIZE=1,//unfold the size select 00049 ICONLIST_UNFLDCOLOR=2,//fold the color select 00050 }ICONLIST_MODE;
| void activeIcon | ( | int | iconID | ) |
Definition at line 245 of file toolbar.c.
00246 { 00247 tbSetStatePlatformIcon(toolbarChannel, ER_SCRIBBLE_UA_ID, 00248 iconID,iconState_selected); 00249 }
| static void addIcon | ( | const int | iconID | ) | [static] |
| static void addIcons | ( | const int * | pIcons, | |
| unsigned int | iSize | |||
| ) | [static] |
Definition at line 202 of file toolbar.c.
00203 { 00204 unsigned int i; 00205 for( i=0;i<iSize;i++) 00206 { 00207 tbAppendPlatformIcon(toolbarChannel,ER_SCRIBBLE_UA_ID, 00208 pIcons[i],ccVwrToolbar); 00209 } 00210 }
| void addIconsByListMode | ( | const ICONLIST_MODE | iListMode | ) |
Definition at line 264 of file toolbar.c.
00265 { 00266 addIcon( iconID_pen );//normal 00267 00268 //to keep the icons order. 00269 if( ICONLIST_UNFLDSIZE==iListMode ) 00270 { 00271 addIcons(s_PenList[LIST_INDEX_ICONLOW], ARRAYSIZE(s_PenList[LIST_INDEX_ICONLOW])); 00272 } 00273 else 00274 { 00275 addIcon( getIconfromPenSize(getPenSize(), LIST_INDEX_ICON) ); 00276 } 00277 00278 if( ICONLIST_UNFLDCOLOR==iListMode ) 00279 { 00280 addIcons(s_ColorList[LIST_INDEX_ICONLOW], ARRAYSIZE(s_ColorList[LIST_INDEX_ICONLOW])); 00281 } 00282 else 00283 { 00284 addIcon( getIconfromPenColor(getPenColor(), LIST_INDEX_ICON) ); 00285 } 00286 00287 addIcons(s_InitIcons,ARRAYSIZE(s_InitIcons)); 00288 //always disable keyboard and tagging currently 00289 disableIcon(iconID_keyboard); 00290 disableIcon(iconID_tagging); 00291 }

| void disableIcon | ( | int | iconID | ) |
Definition at line 251 of file toolbar.c.
00252 { 00253 tbSetStatePlatformIcon(toolbarChannel, ER_SCRIBBLE_UA_ID, 00254 iconID,iconState_grey); 00255 }
| void drawIconsByMode | ( | int | iTotalPage | ) |
Definition at line 294 of file toolbar.c.
00295 { 00296 // freeze toolbar 00297 tbDisableUpdate(toolbarChannel, ER_SCRIBBLE_UA_ID); 00298 00299 // clear the toolbar 00300 tbClearIconSet(toolbarChannel, ER_SCRIBBLE_UA_ID); 00301 switch ( getOperationMode() ) 00302 { 00303 case MODE_INVALID: 00304 addIconsByListMode(ICONS_FLDALL); 00305 break; 00306 case MODE_DRAW: 00307 addIconsByListMode(ICONS_FLDALL); 00308 activeIcon( iconID_pen ); 00309 break; 00310 case MODE_SELSIZE: 00311 addIconsByListMode(ICONLIST_UNFLDSIZE); 00312 activeIcon( getIconfromPenSize(getPenSize(), LIST_INDEX_ICONLOW) ); 00313 activeIcon( iconID_pen ); 00314 break; 00315 case MODE_SELCOLOR: 00316 addIconsByListMode(ICONLIST_UNFLDCOLOR); 00317 activeIcon( getIconfromPenColor(getPenColor(), LIST_INDEX_ICONLOW) ); 00318 activeIcon( iconID_pen ); 00319 break; 00320 case MODE_ERASE: 00321 addIconsByListMode(ICONS_FLDALL); 00322 activeIcon( iconID_eraseline ); 00323 break; 00324 case MODE_DELPAGE: 00325 addIconsByListMode(ICONS_FLDALL); 00326 activeIcon( iconID_trashcan ); 00327 break; 00328 default: 00329 SB_ERRORPRINTF("Error Mode[%d]\n", getOperationMode()); 00330 return; 00331 } 00332 if( iTotalPage<=1 ) 00333 { 00334 disableIcon(iconID_trashcan); 00335 } 00336 00337 // redraw toolbar now 00338 tbEnableUpdate(toolbarChannel, ER_SCRIBBLE_UA_ID); 00339 }

| static int getIconfromPenColor | ( | HW_COLOR | iPenColor, | |
| int | iListIndex | |||
| ) | [static] |
Definition at line 173 of file toolbar.c.
00174 { 00175 int i; 00176 for( i=0; i< ARRAYSIZE(s_ColorList[LIST_INDEX_SETTING]); i++) 00177 { 00178 if( s_ColorList[LIST_INDEX_SETTING][i] == iPenColor ) 00179 { 00180 return s_ColorList[iListIndex][i]; 00181 } 00182 } 00183 return s_ColorList[iListIndex][3]; //default: black 00184 }
| static int getIconfromPenSize | ( | PEN_SIZE | iPenSize, | |
| int | iListIndex | |||
| ) | [static] |
Definition at line 146 of file toolbar.c.
00147 { 00148 int i; 00149 for(i=0; i< ARRAYSIZE(s_PenList[LIST_INDEX_SETTING]); i++) 00150 { 00151 if( s_PenList[LIST_INDEX_SETTING][i] == iPenSize ) 00152 { 00153 return s_PenList[iListIndex][i]; 00154 } 00155 } 00156 return s_PenList[iListIndex][1]; //default: pen3pixel 00157 }
| OPERATION_MODE getOperationMode | ( | ) |
| HW_COLOR getPenColor | ( | ) |
| static HW_COLOR getPenColorfromIcon | ( | int | iIconID | ) | [static] |
Definition at line 186 of file toolbar.c.
00187 { 00188 int i; 00189 for( i=0; i< ARRAYSIZE(s_ColorList[LIST_INDEX_SETTING]); i++) 00190 { 00191 if( s_ColorList[LIST_INDEX_ICON ][i]==iIconID 00192 || s_ColorList[LIST_INDEX_ICONLOW][i]==iIconID ) 00193 { 00194 return s_ColorList[LIST_INDEX_SETTING][i]; 00195 } 00196 } 00197 return COLOR_BLACK;//default 00198 }
| PEN_SIZE getPenSize | ( | ) |
| static PEN_SIZE getPenSizefromIcon | ( | int | iIconID | ) | [static] |
Definition at line 159 of file toolbar.c.
00160 { 00161 int i; 00162 for(i=0; i< ARRAYSIZE(s_PenList[LIST_INDEX_SETTING]); i++) 00163 { 00164 if( s_PenList[LIST_INDEX_ICON ][i]==iIconID 00165 || s_PenList[LIST_INDEX_ICONLOW][i]==iIconID ) 00166 { 00167 return s_PenList[LIST_INDEX_SETTING][i]; 00168 } 00169 } 00170 return SIZE_3PIX;//default 00171 }
| void normalIcon | ( | int | iconID | ) |
Definition at line 257 of file toolbar.c.
00258 { 00259 tbSetStatePlatformIcon(toolbarChannel, ER_SCRIBBLE_UA_ID, 00260 iconID,iconState_normal); 00261 }
| void setOperationMode | ( | OPERATION_MODE | iOpMode | ) |
| void setPenColor | ( | HW_COLOR | iHwColor | ) |
| void setPenSize | ( | PEN_SIZE | iPenSize | ) |
| void toolbar_clearall | ( | ) |
Definition at line 342 of file toolbar.c.
00343 { 00344 tbClearIconSet(toolbarChannel, ER_SCRIBBLE_UA_ID); 00345 }
| void toolbar_confirm_delpage | ( | ) |
| void toolbar_firstinit | ( | int | iTotalPage | ) |
Definition at line 348 of file toolbar.c.
00349 { 00350 setOperationMode(MODE_DRAW); 00351 drawIconsByMode(iTotalPage); 00352 }

| void toolbar_init | ( | void | ) |
Init toolbar (open communication channel and enable/set the correct icons)
Definition at line 365 of file toolbar.c.
00366 { 00367 int returnValue; 00368 00369 SB_IPCPRINTF("\n\n\nentry,ER_TOOLBAR_CHANNEL=%d\n\n", 00370 ER_TOOLBAR_CHANNEL); 00371 toolbarChannel=NULL; 00372 // create/init channel to communicate with the toolbar service 00373 returnValue = erIpcStartClient(ER_TOOLBAR_CHANNEL, &toolbarChannel); 00374 if (returnValue != 0) 00375 { 00376 SB_ERRORPRINTF("erIpcStartClient returned %d\n", returnValue); 00377 return; 00378 } 00379 // tell toolbar which icons set to display 00380 tbSelectIconSet(toolbarChannel, ER_SCRIBBLE_UA_ID); 00381 }
| gboolean toolbar_is_drawing | ( | ) |
Definition at line 238 of file toolbar.c.
00239 { 00240 return( MODE_DRAW ==s_OperationMode 00241 || MODE_SELSIZE ==s_OperationMode 00242 || MODE_SELCOLOR ==s_OperationMode); 00243 }
| gboolean toolbar_is_erasing | ( | ) |
Definition at line 232 of file toolbar.c.
00233 { 00234 return (MODE_ERASE== s_OperationMode); 00235 }
| gboolean toolbar_is_waitconfirmdel | ( | ) |
Definition at line 219 of file toolbar.c.
00220 { 00221 return ( MODE_DELPAGE==s_OperationMode ); 00222 }
| void toolbar_key_selected | ( | int | iconID, | |
| int | iconState, | |||
| PScribbleUICtx | pScribbleUICtx | |||
| ) |
A key is selected on the toolbar
| command | the command associated with the selected key | |
| PScribbleUICtx | scribble ui context |
Definition at line 383 of file toolbar.c.
00384 { 00385 if( iconState_grey==iconState ) 00386 { 00387 return;//donothing. 00388 } 00389 00390 SB_IPCPRINTF("\n====iconID=%d[mode=%d,pensize=%d,color=%d]\n", 00391 iconID,getOperationMode(),getPenSize(),getPenColor()); 00392 00393 gboolean bNeedFlushWithFullQlt=FALSE; 00394 //need full update when return from erase mode. 00395 if( getOperationMode()== MODE_ERASE) 00396 { 00397 //every erase stroke ,we do it, so it's useless 00398 //core_redrawBgAndStrks(pScribbleUICtx); 00399 bNeedFlushWithFullQlt=TRUE; 00400 } 00401 //we should add deal to pageup/pagedown 00402 switch (iconID) 00403 { 00404 case iconID_pen: 00405 //we switch by whether or not user is drawing 00406 if( !toolbar_is_drawing() ) 00407 { 00408 setOperationMode(MODE_DRAW); 00409 } 00410 else 00411 { 00412 setOperationMode(MODE_INVALID); 00413 } 00414 break; 00415 case iconID_pen1pixel: 00416 case iconID_pen3pixel: 00417 case iconID_pen5pixel: 00418 case iconID_pen7pixel: 00419 //enter select mode 00420 setOperationMode(MODE_SELSIZE); 00421 break; 00422 case iconID_pen1pixelLow: 00423 case iconID_pen3pixelLow: 00424 case iconID_pen5pixelLow: 00425 case iconID_pen7pixelLow: 00426 //confirm the select 00427 setPenSize(getPenSizefromIcon(iconID)); 00428 setOperationMode(MODE_DRAW); 00429 break; 00430 case iconID_penwhite://WHITE 00431 case iconID_penlightgrey://LIGHT_GRAY 00432 case iconID_pendarkgrey://DARK_GRAY 00433 case iconID_penblack://BLACK 00434 //enter select mode 00435 setOperationMode(MODE_SELCOLOR); 00436 break; 00437 case iconID_penwhiteLow://WHITE 00438 case iconID_penlightgreyLow://LIGHT_GRAY 00439 case iconID_pendarkgreyLow://DARK_GRAY 00440 case iconID_penblackLow://BLACK 00441 //confirm the select 00442 setPenColor(getPenColorfromIcon(iconID)); 00443 setOperationMode(MODE_DRAW); 00444 break; 00445 case iconID_eraseline: 00446 if( MODE_ERASE==getOperationMode()) 00447 { 00448 setOperationMode(MODE_DRAW); 00449 } 00450 else 00451 { 00452 setOperationMode(MODE_ERASE); 00453 } 00454 break; 00455 case iconID_trashcan://delete page 00456 if(MODE_DELPAGE==getOperationMode()) 00457 { 00458 setOperationMode(MODE_DRAW); 00459 if(ispagedel_confirmed) 00460 { 00461 //delete page 00462 delOnepage(pScribbleUICtx); 00463 ispagedel_confirmed=FALSE; 00464 return;//tool bar will be updated when jumping 00465 } 00466 ispagedel_confirmed=FALSE; 00467 } 00468 else 00469 { 00470 SB_IPCPRINTF("enter MODE_DELPAGE\n"); 00471 setOperationMode(MODE_DELPAGE); 00472 ispagedel_confirmed=FALSE; 00473 } 00474 break; 00475 case iconID_npage: 00476 addOnepage(pScribbleUICtx); 00477 return;//tool bar will be updated when jumping 00478 default: 00479 SB_IPCPRINTF("Unknown iconID [%d]\n", iconID); 00480 return; 00481 } 00482 00483 drawIconsByMode(getTotalPage(&pScribbleUICtx->fileManager)); 00484 //flush the pixmap to gdk_buffer,but now every stroke is flush,so it's useless. 00485 //flushPixMap(pScribbleUICtx); 00486 if(bNeedFlushWithFullQlt) 00487 { 00488 display_update_request_screen_refresh 00489 (MAIN_WINDOW_EXPOSE_LEVEL,(gpointer)dmQFull); 00490 } 00491 else 00492 { 00493 display_update_request_screen_refresh 00494 (MAIN_WINDOW_EXPOSE_LEVEL,(gpointer)dmQTyping); 00495 } 00496 SB_IPCPRINTF("\n===end===[mode=%d,pensize=%d,color=%d]\n", 00497 getOperationMode(),getPenSize(),getPenColor()); 00498 return; 00499 }

| void toolbar_reinit | ( | int | iTotalPage | ) |
Definition at line 355 of file toolbar.c.
00356 { 00357 //change the current mode only if current is mode_draw or erase. 00358 if( MODE_DELPAGE==getOperationMode() ) 00359 { 00360 setOperationMode(MODE_DRAW); 00361 } 00362 drawIconsByMode(iTotalPage); 00363 }

gboolean ispagedel_confirmed = FALSE [static] |
const int s_ColorList[][4] [static] |
Initial value:
{
{
iconID_penwhite,
iconID_penlightgrey,
iconID_pendarkgrey,
iconID_penblack
},
{
iconID_penwhiteLow,
iconID_penlightgreyLow,
iconID_pendarkgreyLow,
iconID_penblackLow
},
{
COLOR_WHITE,
COLOR_LIGHT_GRAY,
COLOR_DARK_GRAY,
COLOR_BLACK,
}
}
const int s_InitIcons[] [static] |
OPERATION_MODE s_OperationMode = MODE_DRAW [static] |
HW_COLOR s_PenColor = COLOR_BLACK [static] |
const int s_PenList[][4] [static] |
erClientChannel_t toolbarChannel = NULL [static] |
1.5.6