00001 #ifndef MediaTable_TableWindow_h
00002 #define MediaTable_TableWindow_h
00003
00004 #include "TableWindowColumn.h"
00005 #include "OglGui/WindowScrollBar.h"
00006 #include "OglGui/ScrollWnd.h"
00007
00008 #include "TableDataViewController.h"
00009
00010 namespace Impala {
00011 namespace Application {
00012 namespace MediaTable {
00013
00014 class TableWindow : public OglGui::Window,
00015 OglGui::ScrollBarListener,
00016 ColumnListener,
00017 public TableDataViewController
00018 {
00019 public:
00020 typedef OglGui::Window Window;
00021 typedef OglGui::ScrollWnd ScrollWnd;
00022 typedef OglGui::ScrollBar ScrollBar;
00023 typedef OglGui::ScrollBarListener ScrollBarListener;
00024 typedef OglGui::WindowScrollBar WindowScrollBar;
00025 typedef Impala::Core::Array::Array2dVec3UInt8 Array2dVec3UInt8;
00026 typedef OglGui::MenuTopPane MenuTopPane;
00027 typedef OglGui::Menu Menu;
00028
00029 TableWindow(Window* parent, TableDataView* view, int width, int height):
00030 Window(parent, width, height),
00031 TableDataViewController(view)
00032 {
00033 Init(width, height);
00034 }
00035
00036 TableWindow(Window* parent, TableDataView* view, int x, int y,
00037 int width, int height) :
00038 Window(parent, x, y, width, height),
00039 TableDataViewController(view)
00040 {
00041 Init(width, height);
00042 }
00043
00044 private:
00045 void AddColumnFromDescription(TableColumn* d,
00046 bool dynamicWidth=false)
00047 {
00048 TableWindowColumn *p = new TableWindowColumn(this,this,GetTableDataView(),d->GetName(),d->GetWidth());
00049
00050 if (dynamicWidth)
00051 p->SetColumnWidthDynamic(true);
00052 switch (d->GetType())
00053 {
00054 case TableDataSource::TYPE_TEXT:
00055 p->SetDisplayMode(TableWindowCell::DISPLAY_TEXT);
00056 break;
00057 case TableDataSource::TYPE_INT:
00058 p->SetSortType(TableDataSource::TYPE_INT);
00059 p->SetDisplayMode(TableWindowCell::DISPLAY_NUMBER);
00060 break;
00061 case TableDataSource::TYPE_DOUBLE:
00062 p->SetSortType(TableDataSource::TYPE_DOUBLE);
00063 p->SetDisplayMode(TableWindowCell::DISPLAY_NUMBER);
00064 break;
00065 case TableDataSource::TYPE_IMAGE:
00066 p->SetDisplayMode(TableWindowCell::DISPLAY_IMAGE);
00067 if (mZoomViewCache == 0)
00068 SetZoomViewCache(p->GetViewCache());
00069 break;
00070 case TableDataSource::TYPE_NORMALIZEDVALUE:
00071 if (dynamicWidth)
00072 p->SetDisplayMode(TableWindowCell::DISPLAY_FILLED,d->GetVisParam());
00073 else
00074 p->SetDisplayMode(TableWindowCell::DISPLAY_DOT, d->GetVisParam());
00075 break;
00076 }
00077 AddColumn(p);
00078 }
00079
00080 void AddColumn(TableWindowColumn* col, int insertAt=-1)
00081 {
00082 if (insertAt==-1 || insertAt>mColumns.size()-1)
00083 mColumns.push_back(col);
00084 else
00085 mColumns.insert(mColumns.begin()+insertAt+1,col);
00086 col->SetAllowReposition(false);
00087 }
00088
00089 public:
00090 void AddColumnsFromDataSource()
00091 {
00092 std::vector<TableColumn*> c = GetTableDataView()->GetColumns(true, false);
00093 ILOG_DEBUG("Adding " << c.size() << " fixed columns from datasource");
00094 int swidth = 0;
00095 for (int i=0; i<c.size();i++)
00096 {
00097 AddColumnFromDescription(c[i]);
00098 if (c[i]->GetType() == TableDataSource::TYPE_IMAGE)
00099 {
00100 ILOG_DEBUG("Found image column: " << c[i]->GetName());
00101 mImageColumn = c[i]->GetName();
00102 }
00103 swidth += c[i]->GetWidth();
00104 }
00105
00106 mStaticColumnWidth = swidth;
00107 mStaticColumnCount = c.size();
00108
00109 std::vector<TableColumn*> d=GetTableDataView()->GetColumns(false, true);
00110 ILOG_DEBUG("Adding " << d.size() << " dynamic columns from datasource");
00111 for (int i=0; i<d.size();i++)
00112 {
00113 AddColumnFromDescription(d[i], true);
00114 }
00115
00116 HandleColumnPositions();
00117 HandleLayoutChange();
00118 }
00119
00120 void SetGetOglImageByIdInterface(OglGui::GetOglImageByIdInterface* i)
00121 {
00122 std::vector<TableWindowColumn*>::iterator iter;
00123 for(iter = mColumns.begin(); iter != mColumns.end(); iter++)
00124 {
00125 TableViewCache* cache = (*iter)->GetViewCache();
00126 if(cache)
00127 cache->SetGetOglImageByIdInterface(i);
00128 }
00129 }
00130
00131
00132 void HandleColumnPositions()
00133 {
00134 int x,y,w,h;
00135 int mx = 0;
00136 int maxw = W() - 60;
00137 int wpc = 20;
00138
00139
00140 for (int i=0; i<mColumns.size(); i++)
00141 {
00142 mColumns[i]->GetDimensions(x,y,w,h);
00143 x = mx;
00144 if (mColumns[i]->GetColumnWidthDynamic())
00145 w = wpc;
00146 mx += w + 2;
00147 }
00148 mHorScrollBar->SetRange(mx, W());
00149
00150
00151 UpdateHorColumnPositions();
00152 }
00153
00154 int GetColumnForX(int mx)
00155 {
00156 int x,y,w,h,xp = -mHorScrollPosition;
00157 for (int i=0; i<mColumns.size(); i++)
00158 {
00159 mColumns[i]->GetDimensions(x,y,w,h);
00160 xp += (w + 2);
00161 if (xp > mx)
00162 return i;
00163 }
00164 return 0;
00165 }
00166
00167
00168 void UpdateHorColumnPositions()
00169 {
00170 int x,y,w,h;
00171 int mx = -mHorScrollPosition;
00172 int maxw = W() - 60;
00173 int wpc = 20;
00174
00175 TableWindowColumn::SetUpdatingColumnWidths(true);
00176 for (int i=0; i<mColumns.size(); i++)
00177 {
00178 mColumns[i]->GetDimensions(x,y,w,h);
00179 x = mx;
00180 if (mColumns[i]->GetColumnWidthDynamic())
00181 {
00182 if (mColumnCondenseEnabled)
00183 {
00184 int dc = (mColumnCondense-i);
00185 if (dc<0) dc=-dc;
00186 double multiplier = 1.0;
00187 if (dc == 4) multiplier = 1.1;
00188 if (dc == 3) multiplier = 1.2;
00189 if (dc == 2) multiplier = 1.6;
00190 if (dc == 1) multiplier = 2.2;
00191 if (dc == 0) multiplier = 6.0;
00192 w = wpc * multiplier;
00193 } else {
00194 w = wpc;
00195 }
00196 }
00197 mx += w + 2;
00198 mColumns[i]->SetDimensions(x,y,w,h);
00199 }
00200 UpdateRows();
00201 TableWindowColumn::SetUpdatingColumnWidths(false);
00202 }
00203
00204 void ColumnCondense(int column)
00205 {
00206 if (column != mColumnCondense)
00207 {
00208 mColumnCondense = column;
00209 HandleColumnPositions();
00210 }
00211 }
00212
00213
00214
00215 virtual void ColumnWidthUpdated()
00216 {
00217 HandleColumnPositions();
00218 }
00219
00220 void HandleLayoutChange()
00221 {
00222 UpdateNumberOfRowsEvent();
00223 }
00224
00225 void ResetFilters()
00226 {
00227 ILOG_DEBUG("Reset filters");
00228 for (int x = 0; x < mColumns.size(); x++)
00229 mColumns[x]->ResetFilter(false);
00230 GetTableDataView()->ApplyFilters();
00231 }
00232
00233 void UpdateRows()
00234 {
00235 for (int col=0; col<mColumns.size(); col++)
00236 {
00237 if (mColumns[col]->GetDisplayMode() == TableWindowCell::DISPLAY_IMAGE)
00238 mColumns[col]->GetViewCache()->HideViews();
00239
00240 int cindex = 0;
00241 int yoffset = TableWindowColumn::sHeaderHeight;
00242 int startR = GetTableDataView()->GetStartRow();
00243 for (int i=startR; i<startR+GetTableDataView()->GetNumberOfRows(); i++)
00244 {
00245 TableWindowCell *c = mColumns[col]->GetCell(cindex++);
00246 int yheight = GetRowHeight(i);
00247 yoffset += yheight;
00248 c->UpdateRow(yoffset, i, yheight, mColumns[col]->mDisplayMode, mColumns[col]->mDisplayAttr);
00249 }
00250
00251
00252 mColumns[col]->HideCellsFrom(cindex);
00253 }
00254 UpdateScene();
00255 }
00256
00257
00258
00259
00260 virtual void UpdateRowsEvent()
00261 {
00262
00263
00264 mReady = false;
00265 if (GetTableDataView()->GetFilteredRows() == GetTableDataView()->GetNumberOfRows())
00266 mVertScrollBar->SetVisible(false);
00267 else
00268 {
00269 mVertScrollBar->SetVisible(true);
00270 mVertScrollBar->SetRange(GetTableDataView()->GetFilteredRows(),
00271 GetTableDataView()->GetNumberOfRows());
00272 }
00273 if (mVertScrollBar->GetValue() > GetTableDataView()->GetFilteredRows())
00274 {
00275 ILOG_DEBUG("scrollbar out of range, resetting.");
00276 mReady = true;
00277 mVertScrollBar->SetValue(0);
00278 GetTableDataView()->SetStartRow(0);
00279 UpdateScene();
00280 }
00281 mReady = true;
00282 UpdateRows();
00283 }
00284
00285 virtual void UpdateNumberOfRowsEvent()
00286 {
00287 if(mLastSelectedRow != -1)
00288 {
00289
00290 GetTableDataView()->SetStartRowToFirstMarked(1);
00291 UpdateScene();
00292 }
00293 mLastSelectedRow = -1;
00294
00295 SetNumberOfRowsInPixels(H() - TableWindowColumn::GetHeaderHeight());
00296 }
00297
00298 virtual void OnScroll(ScrollBar *src, int position, void *userData)
00299 {
00300 if (!mReady) return;
00301 if (src == mVertScrollBar)
00302 GetTableDataView()->SetStartRow(position);
00303
00304 if (src == mHorScrollBar)
00305 {
00306 mHorScrollPosition = position;
00307 UpdateHorColumnPositions();
00308 }
00309
00310 }
00311
00312 virtual void UpdateScrollFromSourceEvent()
00313 {
00314 ILOG_DEBUG("TableWindow: UpdateScrollFromSourceEvent()");
00315 mVertScrollBar->SetValue(GetTableDataView()->GetStartRow());
00316 }
00317
00318 void ScrollRelative(int nr)
00319 {
00320 GetTableDataView()->SetStartRow(GetTableDataView()->GetStartRow() + nr);
00321 UpdateScrollFromSourceEvent();
00322 }
00323
00324 virtual void MouseFunc(int msg, int but, int state, int x, int y)
00325 {
00326 mMouseX = x; mMouseY = y;
00327 int nLine = ((state&oglShift) ? 5 : 1);
00328 if (msg == oglMouseWheelUp)
00329 {
00330 mVertScrollBar->ChangePos(-mVertScrollBar->LineIncrement() * nLine);
00331 ILOG_USER("TableWindow mouse wheel up");
00332 }
00333 if (msg == oglMouseWheelDown)
00334 {
00335 mVertScrollBar->ChangePos(mVertScrollBar->LineIncrement() * nLine);
00336 ILOG_USER("TableWindow mouse wheel down");
00337 }
00338 if (!mAutoZoom)
00339 UnZoomRows();
00340 else
00341 ZoomRow(GetRowForY(y));
00342
00343 if (msg == oglMouseEnter && mShowZoomView && mZoomView)
00344 viewSys.SetTags(mZoomView, visibleTag);
00345 if (msg == oglMouseLeave && mShowZoomView && mZoomView)
00346 viewSys.ClearTags(mZoomView, visibleTag);
00347
00348 if (msg == oglMouseDown && but == oglLeftButton)
00349 {
00350 int row = GetRowForY(y);
00351 if (row >= 0)
00352 {
00353 if (state & oglShift && mLastSelectedRow != -1)
00354 {
00355 ILOG_USER("TableWindow shift-select range " << mLastSelectedRow <<
00356 " to " << row);
00357 GetTableDataView()->MarkRange(mLastSelectedRow, row, 1, true);
00358 }
00359 else
00360 {
00361 if (!(state & oglControl))
00362 {
00363 ILOG_USER("TableWindow no ctrl -> unmark all " << row);
00364 GetTableDataView()->MarkAllRows(1, false);
00365 }
00366 ILOG_USER("TableWindow mouse click mark row " << row);
00367 GetTableDataView()->MarkRow(row, 1, true, true);
00368 mLastSelectedRow = row;
00369 }
00370 GetTableDataView()->DoUpdateSelectionEvent();
00371 }
00372 }
00373
00374
00375 ColumnCondense(GetColumnForX(x));
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397 if (msg == oglMouseDown && but == oglRightButton)
00398 {
00399 ILOG_USER("mouse open right context menu on row " << GetRowForY(y));
00400 int rx=0, ry=0;
00401 ToTopWindow(this, rx, ry);
00402 OpenContextMenu(rx+x,ry+y);
00403 }
00404
00405 }
00406
00407 virtual void KeyboardFunc(int c, int state)
00408 {
00409 ILOG_USER("TableWindow keyboard func " << c << " | " << (char) c << " state: " << state);
00410 switch (c)
00411 {
00412 case 'x':
00413 SetDefaultRowSizes(20, 80); break;
00414 case 'c':
00415 SetDefaultRowSizes(15, 40); break;
00416 case 'v':
00417 SetDefaultRowSizes(10, 80); break;
00418 case 'b':
00419 SetDefaultRowSizes(10, 120); break;
00420
00421 case '`':
00422 ShowZoomView(!mShowZoomView);
00423 break;
00424 case '~':
00425 ToggleZoomViewSize();
00426 break;
00427 default:
00428 TableDataViewController::KeyboardFunc(c, state);
00429 }
00430 }
00431
00432 void SetNumberOfRowsInPixels(int pixels)
00433 {
00434 if (pixels <= 0)
00435 return;
00436
00437 int yoff = 0;
00438 int rows = 0;
00439 for (int i=GetTableDataView()->GetStartRow(); i<GetTableDataView()->GetTotalRows(); i++)
00440 {
00441 if ((yoff += GetRowHeight(i)) > pixels)
00442 break;
00443 rows++;
00444 }
00445
00446 {
00447 ILOG_DEBUG("SetNumberOfRowsInPixels: " << pixels << " yields " <<
00448 rows << " rows.");
00449 GetTableDataView()->SetNumberOfRows(rows);
00450 }
00451 }
00452
00453 bool GetAutoZoom()
00454 {
00455 return mAutoZoom;
00456 }
00457
00458 void SetAutoZoom(bool zoom)
00459 {
00460 mAutoZoom = zoom;
00461 }
00462
00463 bool GetColumnCondense()
00464 {
00465 return mColumnCondenseEnabled;
00466 }
00467
00468 void SetColumnCondense(bool val)
00469 {
00470 mColumnCondenseEnabled = val;
00471 UpdateHorColumnPositions();
00472 }
00473
00474 bool GetShowPreview()
00475 {
00476 return mShowZoomView;
00477 }
00478
00479 void SetShowPreview(bool zoom)
00480 {
00481 ShowZoomView(zoom);
00482 }
00483
00484 void TransformMarkedSelectionTo(int sourcemask, int targetmask)
00485 {
00486 ILOG_SYSTEM("transform marked from " << sourcemask << " to " << targetmask);
00487 GetTableDataView()->TransformMarkedTo(sourcemask, targetmask);
00488 GetTableDataView()->DoUpdateSelectionEvent();
00489 }
00490
00491 int GetRowForY(int sy)
00492 {
00493 int my = 0, h=H();
00494 for (int y = GetTableDataView()->GetStartRow(); y < GetTableDataView()->GetEndRow(); y++)
00495 {
00496 my += GetRowHeight(y);
00497 if ((h - TableWindowColumn::GetHeaderHeight() - my) < sy)
00498 return y;
00499 }
00500 return -1;
00501 }
00502
00503
00504
00505
00506 void SetDefaultRowSizes(int unzoom, int zoom)
00507 {
00508 ILOG_DEBUG("SetDefaultRowSizes");
00509 mDefaultRowHeight = unzoom;
00510 mDefaultZoomRowHeight = zoom;
00511 GetTableDataView()->DoUpdateNumberOfRowsEvent();
00512 GetTableDataView()->DoUpdateRowsEvent();
00513 }
00514
00515 virtual int GetRowHeight(int row)
00516 {
00517 if (mZoomRow > -1)
00518 {
00519 int dist = abs((row) - mZoomRow);
00520 if (dist > 5) return mDefaultRowHeight;
00521 double div;
00522 if (dist == 0) div = 1.0;
00523 if (dist == 1) div = 0.45;
00524 if (dist == 2) div = 0.25;
00525 if (dist == 3) div = 0.15;
00526 if (dist == 4) div = 0.1;
00527 if (dist == 5) div = 0.05;
00528 return (int)(mDefaultZoomRowHeight*div+mDefaultRowHeight*(1.0-div));
00529 }
00530 return mDefaultRowHeight;
00531 }
00532
00533 void ZoomRow(int row)
00534 {
00535 if (row == mZoomRow)
00536 return;
00537 if (GetTableDataView()->OutOfBounds(row))
00538 return;
00539 if (mZoomRow == -1)
00540 GetTableDataView()->DoUpdateNumberOfRowsEvent();
00541 mZoomRow = row;
00542 GetTableDataView()->DoUpdateRowsEvent();
00543 }
00544
00545 void UnZoomRows()
00546 {
00547 if (mZoomRow == -1)
00548 return;
00549 mZoomRow = -1;
00550 GetTableDataView()->DoUpdateNumberOfRowsEvent();
00551 GetTableDataView()->DoUpdateRowsEvent();
00552 }
00553
00554
00555 void ShowZoomView(bool show)
00556 {
00557 if (!mZoomViewCache)
00558 ILOG_WARNING("Zoom view disabled: no cache set.");
00559 if (!mZoomView)
00560 ILOG_WARNING("Zoom view disabled: no target window set.");
00561
00562 if (mShowZoomView = show)
00563 {
00564 oglSys.SetAlwaysDraw(mZoomViewTargetWindow->GetOGLWND(), true);
00565 viewSys.SetTags(mZoomView, visibleTag);
00566 }
00567 else
00568 {
00569 viewSys.ClearTags(mZoomView, visibleTag);
00570 mZoomView->UserData1 = (void *) -1;
00571 oglSys.SetAlwaysDraw(mZoomViewTargetWindow->GetOGLWND(), false);
00572 }
00573 }
00574
00575 void UpdateZoomView(int row, int x, int y)
00576 {
00577 int zx = x;
00578 int zy = y;
00579
00580 oglSys.VPToTopWndI(mOglWnd,&zx,&zy);
00581 oglSys.TopWndToVPI(mZoomViewTargetWindow->GetOGLWND(),&zx,&zy);
00582 if (zy + mZoomViewSize > mZoomViewTargetWindow->H())
00583 zy = mZoomViewTargetWindow->H() - mZoomViewSize;
00584 if (zx + mZoomViewSize > mZoomViewTargetWindow->W())
00585 zx = mZoomViewTargetWindow->W() - mZoomViewSize;
00586
00587 if (row == -1)
00588 row = GetRowForY(y);
00589 if (mZoomViewFollowMouse)
00590 viewSys.SetDimensions(mZoomView,zx,zy,mZoomViewSize,mZoomViewSize);
00591 if (mZoomView->UserData1 != (void *) row)
00592 SetZoomView(row);
00593 }
00594
00595 void ToggleZoomViewSize()
00596 {
00597 int newsize;
00598 switch (mZoomViewSize)
00599 {
00600 case 128: newsize = 256; break;
00601 case 256: newsize = 384; break;
00602 case 384: newsize = 512; break;
00603 case 512: newsize = 768; break;
00604 case 768: newsize = 1024; break;
00605 case 1024: newsize = 128; break;
00606 }
00607 mZoomViewSize = newsize;
00608 int x,y,w,h;
00609 viewSys.GetDimensions(mZoomView,&x,&y,&w,&h);
00610 if (y + mZoomViewSize > mZoomViewTargetWindow->H())
00611 y = mZoomViewTargetWindow->H() - mZoomViewSize;
00612 if (x + mZoomViewSize > mZoomViewTargetWindow->W())
00613 x = mZoomViewTargetWindow->W() - mZoomViewSize;
00614 viewSys.SetDimensions(mZoomView,x,y,mZoomViewSize,mZoomViewSize);
00615 }
00616
00617 void UpdateVideoFrame()
00618 {
00619 if (!mZoomViewVideoEnabled || !mZoomImage || !mShowZoomView) return;
00620
00621 Array2dVec3UInt8 *v = GetTableDataView()->GetSortedVideoData("", mZoomViewRow);
00622 if (!v)
00623 return;
00624
00625 Array2dVec3UInt8* old = (Array2dVec3UInt8*)mZoomImage->imageHandle;
00626 if (old)
00627 delete old;
00628 if (mZoomImage->imageHandle = v)
00629 {
00630 mZoomImage->w = v->CW();
00631 mZoomImage->h = v->CH();
00632 }
00633 }
00634
00635 void SetZoomView(int row)
00636 {
00637 if (!mZoomViewCache || !mShowZoomView || mZoomViewRow == row)
00638 return;
00639
00640 mZoomViewRow = row;
00641
00642 Array2dVec3UInt8 *frame = GetTableDataView()->GetSortedVideoData("", row);
00643 if (frame)
00644 {
00645 ILOG_DEBUG("SetZoomView: showing video preview for row " << row);
00646 mZoomViewVideoEnabled = true;
00647 if (!mZoomImage)
00648 mZoomImage = Visualization::RgbOglImage::OglImage(frame);
00649 else
00650 {
00651 if (mZoomImage->imageHandle)
00652 delete mZoomImage->imageHandle;
00653 mZoomImage->imageHandle = frame;
00654 mZoomImage->w = frame->CW();
00655 mZoomImage->h = frame->CH();
00656 }
00657 viewSys.SetImage(mZoomView, mZoomImage);
00658 return;
00659 }
00660
00661
00662 mZoomViewVideoEnabled = false;
00663 unsigned long long quid = GetTableDataView()->GetSortedQuid(mImageColumn, row);
00664 OGLVIEW* v = mZoomViewCache->GetViewFromCache(quid);
00665 if (!v || v->UserData2 == (void*)2) {
00666 ILOG_DEBUG("Could not find view " << quid << " (row: " << row << ") in cache");
00667 return;
00668 }
00669 OGLIMAGE* im = v->im;
00670 viewSys.SetImage(mZoomView, im);
00671 }
00672
00673 void SetZoomViewCache(TableViewCache *c)
00674 {
00675 mZoomViewCache = c;
00676 }
00677
00678 void SetZoomViewTargetWindow(Window *t, bool followMouse=false)
00679 {
00680 mZoomViewTargetWindow = t;
00681
00682 mZoomView =
00683 viewSys.View2D(t->GetOGLWND(),0,0,0,mZoomViewSize, mZoomViewSize);
00684 viewSys.SetTags(mZoomView, FlexViewTags);
00685 int clearTags = visibleTag|showBorderTag|showBgTag|selectableTag;
00686 viewSys.ClearTags(mZoomView, clearTags);
00687 viewSys.SetColor(mZoomView, OGL_BG, oglTrLIGHTGREY);
00688 mZoomView->UserData1 = (void *) -1;
00689 mZoomViewFollowMouse = followMouse;
00690 }
00691
00692
00693
00694 virtual void ReshapeFunc(int w, int h)
00695 {
00696 Window::ReshapeFunc(w,h);
00697 HandleColumnPositions();
00698 HandleLayoutChange();
00699 }
00700
00701 virtual void DisplayFunc()
00702 {
00703 OGC myOGC;
00704 OGCSave(&myOGC);
00705
00706 int h = H(), w = W();
00707 int mx = -mHorScrollPosition, my = 0;
00708 int cx, cy, cw, ch;
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721 SetStipple((short)oglDot);
00722 SetSolidLineColor(0xff777777);
00723 for (int x = 0; x < mColumns.size(); x++)
00724 {
00725 mColumns[x]->GetDimensions(cx,cy,cw,ch);
00726 mx += cw + 2;
00727 if (mx > 0)
00728 DrawLine(mx, 0, mx, h);
00729 }
00730 int hheight = TableWindowColumn::GetHeaderHeight();
00731 my = hheight;
00732 for (int y = GetTableDataView()->GetStartRow(); y < GetTableDataView()->GetEndRow(); y++)
00733 {
00734 my += GetRowHeight(y);
00735
00736
00737
00738
00739 int mark = GetTableDataView()->GetMark(y);
00740 if (mark)
00741 {
00742 int markCol = MarkToColor(mark);
00743 SetSolidFillColor(markCol);
00744 FillRectangle(0, h - my, w - 20, GetRowHeight(y));
00745 }
00746
00747 DrawLine(0, h - my, w - 20, h - my);
00748 }
00749
00750 SetStipple((short)oglSolid);
00751 DrawLine(0, h - hheight, w - 20, h - hheight);
00752 DrawLine(w - 20, 0, w - 20, h - hheight);
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764 OGCRestore(&myOGC);
00765 HandleZoomView();
00766 Window::DisplayFunc();
00767 }
00768
00769 private :
00770
00771 void FitImageToZoomView()
00772 {
00773 if (mZoomView && mZoomView->im)
00774 {
00775 float zoom = (mZoomView->h)/(float)mZoomView->im->h;
00776 viewSys.SetZoom(mZoomView, zoom, zoom);
00777 }
00778 }
00779
00780 void HandleZoomView()
00781 {
00782 if (mShowZoomView && mZoomView && viewSys.HasTags(mZoomView,visibleTag))
00783 {
00784 UpdateZoomView(-1, mMouseX, mMouseY);
00785 UpdateVideoFrame();
00786 FitImageToZoomView();
00787 }
00788 }
00789
00790 void Init(int w, int h)
00791 {
00792 mReady = false;
00793
00794 mAutoZoom = false;
00795 mColumnCondense = false;
00796 mZoomViewTargetWindow = 0;
00797 mStaticColumnWidth = 0;
00798 mLastSelectedRow = -1;
00799
00800 mDefaultRowHeight = 20;
00801 mDefaultZoomRowHeight = 80;
00802 mZoomRow = -1;
00803
00804
00805 mZoomViewSize = 384;
00806 mZoomView = 0;
00807 mZoomImage = 0;
00808 mZoomViewVideoEnabled = false;
00809 mZoomViewCache = 0;
00810 mShowZoomView = false;
00811 mZoomViewFollowMouse = false;
00812
00813 mHorScrollPosition = 0;
00814
00815 SetBackground(0xffffffff);
00816 SetBorderType(1);
00817 SetBorderFillShaded(-2);
00818
00819 GetTableDataView()->AddTableDataViewListener(this);
00820
00821 mVertScrollBar = new WindowScrollBar(this, false);
00822 mVertScrollBar->SetRange(GetTableDataView()->GetTotalRows(),
00823 GetTableDataView()->GetNumberOfRows());
00824 mVertScrollBar->SetScrollBarListener(this, 0);
00825 mVertScrollBar->SetBackground(0xffffffff);
00826
00827 mHorScrollBar = new WindowScrollBar(this, true);
00828 mHorScrollBar->SetRange(1024,
00829 4000);
00830 mHorScrollBar->SetScrollBarListener(this, 0);
00831 mHorScrollBar->SetBackground(0xffffffff);
00832
00833
00834 oglSys.SetAllMouseMotion( mOglWnd, 1 );
00835 mReady = true;
00836
00837 InitContextMenu(this);
00838 }
00839
00840 bool mReady;
00841 bool mAutoZoom;
00842 bool mColumnCondenseEnabled;
00843 bool mShowZoomView;
00844 bool mZoomViewFollowMouse;
00845 bool mZoomViewVideoEnabled;
00846
00847 int mMouseX;
00848 int mMouseY;
00849 int mStaticColumnWidth;
00850 int mStaticColumnCount;
00851 int mDefaultRowHeight;
00852 int mDefaultZoomRowHeight;
00853 int mZoomRow;
00854 int mZoomViewRow;
00855 int mZoomViewSize;
00856 int mLastSelectedRow;
00857 int mMouseXS, mMouseYS, mMouseXE, mMouseYE;
00858 int mHorScrollPosition;
00859 int mColumnCondense;
00860
00861
00862 std::vector<TableWindowColumn*> mColumns;
00863 TableViewCache* mZoomViewCache;
00864 OGLVIEW* mZoomView;
00865 OGLIMAGE* mZoomImage;
00866 String mImageColumn;
00867
00868 Window* mHeaderWindow;
00869 Window* mZoomViewTargetWindow;
00870 WindowScrollBar* mVertScrollBar;
00871 WindowScrollBar* mHorScrollBar;
00872
00873 ILOG_VAR_DEC;
00874 };
00875
00876 ILOG_VAR_INIT(TableWindow, Application.MediaTable);
00877
00878 }
00879 }
00880 }
00881
00882 #endif // TableWindow_h