00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <liberdm/display.h>
00037 #include <liberdm/erdm.h>
00038 #include <liberipc/eripcpagebar.h>
00039 #include <liberipc/eripcviewer.h>
00040 #include <liberipc/eripcbusyd.h>
00041 #include <liberipc/eripccontentlister.h>
00042 #include <liberipc/eripcsetup.h>
00043 #include <liberipc/eripcconnect.h>
00044 #include <liberipc/eripcarinc.h>
00045 #include "gtkPagebar.h"
00046 #include "displayUpdate.h"
00047
00048
00049 #ifdef DEBUG_PRINTS
00050 #define PRINT_TRACE(X) printf X
00051 #define PRINT_DEBUG(X) printf X
00052 #define PRINT_INFO(X) printf X
00053 #else
00054 #define PRINT_TRACE(X) ;
00055 #define PRINT_DEBUG(X) ;
00056 #define PRINT_INFO(X) ;
00057 #endif
00058
00059 #define PRINT_ERROR(X) printf X
00060
00061
00062 #ifdef DEBUG_FLOW_LEVEL
00063 #define ENTER(x) {if (x<DEBUG_FLOW_LEVEL) printf("%s: Entered\n", __FUNCTION__);}
00064 #define LEAVE(x) {if (x<DEBUG_FLOW_LEVEL) printf("%s: Left \n", __FUNCTION__);}
00065 #else
00066 #define ENTER(x) ;
00067 #define LEAVE(x) ;
00068 #endif
00069
00070 #define RETURN(x) {ret=x; goto end;}
00071
00072 #define PAGE_BAR_PADDING 2
00073 #define PAGEBAR_BUTTON_PADDING 2
00074
00075 #define PAGEBAR_LISTBLOCKSIZE 128
00076
00077 #define PAGEBAR_ORIENTATION_X 0 // zeng: hor, provide vertical support
00078 #define PAGEBAR_ORIENTATION_Y 1 // zeng: ver, provide vertical support
00079 #define SCROLLBOX_LEFT 0 // scroll box
00080 #define SCROLLBOX_RIGHT 1
00081 #define SCROLLBOX_NONE -1
00082 #define TIMER_SPAN 1500 // one second does not work. use too many cpu resource
00083
00084 #define TRACE()
00085
00086
00087
00088
00089
00090
00091 enum
00092 {
00093 PAGE_SELECTED,
00094 LAST_SIGNAL,
00095 };
00096
00097 static gint pagebar_signals[LAST_SIGNAL] = { 0 };
00098
00099 static gboolean on_pagebar_exposed(GtkWidget *widget, GdkEventExpose *event, gpointer user_data);
00100 static gboolean on_pagebar_configured(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data);
00101 static gboolean on_pagebar_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data);
00102 static gboolean on_pagebar_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data);
00103
00104
00105 static void pagebar_calculate(GtkPagebar *pagebar);
00106 static void pagebar_draw_cpi(GtkPagebar *pagebar);
00107 static void pagebar_draw_left(GtkPagebar *pagebar);
00108 static void pagebar_draw_right(GtkPagebar *pagebar);
00109 static int pagebar_scrollbox_hitTest(GtkPagebar *pagebar, int, int);
00110 static gboolean pagebar_scrollbox_needLeft(GtkPagebar *pagebar);
00111 static gboolean pagebar_scrollbox_needRight(GtkPagebar *pagebar);
00112 static int framebuffer_device;
00113
00114 static void gtk_pagebar_class_init (GtkPagebarClass *klass);
00115 static void gtk_pagebar_init (GtkPagebar *pagebar);
00116
00117 static erClientChannel_t apabiChannel;
00118 static erClientChannel_t pdfChannel;
00119 static erClientChannel_t xhtmlChannel;
00120 static erClientChannel_t contentListerChannel;
00121 static erClientChannel_t scribbleChannel;
00122 static erClientChannel_t setupChannel;
00123 static erClientChannel_t connectChannel;
00124 static erClientChannel_t ebaChannel;
00125 static erClientChannel_t arincViewerChannel;
00126 static erClientChannel_t arincMenuChannel;
00127 static erClientChannel_t mobipocketChannel;
00128
00129 static int loadBitmap(GdkPixbuf** buf, char* filename) {
00130 GError *error = NULL;
00131 int ret=0;
00132
00133 ENTER(1);
00134
00135 (*buf) = gdk_pixbuf_new_from_file(filename, &error);
00136 if ((*buf)==NULL) {
00137 PRINT_ERROR(("Error loading bitmap %s (%s)\n", filename, error->message));
00138 RETURN(-1);
00139 }
00140
00141 end:
00142 LEAVE(1);
00143 return ret;
00144 }
00145
00146 static int addToList(int** list, int* count, int value) {
00147 int i;
00148 int ret=0;
00149
00150 ENTER(1);
00151
00152 if (value<0)
00153 RETURN(-1);
00154
00155 if (!(*list)) {
00156 (*list)=(int*)malloc(PAGEBAR_LISTBLOCKSIZE*sizeof(int));
00157 for (i=0; i<PAGEBAR_LISTBLOCKSIZE; i++)
00158 (*list)[i]=-1;
00159 *count = PAGEBAR_LISTBLOCKSIZE;
00160 }
00161
00162 i=0;
00163 while (i<*count && (*list)[i]!=-1 && (*list)[i]!=value)
00164 i++;
00165
00166
00167 if (i<*count && (*list)[i]==value)
00168 RETURN(0);
00169
00170
00171
00172 if (i==*count) {
00173 (*list)=(int*)realloc(*list, (*count+PAGEBAR_LISTBLOCKSIZE)*sizeof(int));
00174 for (i=0; i<PAGEBAR_LISTBLOCKSIZE; i++)
00175 (*list)[i+*count]=-1;
00176 *count += PAGEBAR_LISTBLOCKSIZE;
00177 }
00178
00179 (*list)[i]=value;
00180
00181 end:
00182 LEAVE(1);
00183 return ret;
00184 }
00185
00186 static int removeFromList(int** list, int* count, int value) {
00187 int i;
00188
00189 ENTER(1);
00190
00191 i=0;
00192 while (i<*count && (*list)[i]!=value && (*list)[i]!=-1)
00193 i++;
00194 if (i<*count && (*list)[i]==value) {
00195 memmove(*list, (*list)+1, *count-i-1);
00196 (*list)[*count-1]=-1;
00197 *count--;
00198 }
00199
00200 LEAVE(1);
00201 return 0;
00202 }
00203
00204 int addBookmark(GtkPagebar* pagebar, int value) {
00205 return addToList(&pagebar->bookmarks, &pagebar->bookmarkCount, value);
00206 }
00207
00208 int addNote(GtkPagebar* pagebar, int value) {
00209 return addToList(&pagebar->notes, &pagebar->noteCount, value);
00210 }
00211
00212 int removeBookmark(GtkPagebar* pagebar, int value) {
00213 return removeFromList(&pagebar->bookmarks, &pagebar->bookmarkCount, value);
00214 }
00215
00216 int removeNote(GtkPagebar* pagebar, int value) {
00217 return removeFromList(&pagebar->notes, &pagebar->noteCount, value);
00218 }
00219
00220 int pagebar_reset_values(GtkPagebar* pagebar) {
00221 ENTER(0);
00222
00223 pagebar->pagecount = PAGEBAR_DEFAULT_PAGECOUNT;
00224 pagebar->currentPage = PAGEBAR_DEFAULT_CURRENTPAGE;
00225 pagebar->currentPageOffset = PAGEBAR_DEFAULT_CURRENTPAGEOFFSET;
00226 pagebar->zoomMode = PAGEBAR_DEFAULT_ZOOMMODE;
00227 pagebar->orientation = PAGEBAR_DEFAULT_ORIENTATION;
00228 pagebar->drawAreaXPos = PAGEBAR_DEFAULT_DRAWAREAXPOS;
00229 pagebar->drawAreaYPos = PAGEBAR_DEFAULT_DRAWAREAYPOS;
00230 pagebar->drawAreaWidth = PAGEBAR_DEFAULT_DRAWAREAWIDTH;
00231 pagebar->drawAreaHeight = PAGEBAR_DEFAULT_DRAWAREAHEIGHT;
00232 pagebar->barXPos = PAGEBAR_DEFAULT_BARXPOS;
00233 pagebar->barYPos = PAGEBAR_DEFAULT_BARYPOS;
00234 pagebar->barWidth = PAGEBAR_DEFAULT_BARWIDTH;
00235 pagebar->barHeight = PAGEBAR_DEFAULT_BARHEIGHT;
00236 pagebar->cpiHeight = PAGEBAR_DEFAULT_CPIHEIGHT;
00237 pagebar->cpiWidth = PAGEBAR_DEFAULT_CPIWIDTH;
00238 pagebar->barFontType = PAGEBAR_DEFAULT_BARFONTTYPE;
00239 pagebar->barFontHeight = PAGEBAR_DEFAULT_BARFONTHEIGHT;
00240 pagebar->cpiFontType = PAGEBAR_DEFAULT_CPIFONTTYPE;
00241 pagebar->cpiFontHeight = PAGEBAR_DEFAULT_CPIFONTHEIGHT;
00242 pagebar->pageFieldWidth = PAGEBAR_DEFAULT_PAGEFIELDWIDTH;
00243 pagebar->pageFieldHeight = PAGEBAR_DEFAULT_PAGEFIELDHEIGHT;
00244 pagebar->pageOffsetWidth = PAGEBAR_DEFAULT_PAGEOFFSETWIDTH;
00245 pagebar->pageOffsetHeight = PAGEBAR_DEFAULT_PAGEOFFSETHEIGHT;
00246 pagebar->pageOffsetXOffset = PAGEBAR_DEFAULT_PAGEOFFSETXOFFSET;
00247 pagebar->pageOffsetYOffset = PAGEBAR_DEFAULT_PAGEOFFSETYOFFSET;
00248 pagebar->bookmarkCount = PAGEBAR_DEFAULT_BOOKMARKCOUNT;
00249 pagebar->bookmarkMaxValue = PAGEBAR_DEFAULT_BOOKMARKMAXVALUE;
00250 pagebar->noteCount = PAGEBAR_DEFAULT_NOTECOUNT;
00251 pagebar->notesMaxValue = PAGEBAR_DEFAULT_NOTESMAXVALUE;
00252 pagebar->scrollButtonWidth = PAGEBAR_DEFAULT_SCROLLBUTTONWIDTH;
00253 pagebar->show = PAGEBAR_DEFAULT_SHOW;
00254 if (PAGEBAR_TIMER_PROGRESS != pagebar->currentTimer)
00255 pagebar->currentTimer = PAGEBAR_TIMER_NONE;
00256
00257 pagebar->lastPage = -1;
00258 pagebar->lastDrawAreaXPos = pagebar->lastDrawAreaYPos = -1;
00259
00260 if (pagebar->bookmarks)
00261 free(pagebar->bookmarks);
00262 if (pagebar->notes)
00263 free(pagebar->notes);
00264
00265 pagebar->bookmarks = NULL;
00266 pagebar->notes = NULL;
00267
00268 LEAVE(0);
00269 return 0;
00270 }
00271
00272 int pagebar_load_bitmaps(GtkPagebar* pagebar)
00273 {
00274 int ret = 0;
00275 #ifdef USE_BITMAPS
00276
00277 if (loadBitmap(&(pagebar->bitmaps[bitmap_CPI]), DATA_DIR "/pagebar_cpi.png"))
00278 RETURN(-1);
00279 pagebar->cpiWidth = gdk_pixbuf_get_width(pagebar->bitmaps[bitmap_CPI]);
00280 pagebar->cpiHeight = gdk_pixbuf_get_height(pagebar->bitmaps[bitmap_CPI]);
00281
00282
00283
00284
00285
00286 if (loadBitmap(&(pagebar->bitmaps[bitmap_PageField]), DATA_DIR "/pagebar_pagefield.png"))
00287 RETURN(-1);
00288 pagebar->pageFieldWidth = gdk_pixbuf_get_width(pagebar->bitmaps[bitmap_PageField]);
00289 pagebar->pageFieldHeight = gdk_pixbuf_get_height(pagebar->bitmaps[bitmap_PageField]);
00290 if (loadBitmap(&(pagebar->bitmaps[bitmap_ScrollLeft]), DATA_DIR "/pagebar_scrollleft.png"))
00291 RETURN(-1);
00292 pagebar->scrollButtonWidth = gdk_pixbuf_get_width(pagebar->bitmaps[bitmap_ScrollLeft]);
00293 if (loadBitmap(&(pagebar->bitmaps[bitmap_ScrollRight]), DATA_DIR "/pagebar_scrollright.png"))
00294 RETURN(-1);
00295 if (loadBitmap(&(pagebar->bitmaps[bitmap_Bookmark]), DATA_DIR "/pagebar_bookmark.png"))
00296 RETURN(-1);
00297 if (loadBitmap(&(pagebar->bitmaps[bitmap_Note]), DATA_DIR "/pagebar_note.png"))
00298 RETURN(-1);
00299 #endif
00300
00301 end:
00302 return ret;
00303 }
00304
00305
00306 static gboolean on_pagebar_configured(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
00307 {
00308 GtkPagebar* pagebar = GTK_PAGEBAR(user_data);
00309
00310 ENTER(0);
00311
00312 if (pagebar->pixmap)
00313 g_object_unref (pagebar->pixmap);
00314
00315 pagebar->pixmap = gdk_pixmap_new (widget->window,
00316 widget->allocation.width,
00317 widget->allocation.height,
00318 -1);
00319 gdk_draw_rectangle (pagebar->pixmap,
00320 widget->style->white_gc,
00321 TRUE,
00322 0, 0,
00323 widget->allocation.width,
00324 widget->allocation.height);
00325
00326 gtk_pagebar_draw(pagebar);
00327 LEAVE(0);
00328 return TRUE;
00329 }
00330
00331
00332 static gboolean on_pagebar_exposed(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
00333 {
00334
00335 GtkPagebar* pagebar = GTK_PAGEBAR(user_data);
00336
00337 ENTER(0);
00338
00339
00340 gdk_draw_drawable (widget->window,
00341 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
00342 pagebar->pixmap,
00343 event->area.x, event->area.y,
00344 event->area.x, event->area.y,
00345 event->area.width, event->area.height);
00346
00347 LEAVE(0);
00348 return FALSE;
00349 }
00350
00351 static gboolean on_pagebar_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
00352 {
00353 ENTER(1);
00354
00355 PRINT_TRACE(("button_release_event -- location %dx%d - %dx%d \n",(int)event->x,(int)event->y,(int)event->x_root,(int)event->y_root));
00356
00357 LEAVE(1);
00358
00359 return TRUE;
00360 }
00361
00362 static int currentPageChanged(GtkPagebar* pagebar) {
00363 erClientChannel_t channel;
00364 int ret = 0;
00365
00366 ENTER(1);
00367
00368 if (pagebar->lastPage==pagebar->currentPage)
00369 RETURN (0);
00370
00371 pagebar->lastPage=pagebar->currentPage;
00372 gtk_pagebar_draw(pagebar);
00373
00374 switch (pagebar->currentApp) {
00375 case ER_APABI_VIEWER_UA_ID:
00376 channel = apabiChannel;
00377 break;
00378 case ER_PDF_VIEWER_UA_ID:
00379 channel = pdfChannel;
00380 break;
00381 case ER_XHTML_VIEWER_UA_ID:
00382 channel = xhtmlChannel;
00383 break;
00384 case ER_SCRIBBLE_UA_ID:
00385 channel = scribbleChannel;
00386 break;
00387 case ER_CONTENT_LISTER_UA_ID:
00388 channel = contentListerChannel;
00389 clGotoPage(channel, pagebar->currentPage);
00390 RETURN (0);
00391 case ER_SETUP_UA_ID:
00392 channel = setupChannel;
00393 stGotoPage(channel, pagebar->currentPage);
00394 RETURN (0);
00395 case ER_CONNECT_UA_ID:
00396 channel = connectChannel;
00397 cnGotoPage(channel, pagebar->currentPage);
00398 RETURN (0);
00399 case ER_EBA_VIEWER_UA_ID:
00400 channel = ebaChannel;
00401 break;
00402 case ER_ARINC_VIEWER_UA_ID:
00403 channel = arincViewerChannel;
00404 arincJumpToPage(channel, pagebar->currentApp, pagebar->currentPage);
00405 RETURN (0);
00406 case ER_ARINC_MENU_UA_ID:
00407 channel = arincMenuChannel;
00408 arincJumpToPage(channel, pagebar->currentApp, pagebar->currentPage);
00409 RETURN (0);
00410 case ER_MOBIPOCKET_VIEWER_UA_ID:
00411 channel = mobipocketChannel;
00412 break;
00413 default:
00414 return -1;
00415 }
00416 vwrJumpToPage(channel, pagebar->currentApp, pagebar->currentPage);
00417
00418 end:
00419 LEAVE(1);
00420 return ret;
00421 }
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474 static gboolean on_pagebar_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
00475 {
00476 GtkPagebar* pagebar = GTK_PAGEBAR(user_data);
00477 int x=event->x;
00478 int y=event->y;
00479 int i;
00480 int j;
00481
00482
00483 ENTER(0);
00484
00485 PRINT_TRACE(("button_press_event -- location %dx%d - %dx%d \n",(int)event->x,(int)event->y,(int)event->x_root,(int)event->y_root));
00486
00487
00488 if (x>=pagebar->barXPos+(pagebar->barWidth-pagebar->cpiWidth)/2 && x<=pagebar->barXPos+(pagebar->barWidth+pagebar->cpiWidth)/2 &&
00489 y>=pagebar->barYPos+(pagebar->barHeight-pagebar->cpiHeight)/2 && y<=pagebar->barYPos+(pagebar->barHeight+pagebar->cpiHeight)/2)
00490 {
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513 pagebar->zoomMode=!pagebar->zoomMode;
00514 gtk_pagebar_draw(pagebar);
00515
00516
00517
00518 display_update_request_screen_refresh(MAIN_WINDOW_EXPOSE_LEVEL, (void*) DM_QUALITY_TYPING);
00519 }
00520 else
00521 {
00522 if (pagebar->zoomMode==0) {
00523 int smallBarWidth;
00524 smallBarWidth = (pagebar->barWidth-pagebar->cpiWidth)/2-pagebar->pageFieldWidth;
00525
00526 if (x<pagebar->barXPos+(pagebar->barWidth-pagebar->cpiWidth)/2 && pagebar->currentPage!=1) {
00527 i=pagebar->barXPos+(pagebar->barWidth-pagebar->cpiWidth)/2-x;
00528 i=i*(pagebar->pagecount-2)/(smallBarWidth);
00529 if (i<pagebar->currentPage-1) {
00530 pagebar->currentPage-=(i+1);
00531 }
00532 else {
00533 pagebar->currentPage=1;
00534 }
00535 currentPageChanged(pagebar);
00536 }
00537
00538 else if (x>pagebar->barXPos+(pagebar->barWidth+pagebar->cpiWidth)/2 && pagebar->currentPage!=pagebar->pagecount) {
00539 i=x-(pagebar->barXPos+(pagebar->barWidth+pagebar->cpiWidth)/2);
00540 i=i*(pagebar->pagecount-2)/(smallBarWidth);
00541 if (i<pagebar->pagecount-pagebar->currentPage) {
00542 pagebar->currentPage+=(i+1);
00543 }
00544 else {
00545 pagebar->currentPage=pagebar->pagecount;
00546 }
00547 currentPageChanged(pagebar);
00548 }
00549 }
00550 else if (pagebar->zoomMode==1) {
00551
00552
00553 j = ((pagebar->barWidth-pagebar->cpiWidth)/2-pagebar->scrollButtonWidth)/pagebar->pageFieldWidth;
00554
00555 if (x<pagebar->barXPos+(pagebar->barWidth-pagebar->cpiWidth)/2 &&
00556 x>pagebar->barXPos+(pagebar->barWidth-pagebar->cpiWidth)/2-j*pagebar->pageFieldWidth &&
00557 pagebar->currentPage!=1)
00558 {
00559 i=pagebar->barXPos+(pagebar->barWidth-pagebar->cpiWidth)/2-x;
00560 i/=pagebar->pageFieldWidth;
00561 if (i<pagebar->currentPage-1 && i<j)
00562 {
00563 pagebar->currentPage-=(i+1);
00564 currentPageChanged(pagebar);
00565 }
00566 }
00567
00568 else if (x>pagebar->barXPos+(pagebar->barWidth+pagebar->cpiWidth)/2 &&
00569 x<pagebar->barXPos+(pagebar->barWidth+pagebar->cpiWidth)/2+j*pagebar->pageFieldWidth &&
00570 pagebar->currentPage!=pagebar->pagecount)
00571 {
00572 i=x-(pagebar->barXPos+(pagebar->barWidth+pagebar->cpiWidth)/2);
00573 i/=pagebar->pageFieldWidth;
00574 if (i<pagebar->pagecount-pagebar->currentPage && i<j)
00575 {
00576 pagebar->currentPage+=(i+1);
00577 currentPageChanged(pagebar);
00578 }
00579 }
00580
00581
00582 else if (SCROLLBOX_LEFT == pagebar_scrollbox_hitTest(pagebar, x, y))
00583 {
00584
00585
00586 pagebar->currentPage-=2*pagebar->maxItems+1;
00587 if (pagebar->currentPage<1)
00588 pagebar->currentPage=1;
00589
00590 currentPageChanged(pagebar);
00591
00592 }
00593 else if (SCROLLBOX_RIGHT == pagebar_scrollbox_hitTest(pagebar, x, y))
00594 {
00595 pagebar->currentPage+=2*pagebar->maxItems+1;
00596 if (pagebar->currentPage>pagebar->pagecount)
00597 pagebar->currentPage=pagebar->pagecount;
00598
00599 currentPageChanged(pagebar);
00600 }
00601 }
00602 }
00603
00604 LEAVE(0);
00605
00606 return TRUE;
00607 }
00608
00609
00610 GType gtk_pagebar_get_type (void)
00611 {
00612 static GType pagebar_type = 0;
00613
00614 if (!pagebar_type)
00615 {
00616 static const GTypeInfo pagebar_info =
00617 {
00618 sizeof (GtkPagebarClass),
00619 NULL,
00620 NULL,
00621 (GClassInitFunc) gtk_pagebar_class_init,
00622 NULL,
00623 NULL,
00624 sizeof (GtkPagebar),
00625 0,
00626 (GInstanceInitFunc) gtk_pagebar_init,
00627 };
00628
00629 pagebar_type = g_type_register_static (GTK_TYPE_EVENT_BOX, "Pagebar", &pagebar_info, 0);
00630 }
00631
00632 return pagebar_type;
00633 }
00634
00635 static void gtk_pagebar_class_init (GtkPagebarClass *klass)
00636 {
00637 GtkObjectClass *object_class;
00638
00639 ENTER(0);
00640
00641 object_class = (GtkObjectClass *) klass;
00642
00643
00644
00645 pagebar_signals[PAGE_SELECTED] =
00646 g_signal_new ("pagebar_page_selected",
00647 G_OBJECT_CLASS_TYPE (object_class),
00648 G_SIGNAL_RUN_LAST,
00649 G_STRUCT_OFFSET (GtkPagebarClass, pagebar_page_selected),
00650 NULL, NULL,
00651 gtk_marshal_VOID__INT,
00652 G_TYPE_NONE,
00653 1,
00654 G_TYPE_INT);
00655 LEAVE(0);
00656 }
00657
00658 static void gtk_pagebar_init(GtkPagebar *pagebar)
00659 {
00660 ENTER(0);
00661
00662
00663 pagebar->drawingArea = gtk_drawing_area_new();
00664
00665 gtk_widget_set_events (GTK_WIDGET(pagebar->drawingArea), GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK );
00666
00667 gtk_container_add(GTK_CONTAINER(pagebar),pagebar->drawingArea);
00668
00669 gtk_signal_connect(GTK_OBJECT(pagebar->drawingArea), "expose-event", GTK_SIGNAL_FUNC(on_pagebar_exposed),pagebar);
00670 gtk_signal_connect(GTK_OBJECT(pagebar->drawingArea), "configure-event", GTK_SIGNAL_FUNC(on_pagebar_configured),pagebar);
00671
00672 g_signal_connect (G_OBJECT (pagebar->drawingArea), "button_press_event", G_CALLBACK (on_pagebar_button_press_event), pagebar);
00673
00674 g_signal_connect (G_OBJECT (pagebar->drawingArea), "button_release_event", G_CALLBACK (on_pagebar_button_release_event), pagebar);
00675
00676 erIpcStartClient(ER_APABI_VIEWER_CHANNEL, &apabiChannel );
00677 erIpcStartClient(ER_PDF_VIEWER_CHANNEL, &pdfChannel );
00678 erIpcStartClient(ER_XHTML_VIEWER_CHANNEL, &xhtmlChannel );
00679 erIpcStartClient(ER_CONTENTLISTER_CHANNEL, &contentListerChannel);
00680 erIpcStartClient(ER_SCRIBBLE_CHANNEL, &scribbleChannel );
00681 erIpcStartClient(ER_SETUP_CHANNEL, &setupChannel );
00682 erIpcStartClient(ER_CONNECT_CHANNEL, &connectChannel );
00683 erIpcStartClient(ER_EBA_VIEWER_CHANNEL, &ebaChannel );
00684 erIpcStartClient(ER_ARINC_VIEWER_CHANNEL, &arincViewerChannel );
00685 erIpcStartClient(ER_ARINC_MENU_CHANNEL, &arincMenuChannel );
00686 erIpcStartClient(ER_MOBIPOCKET_VIEWER_CHANNEL, &mobipocketChannel );
00687
00688 gtk_widget_show(pagebar->drawingArea);
00689
00690 LEAVE(0);
00691 }
00692
00693 GtkWidget* gtk_pagebar_new()
00694 {
00695 GtkPagebar* pagebar;
00696 PangoFontDescription* fontdesc;
00697
00698 ENTER(0);
00699
00700 pagebar = (GtkPagebar*) g_object_new(GTK_PAGEBAR_TYPE,NULL);
00701
00702 memset(pagebar->bitmaps, 0, sizeof(pagebar->bitmaps));
00703 pagebar->bookmarks = NULL;
00704 pagebar->notes = NULL;
00705
00706
00707 pagebar_reset_values(pagebar);
00708 pagebar_load_bitmaps(pagebar);
00709
00710 framebuffer_device = open("/dev/fb0", O_RDWR);
00711
00712 PRINT_DEBUG(("bar format %dx%d\n",pagebar->drawAreaWidth,pagebar->drawAreaHeight));
00713
00714 gtk_drawing_area_size(GTK_DRAWING_AREA(pagebar->drawingArea),pagebar->drawAreaWidth,pagebar->drawAreaHeight);
00715
00716 pagebar->pangolayout=gtk_widget_create_pango_layout(GTK_WIDGET(pagebar->drawingArea),"X");
00717 fontdesc = pango_font_description_from_string("Bitstream Vera 6.5");
00718
00719 pango_layout_set_font_description(pagebar->pangolayout, fontdesc);
00720 pango_font_description_free(fontdesc);
00721 pango_layout_get_pixel_size(pagebar->pangolayout,&pagebar->barFontWidth,&pagebar->barFontHeight);
00722
00723 pagebar->cpiFontWidth = pagebar->barFontWidth;
00724
00725 PRINT_DEBUG(("text format %dx%d\n",pagebar->barFontWidth,pagebar->barFontHeight));
00726
00727
00728
00729 LEAVE(0);
00730
00731 return GTK_WIDGET(pagebar);
00732 }
00733
00734
00735 static int drawMarkers(GtkPagebar* pagebar, int width, int y, int bitmap, int* markers, int count, int maxValue) {
00736 int i;
00737 int j;
00738 int x;
00739
00740 ENTER(1);
00741
00742 for (i=0; i<count && markers[i]!=-1; i++) {
00743
00744 j=markers[i]*pagebar->pagecount/maxValue;
00745 if (j>pagebar->currentPage) {
00746 x = pagebar->barXPos+(pagebar->barWidth+pagebar->cpiWidth)/2;
00747
00748 if (j>=pagebar->pagecount)
00749 x += (((pagebar->pagecount-pagebar->currentPage-1)*width/(pagebar->pagecount-2))&0xFFFFFFFC)+pagebar->pageFieldWidth/2;
00750 else
00751 x += (((pagebar->pagecount-pagebar->currentPage-1)*width/(pagebar->pagecount-2))*(j-pagebar->currentPage-1)/(pagebar->pagecount-1-pagebar->currentPage-1))&0xFFFFFFFC;
00752
00753 if (x-(pagebar->barXPos+(pagebar->barWidth+pagebar->cpiWidth)/2)<2)
00754 x+=3;
00755
00756 #ifdef USE_BITMAPS
00757 gdk_draw_pixbuf(pagebar->pixmap, NULL, pagebar->bitmaps[bitmap], 0,0,x-2,y,-1,-1,GDK_RGB_DITHER_NONE,0,0);
00758 #else
00759 gdk_draw_line(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, x, y, x, y+6);
00760 #endif
00761 }
00762 else if (j<pagebar->currentPage) {
00763 x = pagebar->barXPos+(pagebar->barWidth-pagebar->cpiWidth)/2-2;
00764 if (j==1)
00765 x -= ((width*(pagebar->currentPage-2)/(pagebar->pagecount-2))&0xFFFFFFFC) + pagebar->pageFieldWidth/2;
00766 else
00767 x -= (width*(pagebar->currentPage-2)/(pagebar->pagecount-2)*(pagebar->currentPage-j-1)/(pagebar->currentPage-3))&0xFFFFFFFC;
00768
00769 #ifdef USE_BITMAPS
00770 gdk_draw_pixbuf(pagebar->pixmap, NULL, pagebar->bitmaps[bitmap], 0,0,x-2,y,-1,-1,GDK_RGB_DITHER_NONE,0,0);
00771 #else
00772 gdk_draw_line(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, x, y, x, y+6);
00773 #endif
00774 }
00775 }
00776
00777 LEAVE(1);
00778
00779 return 0;
00780 }
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791 int gtk_pagebar_draw(GtkPagebar* pagebar)
00792 {
00793 int ret = 0;
00794
00795 ENTER(1);
00796
00797
00798 if (!IS_GTK_PAGEBAR(pagebar)) {
00799 RETURN(-1);
00800 }
00801
00802
00803 if (!pagebar->pixmap)
00804 RETURN(-1);
00805
00806
00807 if (pagebar->lastDrawAreaXPos!=pagebar->drawAreaXPos || pagebar->lastDrawAreaYPos!=pagebar->drawAreaYPos) {
00808 pagebar->lastDrawAreaXPos=pagebar->drawAreaXPos;
00809 pagebar->lastDrawAreaYPos=pagebar->drawAreaYPos;
00810 gtk_window_move(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pagebar))), pagebar->drawAreaXPos, pagebar->drawAreaYPos);
00811 }
00812
00813
00814 if (pagebar->lastDrawAreaWidth!=pagebar->drawAreaWidth || pagebar->lastDrawAreaHeight!=pagebar->drawAreaHeight) {
00815 pagebar->lastDrawAreaWidth=pagebar->drawAreaWidth;
00816 pagebar->lastDrawAreaHeight=pagebar->drawAreaHeight;
00817 gtk_widget_set_size_request(GTK_WIDGET(gtk_widget_get_toplevel(GTK_WIDGET(pagebar))), pagebar->drawAreaWidth, pagebar->drawAreaHeight);
00818 }
00819
00820
00821 gdk_draw_rectangle (pagebar->pixmap,
00822 GTK_WIDGET(pagebar->drawingArea)->style->white_gc,
00823 TRUE,
00824 pagebar->barXPos,
00825 pagebar->barYPos,
00826 pagebar->barWidth,
00827 pagebar->barHeight);
00828
00829 if (!pagebar->show)
00830 RETURN(-1);
00831
00832
00833 pagebar_calculate(pagebar);
00834
00835
00836 pagebar_draw_cpi(pagebar);
00837
00838 if (pagebar->pagecount==1)
00839 RETURN(0);
00840
00841
00842 pagebar_draw_left(pagebar);
00843 pagebar_draw_right(pagebar);
00844 end:
00845
00846 gtk_widget_queue_draw(GTK_WIDGET(pagebar->drawingArea));
00847 PRINT_TRACE(("gtk_widget_queue_draw_area called \n"));
00848
00849 LEAVE(1);
00850
00851 return ret;
00852 }
00853
00854
00855
00856
00857
00858
00859 gboolean pagebar_scrollbox_needLeft(GtkPagebar *pagebar)
00860 {
00861 if (pagebar->currentPage > pagebar->maxItems + 1)
00862 return TRUE;
00863 return FALSE;
00864 }
00865
00866 gboolean pagebar_scrollbox_needRight(GtkPagebar *pagebar)
00867 {
00868 if (pagebar->pagecount - pagebar->currentPage > pagebar->maxItems)
00869 return TRUE;
00870 return FALSE;
00871 }
00872
00873 int pagebar_scrollbox_hitTest(GtkPagebar *pagebar, int x, int y)
00874 {
00875 int width = pagebar->maxItems *pagebar->pageFieldWidth;
00876
00877
00878 if (x < pagebar->cpiXPos - width &&
00879 x > pagebar->cpiXPos - width - pagebar->scrollButtonWidth &&
00880 pagebar_scrollbox_needLeft(pagebar))
00881 {
00882 return SCROLLBOX_LEFT;
00883 }
00884
00885 if (x > pagebar->cpiXPos + pagebar->cpiWidth + width &&
00886 x < pagebar->cpiXPos + pagebar->cpiWidth + width + pagebar->scrollButtonWidth &&
00887 pagebar_scrollbox_needRight(pagebar))
00888 {
00889 return SCROLLBOX_RIGHT;
00890 }
00891
00892 return SCROLLBOX_NONE;
00893 }
00894
00895
00896
00897
00898
00899
00900 void pagebar_calculate(GtkPagebar *pagebar)
00901 {
00902 if (PAGEBAR_ORIENTATION_X == pagebar->orientation)
00903 {
00904 pagebar->cpiXPos = pagebar->barXPos + (pagebar->barWidth-pagebar->cpiWidth)/2;
00905 pagebar->cpiYPos = pagebar->barYPos - (pagebar->cpiHeight -pagebar->barHeight)/2;
00906 pagebar->maxItems = ((pagebar->barWidth-pagebar->cpiWidth)/2-pagebar->scrollButtonWidth)/pagebar->pageFieldWidth;
00907 }
00908 else if (PAGEBAR_ORIENTATION_Y == pagebar->orientation)
00909 {
00910
00911 pagebar->cpiXPos = (pagebar->barWidth-pagebar->cpiWidth)/2;
00912 pagebar->cpiYPos = pagebar->barYPos + (pagebar->barHeight - pagebar->cpiHeight)/2;
00913 pagebar->maxItems = ((pagebar->barHeight - pagebar->cpiHeight)/2-pagebar->scrollButtonHeight)/pagebar->pageFieldHeight;
00914 }
00915 }
00916
00917
00918
00919
00920 void pagebar_draw_cpi(GtkPagebar *pagebar)
00921 {
00922
00923
00924 int canZoom = 1;
00925 int x = 0, y = 0, w = 0, h = 0;
00926 char pageStr[16] = {0};
00927 if (pagebar->pagecount<= pagebar->maxItems *2+1) {
00928 pagebar->zoomMode = 1;
00929 canZoom = 0;
00930 }
00931
00932
00933 gtk_widget_hide(pagebar->pageEntry);
00934
00935
00936 #ifdef USE_BITMAPS
00937 gdk_draw_pixbuf(pagebar->pixmap, NULL, pagebar->bitmaps[bitmap_CPI], 0, 0,
00938 pagebar->cpiXPos, pagebar->cpiYPos, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
00939 #else
00940 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, FALSE,
00941 pagebar->cpiXPos, pagebar->cpiYPos, pagebar->cpiWidth, h);
00942 #endif
00943
00944
00945 if (pagebar->currentPageOffset <= PAGEBAR_DEFAULT_CURRENTPAGEOFFSET)
00946 {
00947 int i = pagebar->currentPageOffset*pagebar->pageOffsetWidth/PAGEBAR_DEFAULT_CURRENTPAGEOFFSET;
00948 x = pagebar->cpiXPos;
00949 y = pagebar->cpiYPos;
00950 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, TRUE,
00951 x+pagebar->pageOffsetXOffset,
00952 y+pagebar->pageOffsetYOffset,
00953 i,
00954 pagebar->pageOffsetHeight);
00955 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->white_gc, TRUE,
00956 x+pagebar->pageOffsetXOffset+i,
00957 y+pagebar->pageOffsetYOffset,
00958 pagebar->pageOffsetWidth-i,
00959 pagebar->pageOffsetHeight);
00960 }
00961
00962
00963 sprintf(pageStr, "%d", pagebar->currentPage);
00964 pango_layout_set_text(pagebar->pangolayout, pageStr, -1);
00965 pango_layout_get_pixel_size(pagebar->pangolayout,&w,&h);
00966 x = pagebar->barXPos + (pagebar->barWidth-w)/2;
00967 y = pagebar->barYPos + (pagebar->barHeight-h)/2;
00968 gdk_draw_layout(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, x, y, pagebar->pangolayout);
00969 }
00970
00971
00972
00973
00974
00975
00976 void pagebar_draw_left(GtkPagebar *pagebar)
00977 {
00978 int w = 0, x = 0, y = 0;
00979 int i = 0, j = 0;
00980 char pageStr[16] = {0};
00981 int left = 1;
00982
00983
00984 x = pagebar->cpiXPos;
00985 y = pagebar->cpiYPos + (pagebar->cpiHeight - pagebar->pageFieldHeight)/2;
00986
00987
00988 if (pagebar->pagecount > 2 * pagebar->maxItems + 1 && 0 == pagebar->zoomMode)
00989 {
00990
00991 w = (pagebar->barWidth-pagebar->cpiWidth)/2-pagebar->pageFieldWidth;
00992 y = pagebar->barYPos+(pagebar->barHeight-pagebar->pageFieldHeight)/2;
00993 x = pagebar->barXPos+(pagebar->barWidth-pagebar->cpiWidth)/2-2;
00994 if (pagebar->currentPage!=1)
00995 {
00996 for (i=0; i<w*(pagebar->currentPage-2)/(pagebar->pagecount-2)/4; i++)
00997 {
00998 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, FALSE, x, y, 1, pagebar->pageFieldHeight);
00999 x-=4;
01000 }
01001 x=x-pagebar->pageFieldWidth+1;
01002 #ifdef USE_BITMAPS
01003 gdk_draw_pixbuf(pagebar->pixmap, NULL, pagebar->bitmaps[bitmap_PageField], 0,0,x,y,-1,-1,GDK_RGB_DITHER_NONE,0,0);
01004 #else
01005 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, FALSE, x, y, pagebar->pageFieldWidth, pagebar->pageFieldHeight);
01006 #endif
01007 sprintf(pageStr, "1");
01008 pango_layout_set_text(pagebar->pangolayout, pageStr, -1);
01009 pango_layout_get_pixel_size(pagebar->pangolayout,&i,&j);
01010 gdk_draw_layout(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, x+(pagebar->pageFieldWidth-i)/2, y+(pagebar->pageFieldHeight-j)/2, pagebar->pangolayout);
01011 }
01012
01013 if (pagebar->bookmarkMaxValue)
01014 drawMarkers(pagebar, w, y-6, bitmap_Bookmark, pagebar->bookmarks, pagebar->bookmarkCount, pagebar->bookmarkMaxValue);
01015 if (pagebar->notesMaxValue)
01016 drawMarkers(pagebar, w, y+pagebar->pageFieldHeight, bitmap_Note, pagebar->notes, pagebar->noteCount, pagebar->notesMaxValue);
01017 }
01018 else
01019 {
01020
01021 for(left; left < pagebar->currentPage && left <= pagebar->maxItems; ++left)
01022 {
01023 x -= pagebar->pageFieldWidth;
01024 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->white_gc, FALSE, x, y, 1, pagebar->pageFieldHeight);
01025
01026 #ifdef USE_BITMAPS
01027 gdk_draw_pixbuf(pagebar->pixmap, NULL, pagebar->bitmaps[bitmap_PageField], 0,0,x,y,-1,-1,GDK_RGB_DITHER_NONE,0,0);
01028 #else
01029 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, FALSE, x, y, pagebar->pageFieldWidth, pagebar->pageFieldHeight);
01030 #endif
01031
01032 sprintf(pageStr, "%d", pagebar->currentPage - left );
01033 pango_layout_set_text(pagebar->pangolayout, pageStr, -1);
01034 pango_layout_get_pixel_size(pagebar->pangolayout,&i,&j);
01035 gdk_draw_layout(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, x+(pagebar->pageFieldWidth-i)/2, y+(pagebar->pageFieldHeight-j)/2, pagebar->pangolayout);
01036 }
01037
01038
01039 if (pagebar_scrollbox_needLeft(pagebar))
01040 {
01041 x = pagebar->cpiXPos - pagebar->maxItems * pagebar->pageFieldWidth;
01042 x-=pagebar->scrollButtonWidth;
01043 #ifdef USE_BITMAPS
01044 gdk_draw_pixbuf(pagebar->pixmap, NULL, pagebar->bitmaps[bitmap_ScrollLeft], 0,0,x,y,-1,-1,GDK_RGB_DITHER_NONE,0,0);
01045 #else
01046 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, TRUE, x, y, pagebar->scrollButtonWidth, pagebar->pageFieldHeight);
01047 #endif
01048 }
01049 else
01050 {
01051
01052 }
01053
01054 i = pagebar->maxItems;
01055 for (j=0; pagebar->bookmarkMaxValue > 0 && j<pagebar->bookmarkCount && pagebar->bookmarks[j]!=-1; j++)
01056 {
01057 int page;
01058 page=pagebar->bookmarks[j]*pagebar->pagecount/pagebar->bookmarkMaxValue;
01059 if (page<pagebar->currentPage && page>=pagebar->currentPage-i)
01060 x=pagebar->barXPos+(pagebar->barWidth-pagebar->cpiWidth)/2-(pagebar->currentPage-page)*pagebar->pageFieldWidth+pagebar->pageFieldWidth/2;
01061 else if (page>pagebar->currentPage && page<=pagebar->currentPage+i)
01062 x=pagebar->barXPos+(pagebar->barWidth+pagebar->cpiWidth)/2+(page-pagebar->currentPage-1)*pagebar->pageFieldWidth+pagebar->pageFieldWidth/2;
01063 else
01064 continue;
01065
01066 #ifdef USE_BITMAPS
01067 gdk_draw_pixbuf(pagebar->pixmap, NULL, pagebar->bitmaps[bitmap_Bookmark], 0,0,x,y-6,-1,-1,GDK_RGB_DITHER_NONE,0,0);
01068 #else
01069 gdk_draw_line(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, x, y-6, x, y);
01070 #endif
01071 }
01072 for (j=0; pagebar->notesMaxValue > 0 && j<pagebar->noteCount && pagebar->notes[j]!=-1; j++)
01073 {
01074 int page;
01075 page=pagebar->notes[j]*pagebar->pagecount/pagebar->notesMaxValue;
01076 if (page<pagebar->currentPage && page>=pagebar->currentPage-i)
01077 x=pagebar->barXPos+(pagebar->barWidth-pagebar->cpiWidth)/2-(pagebar->currentPage-page)*pagebar->pageFieldWidth+pagebar->pageFieldWidth/2;
01078 else if (page>pagebar->currentPage && page<=pagebar->currentPage+i)
01079 x=pagebar->barXPos+(pagebar->barWidth+pagebar->cpiWidth)/2+(page-pagebar->currentPage-1)*pagebar->pageFieldWidth+pagebar->pageFieldWidth/2;
01080 else
01081 continue;
01082
01083 #ifdef USE_BITMAPS
01084 gdk_draw_pixbuf(pagebar->pixmap, NULL, pagebar->bitmaps[bitmap_Note], 0,0,x,y+pagebar->pageFieldHeight,-1,-1,GDK_RGB_DITHER_NONE,0,0);
01085 #else
01086 gdk_draw_line(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, x, y+pagebar->pageFieldHeight, x, y+pagebar->pageFieldHeight+6);
01087 #endif
01088 }
01089 }
01090 }
01091
01092 void pagebar_draw_right(GtkPagebar *pagebar)
01093 {
01094 int w = 0, x = 0, y = 0;
01095 int i = 0, j = 0;
01096 char pageStr[16] = {0};
01097 int right = 1;
01098
01099
01100 x = pagebar->cpiXPos + pagebar->cpiWidth;
01101 y = pagebar->cpiYPos + (pagebar->cpiHeight - pagebar->pageFieldHeight)/2;
01102
01103
01104 if (pagebar->pagecount > 2 * pagebar->maxItems + 1 && 0 == pagebar->zoomMode)
01105 {
01106
01107 w = (pagebar->barWidth-pagebar->cpiWidth)/2-pagebar->pageFieldWidth;
01108 x = pagebar->barXPos+(pagebar->barWidth+pagebar->cpiWidth)/2;
01109 y = pagebar->barYPos+(pagebar->barHeight-pagebar->pageFieldHeight)/2;
01110 if (pagebar->currentPage!=pagebar->pagecount)
01111 {
01112 for (i=0; i<w*(pagebar->pagecount-pagebar->currentPage-1)/(pagebar->pagecount-2)/4; i++)
01113 {
01114 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, FALSE, x, y, 1, pagebar->pageFieldHeight);
01115 x+=4;
01116 }
01117 #ifdef USE_BITMAPS
01118 gdk_draw_pixbuf(pagebar->pixmap, NULL, pagebar->bitmaps[bitmap_PageField], 0,0,x,y,-1,-1,GDK_RGB_DITHER_NONE,0,0);
01119 #else
01120 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, FALSE, x, y, pagebar->pageFieldWidth, pagebar->pageFieldHeight);
01121 #endif
01122 sprintf(pageStr, "%d", pagebar->pagecount);
01123 pango_layout_set_text(pagebar->pangolayout, pageStr, -1);
01124 pango_layout_get_pixel_size(pagebar->pangolayout,&i,&j);
01125 gdk_draw_layout(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, x+(pagebar->pageFieldWidth-i)/2, y+(pagebar->pageFieldHeight-j)/2, pagebar->pangolayout);
01126 }
01127 }
01128 else
01129 {
01130
01131 for(right; right <= pagebar->pagecount - pagebar->currentPage && right <= pagebar->maxItems; ++right)
01132 {
01133 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->white_gc, FALSE, x, y, 1, pagebar->pageFieldHeight);
01134
01135 #ifdef USE_BITMAPS
01136 gdk_draw_pixbuf(pagebar->pixmap, NULL, pagebar->bitmaps[bitmap_PageField], 0,0,x,y,-1,-1,GDK_RGB_DITHER_NONE,0,0);
01137 #else
01138 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, FALSE, x, y, pagebar->pageFieldWidth, pagebar->pageFieldHeight);
01139 #endif
01140
01141 sprintf(pageStr, "%d", pagebar->currentPage + right );
01142 pango_layout_set_text(pagebar->pangolayout, pageStr, -1);
01143 pango_layout_get_pixel_size(pagebar->pangolayout,&i,&j);
01144 gdk_draw_layout(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, x+(pagebar->pageFieldWidth-i)/2, y+(pagebar->pageFieldHeight-j)/2, pagebar->pangolayout);
01145 x += pagebar->pageFieldWidth;
01146 }
01147
01148
01149 if (pagebar_scrollbox_needRight(pagebar))
01150 {
01151 x = pagebar->cpiXPos + pagebar->maxItems * pagebar->pageFieldWidth;
01152 x += pagebar->cpiWidth;
01153 #ifdef USE_BITMAPS
01154 gdk_draw_pixbuf(pagebar->pixmap, NULL, pagebar->bitmaps[bitmap_ScrollRight], 0,0,x,y,-1,-1,GDK_RGB_DITHER_NONE,0,0);
01155 #else
01156 gdk_draw_rectangle(pagebar->pixmap, GTK_WIDGET(pagebar->drawingArea)->style->black_gc, TRUE, x, y, pagebar->scrollButtonWidth, pagebar->pageFieldHeight);
01157 #endif
01158
01159 }
01160 else
01161 {
01162
01163 }
01164 }
01165 }
01166
01167
01168 gboolean on_idle(gpointer data)
01169 {
01170 GtkPagebar *pagebar = (GtkPagebar *)data;
01171 gdk_threads_enter();
01172 gdk_flush();
01173 gdk_threads_leave();
01174
01175 erClientChannel_t channel;
01176 switch (pagebar->currentApp)
01177 {
01178 case ER_APABI_VIEWER_UA_ID:
01179 channel = apabiChannel;
01180 break;
01181 case ER_PDF_VIEWER_UA_ID:
01182 channel = pdfChannel;
01183 break;
01184 case ER_XHTML_VIEWER_UA_ID:
01185 channel = xhtmlChannel;
01186 break;
01187 case ER_SCRIBBLE_UA_ID:
01188 channel = scribbleChannel;
01189 break;
01190 case ER_CONTENT_LISTER_UA_ID:
01191 channel = contentListerChannel;
01192 break;
01193 case ER_SETUP_UA_ID:
01194 channel = setupChannel;
01195 break;
01196 case ER_CONNECT_UA_ID:
01197 channel = connectChannel;
01198 break;
01199 case ER_EBA_VIEWER_UA_ID:
01200 channel = ebaChannel;
01201 break;
01202 case ER_ARINC_VIEWER_UA_ID:
01203 channel = arincViewerChannel;
01204 break;
01205 case ER_ARINC_MENU_UA_ID:
01206 channel = arincMenuChannel;
01207 break;
01208 default:
01209 return FALSE;
01210 }
01211
01212 pbReportSynchronise(channel, pagebar->currentApp);
01213 return FALSE;
01214 }
01215
01216 void pagebar_reportSync(GtkPagebar *pagebar)
01217 {
01218 gtk_idle_add(on_idle, (gpointer) pagebar);
01219 }
01220