00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 #include "camtypes.h"
00103
00104 #include "dlgmgr.h"
00105
00106
00107
00108
00109
00110
00111
00112 #include "infobar.h"
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 #include "ccdc.h"
00124
00125
00126
00127
00128
00129 #include "camelot.h"
00130 #include "camframe.h"
00131
00132 #include "stack.h"
00133 #include "dropdown.h"
00134 #include "griddropdown.h"
00135 #include "unicdman.h"
00136 #include "appprefs.h"
00137 #include "helpuser.h"
00138
00139
00140
00141
00142
00143
00144 #include "dlgevt.h"
00145 #include "cartprov.h"
00146 #include "cartctl.h"
00147 #include "osrndrgn.h"
00148
00149 #include "statline.h"
00150 #include <wx/imaglist.h>
00151
00152 DECLARE_SOURCE("$Revision: 1770 $");
00153
00154 CC_IMPLEMENT_DYNAMIC(CGadgetImageList, CCObject);
00155
00156
00157 #define new CAM_DEBUG_NEW
00158
00159
00160
00161
00162
00163 List DialogManager::DiscardStrList;
00164 List DialogManager::ScrollPageIncList;
00165 List DialogManager::DialogPositionList;
00166
00167 IdToSerializedPaneInfo * DialogManager::s_pPaneInfoHash = NULL;
00168
00169 wxWindow *DialogManager::pDlgCurrent = NULL;
00170
00171
00172
00173 ActiveDlgStateStack DialogManager::ActiveDlgStack;
00174
00175
00176
00177 #define BN_RGT_CLICKED 6
00178
00179
00180 class Node;
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 DialogManager::DialogManager()
00193 {
00194
00195 }
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258 class wxDynamicPropertySheetDialog : public wxPropertySheetDialog
00259 {
00260 public:
00261 wxDynamicPropertySheetDialog() {m_TabType=TABTYPE_TABS;}
00262 ~wxDynamicPropertySheetDialog() {}
00263 void SetTabType(TabType t) {m_TabType=t;}
00264 protected:
00265 TabType m_TabType;
00266 virtual wxBookCtrlBase* CreateBookCtrl()
00267 {
00268 INT32 style = wxCLIP_CHILDREN | wxBC_DEFAULT;
00269 wxBookCtrlBase* pBook = NULL;
00270
00271 switch (m_TabType)
00272 {
00273 #if wxUSE_LISTBOOK
00274 case TABTYPE_LIST:
00275 return new wxListbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
00276 break;
00277 #endif
00278 #if wxUSE_CHOICEBOOK
00279 case TABTYPE_CHOICE:
00280 return new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
00281 break;
00282 #endif
00283 #if wxUSE_TREEBOOK || wxXTRA_TREEBOOK
00284 case TABTYPE_TREE:
00285 {
00286 wxTreebook * t = new wxTreebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
00287 if (t)
00288 t->GetTreeCtrl()->SetIndent(0);
00289 return t;
00290 }
00291 break;
00292 #else
00293
00294 case TABTYPE_TREE:
00295 return new wxListbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
00296 break;
00297 #endif
00298 #if wxUSE_TOOLBOOK
00299 case TABTYPE_TOOLBAR:
00300 return new wxToolbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
00301 break;
00302 #endif
00303 case TABTYPE_TABS:
00304 default:
00305 pBook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
00306
00307 PORTNOTE("dialog", "This should probably be applied to all controls eventually")
00308
00309 wxFont fontDefault = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
00310 fontDefault.SetPointSize( 8 );
00311 pBook->SetFont( fontDefault );
00312
00313 break;
00314 }
00315
00316 return pBook;
00317 }
00318 };
00319
00320 BOOL DialogManager::Create(DialogOp* DlgOp,
00321 CDlgResID MainDlgID,
00322 CDlgResID SubDlgID,
00323 CDlgMode Mode, INT32 OpeningPage, CWindowID ParentWnd)
00324 {
00325 ERROR2IF(!DlgOp, FALSE, _T("Create Passed Null DialogOp"));
00326 ERROR2IF(DlgOp->pEvtHandler, FALSE, _T("Window has already been created. Having two is greedy"));
00327
00328 DlgOp->pEvtHandler = new DialogEventHandler(DlgOp);
00329 ERRORIF(!DlgOp->pEvtHandler || !DlgOp->pEvtHandler->pDialogOp, FALSE, _R(IDE_CANNOT_CREATE_DIALOG));
00330
00331 BOOL wxAUImanaged = FALSE;
00332 if ( DlgOp->IsABar() || DlgOp->IsAGallery() )
00333 {
00334 BOOL modal = DlgOp->IsModal();
00335 ERROR2IF(modal, FALSE, "Attempting to create a wxAUImanaged Dialog that is modal");
00336
00337 wxAUImanaged = TRUE;
00338 }
00339
00340
00341
00342 ERROR2IF( SubDlgID !=0, FALSE, _T("Merging of dialogs not yet supported"));
00343
00344
00345 if ((ParentWnd == NULL) || wxAUImanaged)
00346 ParentWnd = GetMainFrame();
00347
00348 const TCHAR* pDialogName = NULL;
00349 wxWindow* pDialogWnd = NULL;
00350
00351 if( DlgOp->IS_KIND_OF(DialogTabOp) && !(((DialogTabOp*)DlgOp)->LoadFrameFromResources()))
00352 {
00353
00354 wxDynamicPropertySheetDialog* pPropertySheet;
00355
00356
00357 pPropertySheet = new wxDynamicPropertySheetDialog();
00358 if (pPropertySheet)
00359 {
00360 pPropertySheet->SetTabType(((DialogTabOp*)DlgOp)->GetTabType());
00361 if (!pPropertySheet->Create((wxWindow *)ParentWnd, wxID_ANY, (TCHAR*) (*((DialogTabOp*)DlgOp)->GetName()) ))
00362 {
00363 delete pPropertySheet;
00364 pPropertySheet=NULL;
00365 }
00366 else
00367 {
00368 wxStdDialogButtonSizer *sizer = new wxStdDialogButtonSizer();
00369 wxButton * ok=new wxButton(pPropertySheet, wxID_OK);
00370 sizer->AddButton(ok);
00371 sizer->AddButton(new wxButton(pPropertySheet, wxID_CANCEL));
00372 sizer->AddButton(new wxButton(pPropertySheet, wxID_APPLY));
00373 sizer->AddButton(new wxButton(pPropertySheet, wxID_HELP));
00374 ok->SetDefault();
00375 ok->SetFocus();
00376 pPropertySheet->SetAffirmativeId(wxID_OK);
00377 sizer->Realize();
00378 pPropertySheet->GetInnerSizer()->Add( sizer, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT|wxRIGHT, 2);
00379 pPropertySheet->GetInnerSizer()->AddSpacer(2);
00380 }
00381 }
00382 pDialogWnd=pPropertySheet;
00383 }
00384 else
00385 {
00386 pDialogName=CamResource::GetObjectNameFail(MainDlgID);
00387 ERROR1IF(pDialogName == NULL, FALSE, _R(IDE_CANNOT_CREATE_DIALOG));
00388
00389 PORTNOTE("dialog","A more general scheme is needed to allow creation of a panel for non-toolbar type dialog")
00390 if (wxAUImanaged || _R(IDD_BITMAPPREVIEWDIALOG) == MainDlgID )
00391 pDialogWnd = wxXmlResource::Get()->LoadPanel((wxWindow *)ParentWnd, pDialogName);
00392 else
00393 pDialogWnd = wxXmlResource::Get()->LoadDialog((wxWindow *)ParentWnd, pDialogName);
00394 }
00395
00396 ERROR1IF(pDialogWnd == NULL, FALSE, _R(IDE_CANNOT_CREATE_DIALOG));
00397
00398 pDialogWnd->Hide();
00399 CamArtProvider::Get()->EnsureChildBitmapsLoaded(pDialogWnd);
00400
00401
00402 #ifdef __WXMAC__
00403 pDialogWnd->SetBackgroundStyle(wxBG_STYLE_COLOUR);
00404 pDialogWnd->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
00405 #endif
00406
00407
00408
00409
00410 DlgOp->pEvtHandler->pwxWindow = pDialogWnd;
00411 DlgOp->pEvtHandler->wxAUImanaged = wxAUImanaged;
00412 DlgOp->pEvtHandler->ID =MainDlgID;
00413
00414 DlgOp->WindowID = (CWindowID)pDialogWnd;
00415 pDialogWnd->PushEventHandler(DlgOp->pEvtHandler);
00416
00417 if (DlgOp->IS_KIND_OF(DialogTabOp))
00418 {
00419
00420
00421
00422 if (!CreateTabbedDialog( (DialogTabOp*)DlgOp, Mode, OpeningPage, MainDlgID ))
00423 {
00424
00425 Delete(pDialogWnd, DlgOp);
00426 ERROR1(FALSE, _R(IDE_CANNOT_CREATE_DIALOG));
00427 }
00428 }
00429
00430 CreateRecursor(pDialogWnd);
00431
00432
00433 ControlList::Get()->RegisterWindowAndChildren(pDialogWnd, DlgOp);
00434
00435 ControlList::Get()->ReflectAllStates();
00436
00437
00438 BOOL ok = PostCreate(DlgOp, OpeningPage);
00439
00440 if( ok &&
00441 Mode == MODAL &&
00442 pDialogWnd->IsKindOf( CLASSINFO(wxDialog) ) )
00443 {
00444 ((wxDialog *) pDialogWnd)->ShowModal();
00445 }
00446
00447 #ifdef USE_WXAUI
00448 if (wxAUImanaged)
00449 {
00450 wxString Title = wxEmptyString;
00451 if (pDialogWnd->IsKindOf(CLASSINFO(wxDialog)))
00452 Title=((wxDialog *)pDialogWnd)->GetTitle();
00453 if (Title.IsEmpty()) Title = pDialogWnd->GetLabel();
00454 if (Title.IsEmpty())
00455 {
00456 const TCHAR * ResString=CamResource::GetTextFail(pDialogWnd->GetId());
00457 if (ResString)
00458 Title=wxString(ResString);
00459 }
00460 if (Title.IsEmpty())
00461 {
00462
00463
00464 wxToolTip* pTip = pDialogWnd->GetToolTip();
00465 if (pTip) Title=pTip->GetTip();
00466 }
00467 if (Title.IsEmpty())
00468 Title = wxString(CamResource::GetText(_R(IDS_ANONYMOUSBARTITLE)));
00469
00470
00471
00472
00473
00474 wxAuiPaneInfo paneinfo;
00475 if (!DlgOp->IsABar())
00476 {
00477
00478 paneinfo.FloatingSize(100,300);
00479 }
00480 LoadPaneInfo(wxString(CamResource::GetObjectName(pDialogWnd->GetId())), paneinfo);
00481 paneinfo.DestroyOnClose(FALSE);
00482 if (DlgOp->IsABar())
00483 {
00484 if (DlgOp->IsKindOf(CC_RUNTIME_CLASS(StatusLine)))
00485 paneinfo.Bottom().Layer(1).Row(2).LeftDockable(FALSE).RightDockable(FALSE).Floatable(FALSE).Movable(FALSE).Gripper(FALSE).CaptionVisible(FALSE).PaneBorder(FALSE);
00486 else
00487 {
00488 paneinfo.ToolbarPane().Fixed();
00489 if (DlgOp->IsVertical())
00490 {
00491 paneinfo.Left().Layer(0).GripperTop().TopDockable(FALSE).BottomDockable(FALSE);
00492 }
00493 else
00494 {
00495 paneinfo.Top().Layer(1).Row(2).LeftDockable(FALSE).RightDockable(FALSE);
00496 }
00497 }
00498 }
00499 else
00500 {
00501
00502 paneinfo.Layer(3).GripperTop().TopDockable(FALSE).BottomDockable(FALSE).Float().Dockable(FALSE);
00503 }
00504
00505 if (DlgOp->IsKindOf(CC_RUNTIME_CLASS(InformationBarOp)))
00506 {
00507 paneinfo.Floatable(FALSE);
00508
00509
00510 }
00511
00512 paneinfo.Name(pDialogName).Caption(Title).PinButton(TRUE);
00513
00514 wxSizer * pSizer = pDialogWnd->GetSizer();
00515 if (pSizer)
00516 {
00517 pSizer->SetSizeHints(pDialogWnd);
00518 pDialogWnd->SetSizerAndFit(pSizer);
00519 }
00520
00521
00522
00523 if (paneinfo.IsFloating() && !CCamFrame::GetFrameManager()->GetManagedWindow()->IsShown())
00524 CCamFrame::GetFrameManager()->GetManagedWindow()->Show();
00525
00526 CCamFrame::GetFrameManager()->AddPane(pDialogWnd, paneinfo);
00527
00528 CCamFrame::GetMainFrame()->UpdateFrameManager();
00529
00530
00531
00532 wxWindow * pTLW = pDialogWnd;
00533 while (pTLW->GetParent())
00534 pTLW=pTLW->GetParent();
00535 if (pTLW->IsKindOf(CLASSINFO(wxAuiFloatingFrame)))
00536 pTLW->Raise();
00537
00538 }
00539 #endif
00540
00541 return ok;
00542 }
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560 void DialogManager::CreateRecursor(wxWindow * pwxWindow)
00561 {
00562
00563 wxPlatformDependent::Get()->InitWindow(pwxWindow);
00564
00565
00566 if (pwxWindow->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
00567 {
00568 ((wxOwnerDrawnComboBox*)pwxWindow)->SetPopupMaxHeight(600);
00569 ((wxOwnerDrawnComboBox*)pwxWindow)->SetPopupAnchor(wxLEFT);
00570 }
00571
00572
00573 wxWindowList::Node * pNode = pwxWindow->GetChildren().GetFirst();
00574 while (pNode)
00575 {
00576 CreateRecursor(pNode->GetData());
00577 pNode = pNode->GetNext();
00578 }
00579 return;
00580 }
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602 BOOL DialogManager::PostCreate(DialogOp * pDialogOp, INT32 OpeningPage)
00603 {
00604 ERROR2IF( !pDialogOp || !pDialogOp->pEvtHandler || !pDialogOp->pEvtHandler->pwxWindow,
00605 FALSE, _T("Bad DialogOp / EvtHandler in DialogManager::PostCreate()"));
00606
00607 wxWindow * pDialogWnd = pDialogOp->pEvtHandler->pwxWindow;
00608
00609
00610 INT32 DlgX=0;
00611 INT32 DlgY=0;
00612 CDlgResID ActivePage=0;
00613 UINT32 ActivePageIndex=0;
00614
00615 BOOL CreatedBefore = FALSE;
00616
00617 wxBookCtrlBase * pBook=NULL;
00618
00619 if (pDialogOp->IS_KIND_OF(DialogTabOp))
00620 pBook=GetBookControl(pDialogWnd);
00621
00622 ResourceID BookGadget=pBook?pBook->GetId():0;
00623
00624 if (pBook && (OpeningPage>=0))
00625 {
00626 ActivePage = pBook->GetPage(OpeningPage)->GetId();
00627 ActivePageIndex = OpeningPage;
00628 }
00629
00630
00631 DialogPosition* DlgPos = FindDialogPositionRecord(pDialogOp->pEvtHandler->ID);
00632 if (DlgPos != NULL)
00633 {
00634 DlgX = DlgPos->LastX;
00635 DlgY = DlgPos->LastY;
00636
00637
00638 if (OpeningPage<0)
00639 {
00640 ActivePage = DlgPos->ActivePage;
00641 ActivePageIndex = DlgPos->ActivePageIndex;
00642 }
00643 CreatedBefore = TRUE;
00644 }
00645
00646 if (pBook && ((ActivePageIndex<0) ||
00647 (ActivePageIndex >= pBook->GetPageCount()) ||
00648 ((UINT32)(pBook->GetPage(ActivePageIndex)->GetId()) != ActivePage)
00649 ))
00650 {
00651 ActivePageIndex=0;
00652 ActivePage = pBook->GetPage(0)->GetId();
00653 }
00654
00655
00656 wxRect DialogRect( pDialogWnd->GetRect() );
00657 INT32 DialogWidth = DialogRect.GetWidth();
00658 INT32 DialogHeight = DialogRect.GetHeight();
00659
00660
00661 CWindowIDItem *pWinID = new CWindowIDItem;
00662 if( NULL == pWinID )
00663 {
00664
00665 pDialogWnd->PopEventHandler(FALSE);
00666 pDialogOp->pEvtHandler->Destroy();
00667 pDialogWnd->Destroy();
00668 ERROR1(FALSE, _R(IDS_OUT_OF_MEMORY));
00669 }
00670
00671
00672 if (!CreatedBefore)
00673
00674 {
00675
00676 INT32 ScreenWidth = wxSystemSettings::GetMetric( wxSYS_SCREEN_X );
00677 INT32 ScreenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
00678
00679
00680 DlgX = (ScreenWidth - DialogWidth) / 2;
00681 DlgY = (ScreenHeight - DialogHeight) / 2;
00682
00683
00684 DlgPos = new DialogPosition;
00685 if (DlgPos == NULL)
00686 {
00687
00688 pDialogWnd->PopEventHandler(FALSE);
00689 pDialogOp->pEvtHandler->Destroy();
00690 pDialogWnd->Destroy();
00691 return FALSE;
00692 }
00693 DlgPos->DlgResourceID = pDialogOp->pEvtHandler->ID;
00694
00695
00696
00697
00698 DlgPos->LastX = DlgX;
00699 DlgPos->LastY = DlgY;
00700
00701 DlgPos->ActivePage = 0;
00702 DlgPos->ActivePageIndex=0;
00703
00704 if (pBook)
00705 {
00706
00707 DlgPos->ActivePage = ActivePage;
00708 DlgPos->ActivePageIndex = ActivePageIndex;
00709 }
00710
00711 DialogPositionList.AddHead((ListItem*)DlgPos);
00712 }
00713
00714
00715 pWinID->DlgWin = pDialogWnd;
00716 DlgPos->DlgWinList.AddTail( pWinID );
00717
00718
00719 pDialogWnd->SetSize(DlgX, DlgY, DialogWidth, DialogHeight);
00720
00721
00722 PORTNOTE("dialog","Removed FontFactory usage")
00723 #ifndef EXCLUDE_FROM_XARALX
00724 if( UnicodeManager::IsDBCSOS() )
00725 FontFactory::ApplyFontToWindow( DialogWnd, STOCKFONT_DIALOG ); */
00726 #endif
00727
00728
00729
00730
00731
00732 BROADCAST_TO_CLASS( DialogMsg( pDialogOp->WindowID, DIM_CREATE, 0 ), DialogOp );
00733
00734 if (pBook)
00735 {
00736
00737 UINT32 i;
00738 for (i=0; i<pBook->GetPageCount(); i++)
00739 {
00740 BROADCAST_TO_CLASS(DialogMsg(pDialogOp->WindowID, DIM_CREATE, BookGadget, 0, pBook->GetPage(i)->GetId()) ,DialogOp);
00741 }
00742
00743
00744 BROADCAST_TO_CLASS( DialogMsg( pDialogOp->WindowID, DIM_SET_ACTIVE, BookGadget, 0, ActivePage ), DialogOp );
00745 pBook->SetSelection(ActivePageIndex);
00746 }
00747
00748
00749
00750
00751 if( !GetMainFrame()->IsEnabled() )
00752 {
00753 EnableAllDialogs(FALSE, pDialogWnd);
00754 }
00755
00756 return TRUE;
00757 }
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773 void DialogManager::InitPaneInfoHash()
00774 {
00775 if (s_pPaneInfoHash)
00776 return;
00777
00778 s_pPaneInfoHash = new IdToSerializedPaneInfo;
00779 }
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798 void DialogManager::FreePaneInfoHash()
00799 {
00800 if (s_pPaneInfoHash)
00801 {
00802 delete s_pPaneInfoHash;
00803 s_pPaneInfoHash = NULL;
00804 }
00805 }
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821 void DialogManager::EnsurePanePreferenceDeclared(wxString key)
00822 {
00823 if (!s_pPaneInfoHash)
00824 InitPaneInfoHash();
00825
00826 if (!s_pPaneInfoHash)
00827 return;
00828
00829 IdToSerializedPaneInfo::iterator i=s_pPaneInfoHash->find(key);
00830 if (i==s_pPaneInfoHash->end())
00831 {
00832
00833
00834 (*s_pPaneInfoHash)[key]=_T("");
00835 i=s_pPaneInfoHash->find(key);
00836 if (i==s_pPaneInfoHash->end())
00837 {
00838 ERROR3("This hash leaks like a seive");
00839 return;
00840 }
00841
00842
00843 if (Camelot.DeclareSection(_T("BarPositions"), 10))
00844 {
00845 Camelot.DeclarePref( NULL, (TCHAR *)(key.c_str()), &(i->second) );
00846 }
00847 }
00848 }
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866 void DialogManager::LoadPaneInfo(wxString key, wxAuiPaneInfo &paneinfo)
00867 {
00868 if (!s_pPaneInfoHash)
00869 InitPaneInfoHash();
00870
00871 if (!s_pPaneInfoHash)
00872 return;
00873
00874 EnsurePanePreferenceDeclared(key);
00875
00876 IdToSerializedPaneInfo::iterator i=s_pPaneInfoHash->find(key);
00877 if (i==s_pPaneInfoHash->end())
00878 return;
00879
00880
00881 if (i->second.IsEmpty())
00882 return;
00883
00884 TRACEUSER("amb", _T("key=%s"), (const TCHAR *)key);
00885 TRACEUSER("amb", _T("val=%s"), (const TCHAR *)(i->second));
00886
00887 wxString name = (wxString)((const TCHAR *)(i->second));
00888 CCamFrame::GetFrameManager()->LoadPaneInfo(name, paneinfo);
00889 }
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905 void DialogManager::SavePaneInfo(wxString key, wxAuiPaneInfo &paneinfo)
00906 {
00907
00908 if ((paneinfo.IsOk()) && (paneinfo.IsFloating()))
00909 {
00910 paneinfo.FloatingSize(paneinfo.window->GetParent()->GetSize());
00911 }
00912
00913 if (!s_pPaneInfoHash)
00914 InitPaneInfoHash();
00915
00916 if (!s_pPaneInfoHash)
00917 return;
00918
00919 EnsurePanePreferenceDeclared(key);
00920
00921 (*s_pPaneInfoHash)[key]=CCamFrame::GetFrameManager()->SavePaneInfo(paneinfo);
00922 }
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940 DialogPosition* DialogManager::FindDialogPositionRecord(CDlgResID DialogID)
00941 {
00942
00943 DialogPosition* DlgPos = (DialogPosition*)(DialogPositionList.GetHead());
00944 while (DlgPos != NULL)
00945 {
00946 if (DlgPos->DlgResourceID == DialogID)
00947 {
00948 return DlgPos;
00949 break;
00950 }
00951
00952 DlgPos = (DialogPosition*)(DialogPositionList.GetNext((ListItem*)DlgPos));
00953 }
00954 return NULL;
00955 }
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973 void DialogManager::Open(CWindowID WindowID, DialogOp* pDlgOp)
00974 {
00975
00976 PORTNOTE("dialog","Removed DialogBarOp usage")
00977 #ifndef EXCLUDE_FROM_XARALX
00978 if (pDlgOp->IsKindOf(CC_RUNTIME_CLASS(DialogBarOp)))
00979 {
00980
00981 BaseBar *pCWnd = (wxWindow *)WindowID;
00982 ENSURE( pCWnd != NULL, "Could not find bar object" );
00983
00984 if( pCWnd != NULL )
00985 {
00986 pCWnd->Show( (DialogBarOp *)pDlgOp );
00987 }
00988 }
00989 else
00990 #endif
00991 if( !pDlgOp->IsModal() )
00992 {
00993 ( (wxWindow *)WindowID )->Show( true );
00994 }
00995
00996 if (pDlgOp->pEvtHandler->wxAUImanaged)
00997 CCamFrame::GetMainFrame()->UpdateFrameManager();
00998
00999 }
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017 void DialogManager::Close(CWindowID WindowID, DialogOp* pDlgOp)
01018 {
01019
01020
01021
01022 PORTNOTE("dialog","Removed DialogBarOp usage")
01023 #ifndef EXCLUDE_FROM_XARALX
01024 if (pDlgOp->IsKindOf(CC_RUNTIME_CLASS(DialogBarOp)))
01025 {
01026
01027 wxWindow* pCWnd = CWnd::FromHandlePermanent(WindowID);
01028 ENSURE(pCWnd != NULL, "Could not find bar object");
01029
01030 if (pCWnd != NULL)
01031 {
01032 ((BaseBar*)pCWnd)->Hide((DialogBarOp*)pDlgOp);
01033 }
01034 }
01035 else
01036 #endif
01037 if (!(pDlgOp->IsModal()))
01038 {
01039 ENSURE(WindowID != NULL,"NULL WindowID");
01040 ( (wxWindow *)WindowID )->Show( false );
01041 }
01042
01043 if (pDlgOp->pEvtHandler->wxAUImanaged)
01044 CCamFrame::GetMainFrame()->UpdateFrameManager();
01045 }
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060 BOOL DialogManager::MergeDialogs( CWindowID Dialog, CWindowID Mergee, bool fAbove )
01061 {
01062 wxSizer* pMainSizer = Dialog->GetSizer();
01063 wxSizer* pVertSizer( new wxBoxSizer( wxVERTICAL ) );
01064 if( fAbove )
01065 pVertSizer->Add( Mergee, wxALL );
01066 pVertSizer->Add( pMainSizer );
01067 if( !fAbove )
01068 pVertSizer->Add( Mergee, wxALL );
01069
01070 Dialog->SetSizerAndFit( pVertSizer, false );
01071 return TRUE;
01072 }
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087 BOOL DialogManager::BringToTop(CWindowID WindowID, DialogOp* pDlgOp)
01088 {
01089 ERROR2IF(!WindowID, FALSE, "BringToTop called on a dialog without a window");
01090 ( (wxWindow *)WindowID )->Raise();
01091 if (pDlgOp->pEvtHandler->wxAUImanaged)
01092 CCamFrame::GetMainFrame()->UpdateFrameManager();
01093 return TRUE;
01094 }
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110 void DialogManager::Event (DialogEventHandler *pEvtHandler, wxEvent &event)
01111 {
01112 WXTYPE EventType = event.GetEventType();
01113
01114 ResourceID id = event.GetId();
01115 UINT_PTR DlgMsgParam = 0;
01116 INT32 PageID = 0;
01117 BOOL HandleMessage=FALSE;
01118 BOOL Defer=TRUE;
01119
01120 if (!pEvtHandler->pwxWindow || !pEvtHandler->pDialogOp)
01121 {
01122
01123 event.Skip();
01124 return;
01125 }
01126
01127
01128 if (event.IsKindOf(CLASSINFO(wxCamDialogEvent)) && (EventType == wxEVT_CAMDIALOG_DEFERREDMSG))
01129 {
01130
01131 wxCamDialogEvent * pDialogEvent = (wxCamDialogEvent *)(&event);
01132 pDialogEvent->msg.DlgWndID = pEvtHandler->pwxWindow;
01133
01134 BROADCAST_TO_CLASS( DialogMsg(pDialogEvent->msg), DialogOp );
01135 return;
01136 }
01137
01138 wxWindow * pGadget = NULL;
01139 if (id) pGadget = GetGadget(pEvtHandler->pwxWindow, id);
01140
01141
01142 if( !pGadget && (event.GetEventObject() != pEvtHandler->pwxWindow))
01143 {
01144 pGadget = (wxWindow *)event.GetEventObject();
01145 id = pGadget->GetId();
01146 }
01147
01148
01149 if( NULL != pGadget )
01150 {
01151
01152
01153 wxWindow* pDialog = pGadget->GetParent();
01154 while( NULL != pDialog && !pDialog->IsKindOf( CLASSINFO(wxDialog) ) &&
01155 !pDialog->IsKindOf( CLASSINFO(wxPanel) ) )
01156 {
01157 pDialog = pDialog->GetParent();
01158 }
01159
01160
01161 if( NULL != pDialog && pDialog->IsKindOf( CLASSINFO(wxPanel) ) )
01162 {
01163
01164 wxWindow *pDialogParent = pDialog->GetParent();
01165 if( NULL != pDialogParent && pDialogParent->IsKindOf( CLASSINFO(wxBookCtrlBase) ) )
01166 PageID = pDialog->GetId();
01167 }
01168 }
01169
01170
01171 DialogMsg msg(pEvtHandler->pwxWindow, DIM_NONE, id, DlgMsgParam, PageID);
01172
01173 if (!event.IsKindOf(CLASSINFO(wxMouseEvent)))
01174 {
01175 TRACEUSER("amb",_T("event %d(%s) received, ID=%d(%s), wxw=%llx"), EventType, DialogEventHandler::GetEventName(EventType), id,
01176 CamResource::GetObjectName((ResourceID)id), pEvtHandler->pwxWindow);
01177 }
01178
01179 if (
01180 (EventType == wxEVT_LEFT_DCLICK) ||
01181 (EventType == wxEVT_MIDDLE_DCLICK) ||
01182 (EventType == wxEVT_RIGHT_DCLICK) ||
01183 FALSE)
01184 {
01185
01186
01187
01188
01189 wxMouseEvent *MouseDown = (wxMouseEvent *)(event.Clone());
01190 wxMouseEvent *MouseUp = (wxMouseEvent *)(event.Clone());
01191 if (MouseDown && MouseUp)
01192 {
01193 if (EventType == wxEVT_LEFT_DCLICK)
01194 {
01195 MouseDown->SetEventType(wxEVT_LEFT_DOWN);
01196 MouseUp->SetEventType(wxEVT_LEFT_UP);
01197 }
01198 else if (EventType == wxEVT_MIDDLE_DCLICK)
01199 {
01200 MouseDown->SetEventType(wxEVT_MIDDLE_DOWN);
01201 MouseUp->SetEventType(wxEVT_MIDDLE_UP);
01202 }
01203 else
01204 {
01205 MouseDown->SetEventType(wxEVT_RIGHT_DOWN);
01206 MouseUp->SetEventType(wxEVT_RIGHT_UP);
01207 }
01208
01209
01210
01211
01212 pEvtHandler->pwxWindow->GetEventHandler()->ProcessEvent(*MouseDown);
01213 pEvtHandler->pwxWindow->GetEventHandler()->ProcessEvent(*MouseUp);
01214 }
01215 if (MouseDown) delete MouseDown;
01216 if (MouseUp) delete MouseUp;
01217 }
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244 if (
01245 (EventType == wxEVT_COMMAND_BUTTON_CLICKED) ||
01246 FALSE)
01247 {
01248
01249 if ((ResourceID)id == _R(wxID_OK) )
01250 {
01251 msg.DlgMsg = DIM_COMMIT;
01252 HandleMessage = TRUE;
01253 }
01254 else if (id == _R(ID_CC_APPLY_NOW))
01255 {
01256
01257 msg.DlgMsg = DIM_SOFT_COMMIT;
01258 HandleMessage = TRUE;
01259 }
01260 else if (id == _R(wxID_CANCEL))
01261 {
01262 msg.DlgMsg = DIM_CANCEL;
01263
01264
01265 Defer=FALSE;
01266 HandleMessage = TRUE;
01267 }
01268 else if (id == _R(wxID_HELP))
01269 {
01270
01271 msg.DlgMsg = DIM_LFT_BN_CLICKED;
01272 msg.GadgetID = _R(ID_HELP);
01273 HandleMessage = TRUE;
01274 }
01275 else
01276 {
01277 msg.DlgMsg = DIM_LFT_BN_CLICKED;
01278 HandleMessage = TRUE;
01279 }
01280 }
01281 else if (
01282 (EventType == wxEVT_COMMAND_CHOICE_SELECTED) ||
01283 (EventType == wxEVT_COMMAND_LISTBOX_SELECTED) ||
01284 (EventType == wxEVT_COMMAND_CHECKLISTBOX_TOGGLED) ||
01285
01286
01287 (EventType == wxEVT_COMMAND_TEXT_URL) ||
01288
01289 (EventType == wxEVT_COMMAND_MENU_SELECTED) ||
01290
01291 (EventType == wxEVT_COMMAND_RADIOBOX_SELECTED) ||
01292 (EventType == wxEVT_COMMAND_VLBOX_SELECTED) ||
01293 (EventType == wxEVT_COMMAND_COMBOBOX_SELECTED) ||
01294 (EventType == wxEVT_COMMAND_SPINCTRL_UPDATED) ||
01295 ((
01296 (EventType == wxEVT_SCROLL_CHANGED) ||
01297 (EventType == wxEVT_SCROLL_THUMBTRACK) ||
01298 (EventType == wxEVT_SCROLL_THUMBRELEASE) ||
01299 (EventType == wxEVT_SCROLL_LINEUP) ||
01300 (EventType == wxEVT_SCROLL_LINEDOWN) ||
01301 (EventType == wxEVT_SCROLL_PAGEUP) ||
01302 (EventType == wxEVT_SCROLL_PAGEDOWN)
01303 ) &&
01304 !(
01305 (pGadget && pGadget->IsKindOf(CLASSINFO(wxSlider))) ||
01306 (pGadget && pGadget->IsKindOf(CLASSINFO(wxSliderCombo)))
01307 )
01308 ) ||
01309 (EventType == wxEVT_COMMAND_TREE_SEL_CHANGED) ||
01310 FALSE)
01311 {
01312 msg.DlgMsg = DIM_SELECTION_CHANGED;
01313 msg.DlgMsgParam = NO_COMMIT;
01314 HandleMessage = TRUE;
01315 }
01316 else if( EventType == wxEVT_COMMAND_TEXT_UPDATED &&
01317 pGadget == wxWindow::FindFocus() )
01318 {
01319 msg.DlgMsg = DIM_TEXT_CHANGED;
01320 HandleMessage = TRUE;
01321 }
01322 else if(
01323 (EventType == wxEVT_COMMAND_TEXT_ENTER) ||
01324 FALSE)
01325 {
01326 msg.DlgMsg = DIM_SELECTION_CHANGED;
01327 msg.DlgMsgParam = ENTER_COMMIT;
01328 HandleMessage = TRUE;
01329 }
01330 else if(
01331 (( (EventType == wxEVT_SCROLL_THUMBTRACK) ||
01332 (EventType == wxEVT_SCROLL_LINEUP) ||
01333 (EventType == wxEVT_SCROLL_LINEDOWN) ||
01334 (EventType == wxEVT_SCROLL_PAGEUP) ||
01335 (EventType == wxEVT_SCROLL_PAGEDOWN)
01336 ) && (pGadget && ( pGadget->IsKindOf(CLASSINFO(wxSlider)) || pGadget->IsKindOf(CLASSINFO(wxSliderCombo)) ))) ||
01337 FALSE)
01338 {
01339 msg.DlgMsg = DIM_SLIDER_POS_CHANGING;
01340 HandleMessage = TRUE;
01341 }
01342 else if(
01343
01344
01345 (( EventType == wxEVT_SCROLL_CHANGED) &&
01346 ( (pGadget && pGadget->IsKindOf(CLASSINFO(wxSlider))) || (pGadget && pGadget->IsKindOf(CLASSINFO(wxSliderCombo))) )
01347 ) ||
01348 FALSE)
01349 {
01350 msg.DlgMsg = DIM_SLIDER_POS_SET;
01351 HandleMessage = TRUE;
01352 }
01353 else if(
01354 (EventType == wxEVT_COMMAND_CHECKBOX_CLICKED) ||
01355 (EventType == wxEVT_COMMAND_RADIOBUTTON_SELECTED) ||
01356 FALSE)
01357 {
01358 msg.DlgMsg = DIM_LFT_BN_CLICKED;
01359 HandleMessage = TRUE;
01360 }
01361 else if (
01362 (EventType == wxEVT_COMMAND_LISTBOX_DOUBLECLICKED) ||
01363 FALSE)
01364 {
01365 msg.DlgMsg = DIM_SELECTION_CHANGED_COMMIT;
01366 HandleMessage = TRUE;
01367 }
01368 else if (
01369 (EventType == wxEVT_LEFT_DOWN) ||
01370 FALSE)
01371 {
01372 msg.DlgMsg = DIM_LFT_BN_DOWN;
01373 HandleMessage = TRUE;
01374 }
01375 else if (
01376 (EventType == wxEVT_LEFT_UP) ||
01377 FALSE)
01378 {
01379 msg.DlgMsg = DIM_LFT_BN_UP;
01380 HandleMessage = TRUE;
01381 }
01382 else if (
01383 (EventType == wxEVT_RIGHT_DOWN) ||
01384 FALSE)
01385 {
01386 msg.DlgMsg = DIM_RGT_BN_DOWN;
01387 HandleMessage = TRUE;
01388 }
01389 else if (
01390 (EventType == wxEVT_RIGHT_UP) ||
01391 FALSE)
01392 {
01393 msg.DlgMsg = DIM_RGT_BN_UP;
01394 HandleMessage = TRUE;
01395 }
01396 else if (
01397 (EventType == wxEVT_MIDDLE_DOWN) ||
01398 FALSE)
01399 {
01400 msg.DlgMsg = DIM_MID_BN_DOWN;
01401 HandleMessage = TRUE;
01402 }
01403 else if (
01404 (EventType == wxEVT_MIDDLE_UP) ||
01405 FALSE)
01406 {
01407 msg.DlgMsg = DIM_MID_BN_UP;
01408 HandleMessage = TRUE;
01409 }
01410 else if (
01411 (EventType == wxEVT_MOTION) ||
01412 FALSE)
01413 {
01414 msg.DlgMsg = ((wxMouseEvent *)&event)->Dragging()?DIM_MOUSE_DRAG:DIM_MOUSE_MOVE;
01415 HandleMessage = TRUE;
01416 }
01417 else if (
01418 (EventType == wxEVT_MOUSEWHEEL) ||
01419 FALSE)
01420 {
01421 msg.DlgMsg = (((wxMouseEvent *)&event)->GetWheelRotation()>0)?DIM_MOUSEWHEEL_UP:DIM_MOUSEWHEEL_DOWN;
01422 HandleMessage = TRUE;
01423 }
01424 else if (
01425 (EventType == wxEVT_MOVE) ||
01426 FALSE)
01427 {
01428 msg.DlgMsg = DIM_DLG_MOVED;
01429 HandleMessage = TRUE;
01430 }
01431 else if (
01432 (EventType == wxEVT_SIZE) ||
01433 FALSE)
01434 {
01435 if (event.GetEventObject() != pEvtHandler->pwxWindow)
01436 {
01437 Defer = FALSE;
01438 msg.DlgMsg = DIM_CTRL_RESIZED;
01439 HandleMessage = TRUE;
01440 }
01441 else
01442 {
01443 msg.DlgMsg = DIM_DLG_RESIZED;
01444 HandleMessage = TRUE;
01445 }
01446 }
01447 else if (
01448 (EventType == wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED) &&
01449 pGadget && pGadget->IsKindOf(CLASSINFO(wxBookCtrlBase)))
01450 {
01451 msg.DlgMsg = DIM_SET_ACTIVE;
01452 wxWindow *pPage = ((wxBookCtrlBase*)pGadget)->GetCurrentPage();
01453 msg.PageID = pPage?(pPage->GetId()):0;
01454 HandleMessage = TRUE;
01455 }
01456 else if (
01457 ((EventType == wxEVT_CAMDIALOG_REDRAW) && (pGadget)) ||
01458 FALSE)
01459 {
01460 if (CCamApp::IsDisabled())
01461 {
01462 TRACE( _T("kernel-rendered gadget repaint has been aborted: the system is disabled (due to an error/ensure?)\n"));
01463 HandleMessage = FALSE;
01464 }
01465 else
01466 {
01467
01468
01469
01470 ReDrawInfoType ExtraInfo;
01471
01472 ExtraInfo.pMousePos = NULL;
01473
01474
01475
01476
01477 CCPaintDC MyDc(pGadget);
01478
01479 ExtraInfo.pDC = &MyDc;
01480
01481
01482 ExtraInfo.Dpi = OSRenderRegion::GetFixedDCPPI(MyDc).GetHeight();
01483
01484
01485 wxSize WindowSize = pGadget->GetClientSize();
01486 ExtraInfo.dx = (((INT32)WindowSize.GetWidth())*72000) / ExtraInfo.Dpi;
01487 ExtraInfo.dy = (((INT32)WindowSize.GetHeight())*72000) / ExtraInfo.Dpi;
01488
01489 MyDc.GetDC()->BeginDrawing();
01490
01491 wxRegionIterator upd(pGadget->GetUpdateRegion());
01492
01493 BOOL Stop = FALSE;
01494
01495 while (upd && !Stop)
01496 {
01497
01498 wxRect ClipRect(upd.GetRect());
01499
01500
01501
01502
01503
01504
01505 BOOL UseClipRect = (pGadget->IsKindOf(CLASSINFO(wxCamDrawControl)))
01506 && (((wxCamDrawControl*)pGadget)->GetStyle() & wxCDCS_SETCLIPRECT);
01507
01508 if (UseClipRect)
01509 {
01510 MyDc.GetDC()->SetClippingRegion(ClipRect);
01511 ClipRect.Inflate(1,1);
01512 }
01513 else
01514 {
01515 ClipRect = wxRect(WindowSize);
01516 Stop = TRUE;
01517 }
01518
01519 DocRect DocClipRect;
01520
01521
01522
01523 DocClipRect.lo.x = (ClipRect.GetLeft() * 72000) / ExtraInfo.Dpi;
01524 DocClipRect.lo.y = ExtraInfo.dy - ((ClipRect.GetBottom() * 72000) / ExtraInfo.Dpi);
01525
01526 DocClipRect.hi.x = (ClipRect.GetRight() * 72000) / ExtraInfo.Dpi;
01527 DocClipRect.hi.y = ExtraInfo.dy - ((ClipRect.GetTop() * 72000) / ExtraInfo.Dpi);
01528
01529
01530 ExtraInfo.pClipRect = &DocClipRect;
01531
01532
01533
01534
01535 BROADCAST_TO_CLASS(DialogMsg(pEvtHandler->pwxWindow, DIM_REDRAW, id, (UINT_PTR)(void *)&ExtraInfo, PageID), DialogOp);
01536
01537 upd ++ ;
01538 }
01539
01540 MyDc.GetDC()->EndDrawing();
01541
01542
01543
01544 }
01545 }
01546
01547
01548
01549
01550
01551
01552 if ((msg.DlgMsg != DIM_NONE) && pGadget && pGadget->IsKindOf(CLASSINFO(wxCamDrawControl)) && event.IsKindOf(CLASSINFO(wxMouseEvent)))
01553 {
01554 switch (msg.DlgMsg)
01555 {
01556 case DIM_LFT_BN_DOWN:
01557 case DIM_LFT_BN_UP:
01558 case DIM_LFT_BN_CLICKED:
01559 case DIM_RGT_BN_DOWN:
01560 case DIM_RGT_BN_UP:
01561 case DIM_RGT_BN_CLICKED:
01562 case DIM_MID_BN_DOWN:
01563 case DIM_MID_BN_UP:
01564 case DIM_MID_BN_CLICKED:
01565 case DIM_MOUSE_DRAG:
01566 case DIM_MOUSE_MOVE:
01567 case DIM_MOUSEWHEEL_UP:
01568 case DIM_MOUSEWHEEL_DOWN:
01569 {
01570
01571
01572
01573
01574 ReDrawInfoType ExtraInfo;
01575
01576 ExtraInfo.pMousePos = NULL;
01577
01578
01579
01580
01581 CCPaintDC MyDc(pGadget);
01582
01583 ExtraInfo.pDC = NULL;
01584
01585
01586 ExtraInfo.Dpi = OSRenderRegion::GetFixedDCPPI(MyDc).GetHeight();
01587
01588
01589 wxSize WindowSize = pGadget->GetClientSize();
01590 ExtraInfo.dx = (((INT32)WindowSize.GetWidth())*72000) / ExtraInfo.Dpi;
01591 ExtraInfo.dy = (((INT32)WindowSize.GetHeight())*72000) / ExtraInfo.Dpi;
01592
01593
01594
01595 INT32 XPos = ((wxMouseEvent *)(&event))->GetX();
01596 INT32 YPos = ((wxMouseEvent *)(&event))->GetY();
01597
01598 DocCoord MousePos;
01599 MousePos.x = (XPos * 72000) / ExtraInfo.Dpi;
01600 MousePos.y = ExtraInfo.dy - ((YPos * 72000) / ExtraInfo.Dpi);
01601 ExtraInfo.pMousePos = &MousePos;
01602
01603 BROADCAST_TO_CLASS(DialogMsg(pEvtHandler->pwxWindow, msg.DlgMsg, id, (UINT_PTR)(void *)&ExtraInfo, PageID), DialogOp);
01604
01605 msg.DlgMsg = DIM_NONE;
01606 }
01607
01608 default:
01609 break;
01610 }
01611 }
01612
01613
01614
01615 if (msg.DlgMsg != DIM_NONE)
01616 {
01617
01618 if (!(pEvtHandler->pDialogOp->IsModal()) && (( DIM_SELECTION_CHANGED == msg.DlgMsg ) || ( DIM_SLIDER_POS_SET == msg.DlgMsg )))
01619 {
01620 TRACEUSER( "luke", _T("Change focus") );
01621 AfxGetApp().GiveActiveCanvasFocus();
01622 }
01623
01624 if (Defer)
01625 {
01626
01627 wxCamDialogEvent deferredevent (wxEVT_CAMDIALOG_DEFERREDMSG, event.GetId(), msg);
01628 deferredevent.SetEventObject(pEvtHandler->pwxWindow);
01629
01630 pEvtHandler->pwxWindow->GetEventHandler()->AddPendingEvent(deferredevent);
01631 }
01632 else
01633 {
01634 BROADCAST_TO_CLASS( DialogMsg(msg), DialogOp );
01635 }
01636 }
01637
01638
01639
01640 if (!HandleMessage) event.Skip();
01641 return;
01642 }
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666 wxBookCtrlBase * DialogManager::GetBookControl(CWindowID WindowID, CGadgetID Gadget )
01667 {
01668
01669 if (!WindowID) return NULL;
01670
01671
01672 if (WindowID->IsKindOf(CLASSINFO(wxPropertySheetDialog)))
01673 return ((wxPropertySheetDialog*)WindowID)->GetBookCtrl();
01674
01675
01676 if (!Gadget)
01677 {
01678 if ((WindowID->GetEventHandler())->IsKindOf(CLASSINFO(DialogEventHandler)))
01679 {
01680 DialogOp * pDialogOp = ((DialogEventHandler *)(WindowID->GetEventHandler()))->pDialogOp;
01681
01682
01683 if ((pDialogOp) && (pDialogOp->IS_KIND_OF(DialogTabOp)))
01684 Gadget=((DialogTabOp*)pDialogOp)->GetDefaultBookGadget();
01685 }
01686 }
01687
01688
01689 if (Gadget)
01690 {
01691 wxWindow * pGadget = GetGadget(WindowID, Gadget);
01692 if (pGadget->IsKindOf(CLASSINFO(wxBookCtrlBase)))
01693 return (wxBookCtrlBase*)pGadget;
01694 else
01695 return NULL;
01696 }
01697
01698
01699 wxWindowList::Node * pNode = WindowID->GetChildren().GetFirst();
01700 while (pNode)
01701 {
01702 wxWindow * child = pNode->GetData();
01703 if (child->IsKindOf(CLASSINFO(wxBookCtrlBase)))
01704 return (wxBookCtrlBase*)child;
01705 pNode = pNode->GetNext();
01706 }
01707
01708
01709 pNode = WindowID->GetChildren().GetFirst();
01710 while (pNode)
01711 {
01712 wxBookCtrlBase * pBook=GetBookControl(WindowID, 0);
01713 if (pBook)
01714 return pBook;
01715 pNode = pNode->GetNext();
01716 }
01717
01718 return NULL;
01719 }
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739 BOOL DialogManager::IsGadgetTickable(CWindowID WindowID,
01740 CGadgetID Gadget)
01741 {
01742 wxWindow * pGadget = GetGadget(WindowID, Gadget);
01743 if (!pGadget) return FALSE;
01744
01745
01746 return ( pGadget->IsKindOf(CLASSINFO(wxCheckBox)) ||
01747 pGadget->IsKindOf(CLASSINFO(wxButton)) ||
01748 (pGadget->IsKindOf(CLASSINFO(wxCamArtControl)) && (((wxCamArtControl*)pGadget)->GetStyle() & wxCACS_PUSHBUTTON)) ||
01749 pGadget->IsKindOf(CLASSINFO(wxBitmapButton))
01750 );
01751 }
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769 BOOL DialogManager::ColourPickerAbort(CWindowID WindowID, CGadgetID Gadget, WPARAM wParam)
01770 {
01771 PORTNOTETRACE("dialog","DialogManager::ColourPickerAbort - do nothing");
01772 #ifndef EXCLUDE_FROM_XARALX
01773
01774 HWND hGadget = GetDlgItem((HWND)WindowID, (INT32)Gadget);
01775 String_256 ClassNameStr;
01776
01777
01778 GetClassName(hGadget, (TCHAR*)ClassNameStr, 255);
01779
01780 if (ClassNameStr == String_8(TEXT("cc_colPicker")))
01781 {
01782 BOOL RetVal = FALSE;
01783
01784 RetVal = SendMessage(hGadget, WM_COLOURPICKERABORT, wParam, 0);
01785
01786 return (RetVal);
01787 }
01788
01789 return (TRUE);
01790 ENSURE(FALSE, "Calling ColourPickerAbort for an invalid control");
01791 #endif
01792 return FALSE;
01793 }
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811 void DialogManager::Delete(CWindowID WindowID, DialogOp* pDlgOp)
01812 {
01813 ERROR2IF (!pDlgOp, (void)0, "No dialog op to DialogManager::Delete()");
01814 ERROR2IF (!WindowID, (void)0, "No window to DialogManager::Delete()");
01815
01816 if (!pDlgOp->pEvtHandler)
01817 {
01818 ERROR3("DialogManager::Delete() No dialog op event handler - has this window been deleted twice?");
01819 return;
01820 }
01821
01822
01823
01824 if (pDlgOp->pEvtHandler && pDlgOp->pEvtHandler->m_GrimReaperSent)
01825 {
01826 TRACEALL(_T("DialogManager::Delete() Window has been deleted by something else, then Delete() called"));
01827 return;
01828 }
01829
01830 if (((wxWindow *)WindowID)->IsBeingDeleted())
01831 {
01832 ERROR3("Trying to delete a window that is already being deleted, has an event handler, but has not sent grim reaper");
01833 return;
01834 }
01835
01836 wxBookCtrlBase * pBook=NULL;
01837
01838 if (pDlgOp->IS_KIND_OF(DialogTabOp))
01839 pBook=GetBookControl(WindowID);
01840
01841
01842
01843 DialogPosition* DlgPos = (DialogPosition*)DialogPositionList.GetHead();
01844 CWindowIDItem* WinID;
01845 while(DlgPos != NULL)
01846 {
01847
01848 WinID = (CWindowIDItem*)DlgPos->DlgWinList.GetHead();
01849 while (WinID != NULL)
01850 {
01851 if ((WinID->DlgWin) == WindowID)
01852 {
01853
01854
01855 delete(DlgPos->DlgWinList.RemoveItem((ListItem*)WinID));
01856 goto FoundPos;
01857 }
01858 WinID = (CWindowIDItem*)DlgPos->DlgWinList.GetNext((ListItem*)WinID);
01859 }
01860
01861 DlgPos = ((DialogPosition*)DialogPositionList.GetNext((ListItem*)DlgPos));
01862 }
01863
01864
01865
01866 FoundPos:
01867
01868 wxWindow *pCWnd = (wxWindow *)WindowID;
01869
01870
01871 if (DlgPos != NULL)
01872 {
01873
01874 wxRect DialogRect( pCWnd->GetRect() );
01875 DlgPos->LastX = DialogRect.x;
01876 DlgPos->LastY = DialogRect.y;
01877 DlgPos->ActivePage = 0;
01878 DlgPos->ActivePageIndex = 0;
01879
01880
01881
01882
01883 if (pBook)
01884 {
01885 wxNotebookPage* pPage = pBook->GetCurrentPage();
01886 if (pPage)
01887 {
01888 DlgPos->ActivePage = pPage->GetId();
01889
01890 GetPageWindow(WindowID, DlgPos->ActivePage, &(DlgPos->ActivePageIndex));
01891 }
01892 else
01893 ERROR3("There is no active page");
01894 }
01895 }
01896
01897 if (pDlgOp->pEvtHandler->wxAUImanaged)
01898 {
01899 wxAuiPaneInfo paneinfo = CCamFrame::GetMainFrame()->GetFrameManager()->GetPane(pCWnd);
01900 if (paneinfo.IsOk())
01901 SavePaneInfo(wxString(CamResource::GetObjectName(pCWnd->GetId())), paneinfo);
01902
01903 CCamFrame::GetMainFrame()->GetFrameManager()->DetachPane(pCWnd);
01904 CCamFrame::GetMainFrame()->UpdateFrameManager();
01905 }
01906
01907
01908 DlgDiscardString* DiscardStr = (DlgDiscardString*)(DiscardStrList.GetHead());
01909 while (DiscardStr != NULL)
01910 {
01911 DlgDiscardString* Next = (DlgDiscardString*)(DiscardStrList.GetNext(DiscardStr));
01912 if (DiscardStr->DlgWindow == WindowID)
01913
01914 {
01915 delete (DiscardStr->pStr);
01916 delete(DiscardStrList.RemoveItem(DiscardStr));
01917 }
01918 DiscardStr = Next;
01919 }
01920
01921
01922 ScrollPageInc* PgInc = (ScrollPageInc*)(ScrollPageIncList.GetHead());
01923 while (PgInc != NULL)
01924 {
01925 ScrollPageInc* Next = (ScrollPageInc*)(ScrollPageIncList.GetNext((ListItem*)PgInc));
01926 if( PgInc->pDlgWindow == WindowID )
01927
01928 delete (ScrollPageIncList.RemoveItem( (ListItem*)PgInc) );
01929
01930 PgInc = Next;
01931 }
01932
01933
01934 List* ControlInfoList = GetControlList( (wxWindow *)WindowID );
01935
01936
01937 DropDown::KillDropDownsByWindow(WindowID);
01938 CGridDropDown::KillDropDownsByWindow(WindowID);
01939
01940
01941 ControlList::Get()->RemoveWindowAndChildren((wxWindow *)WindowID);
01942
01943
01944
01945
01946 ((wxWindow *)WindowID)->PopEventHandler(FALSE);
01947 pDlgOp->pEvtHandler->Destroy();
01948
01949
01950 if (pDlgOp->IsModal() && WindowID->IsKindOf(CLASSINFO(wxDialog)))
01951
01952 {
01953 ( (wxDialog *)WindowID )->EndModal( TRUE );
01954 ( (wxWindow *)WindowID )->Destroy();
01955 }
01956 else
01957 {
01958 ( (wxWindow *)WindowID )->Destroy();
01959 }
01960
01961 if (ControlInfoList)
01962 {
01963
01964
01965 while (!ControlInfoList->IsEmpty())
01966 delete(ControlInfoList->RemoveHead());
01967
01968 delete (ControlInfoList);
01969 ControlInfoList = NULL;
01970 }
01971
01972
01973 if (pDlgOp->IsModal())
01974 {
01975
01976 }
01977
01978 DefaultKeyboardFocus();
01979
01980 }
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003 void DialogManager::SetComboListLength(CWindowID WindowID,CGadgetID Gadget)
02004 {
02005
02006
02007 return;
02008 }
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043 void DialogManager::SetGadgetBitmaps(CWindowID WindowID, CGadgetID Gadget, UINT32 Bitmap1, UINT32 Bitmap2)
02044 {
02045 PORTNOTETRACE("dialog","DialogManager::SetGadgetBitmaps - do nothing");
02046 #ifndef EXCLUDE_FROM_XARALX
02047
02048 HWND hGadget = GetDlgItem((HWND)WindowID, (INT32)Gadget);
02049
02050
02051 String_256 ClassNameStr;
02052 GetClassName(hGadget, (TCHAR*)ClassNameStr, 255);
02053
02054
02055 if ((ClassNameStr == String_16(TEXT("cc_Slider"))))
02056 {
02057
02058 SliderBitmapInfo BitmapInfo;
02059 BitmapInfo.hAppInstance = AfxGetResourceHandle();
02060 BitmapInfo.BaseBmpStr = MAKEINTRESOURCE(Bitmap1);
02061 BitmapInfo.SliderBmpStr = MAKEINTRESOURCE(Bitmap2);
02062
02063
02064 SendMessage(hGadget, WM_SET_CHANNEL_WIDTH, 8, 0);
02065 SendMessage(hGadget, WM_SET_SLIDERBITMAPS, 0, (INT32)&BitmapInfo);
02066
02067 }
02068
02069
02070
02071 if (ClassNameStr == String_16(TEXT("cc_BitmapButton"))
02072 || ClassNameStr == String_16(TEXT("cc_SmallBitmapButton")) )
02073 {
02074 SetGadgetBitmaps(hGadget, AfxGetResourceHandle());
02075 }
02076 #endif
02077 }
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095 void DialogManager::SetGadgetBitmap(CWindowID WindowID, CGadgetID Gadget, ResourceID Bitmap)
02096 {
02097 wxWindow* pGadget = GetGadget(WindowID, Gadget);
02098 if (!pGadget) return;
02099
02100 if ( pGadget->IsKindOf(CLASSINFO(wxCamArtControl))
02101 )
02102 {
02103 ((wxCamArtControl *)pGadget)->SetBitmapId(Bitmap);
02104 pGadget->Refresh();
02105 }
02106 }
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121 ResourceID DialogManager::GetGadgetBitmap(CWindowID WindowID, CGadgetID Gadget)
02122 {
02123 wxWindow* pGadget = GetGadget(WindowID, Gadget);
02124 if (!pGadget) return 0;
02125
02126 if ( pGadget->IsKindOf(CLASSINFO(wxCamArtControl))
02127 )
02128 {
02129 return ((wxCamArtControl *)pGadget)->GetBitmapId();
02130 }
02131 return 0;
02132 }
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148 void DialogManager::SetGadgetBitmaps(CWindowID WindowID, CGadgetID Gadget, const CGadgetImageList& imagelist)
02149 {
02150 wxWindow* pGadget = GetGadget(WindowID, Gadget);
02151 if (!pGadget) return;
02152
02153 if ( pGadget->IsKindOf(CLASSINFO(wxTreeCtrl))
02154 )
02155 {
02156 wxImageList* plist = new wxImageList(imagelist.GetWidth(), imagelist.GetHeight());
02157
02158 CamArtProvider* pCAP = CamArtProvider::Get();
02159 ERROR3IF(pCAP==NULL, "Can't find CamArtProvider!");
02160
02161 ListItem* pItem = NULL;
02162 ResourceID resID=0;
02163 pItem = imagelist.FindFirstBitmap(&resID);
02164 while (pItem)
02165 {
02166 wxBitmap* pBitmap = pCAP->FindBitmap(resID);
02167 plist->Add((const wxBitmap&) *pBitmap);
02168
02169 pItem = imagelist.FindNextBitmap(pItem, &resID);
02170 }
02171
02172 ((wxTreeCtrl*)pGadget)->AssignImageList(plist);
02173
02174 return;
02175 }
02176
02177 ERROR3("SetTreeGadgetItem called on non-tree gadget");
02178 return;
02179 }
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204 void DialogManager::SetBitmapButtonIndexes(CWindowID WindowID, CGadgetID Gadget,
02205 UINT32 UnselectedIndex, UINT32 SelectedIndex)
02206
02207 {
02208 PORTNOTETRACE("dialog","DialogManager::SetBitmapButtonIndexes - do nothing");
02209 #ifndef EXCLUDE_FROM_XARALX
02210
02211 HWND hGadget = GetDlgItem((HWND)WindowID, (INT32)Gadget);
02212
02213
02214 String_256 ClassNameStr;
02215 GetClassName(hGadget, (TCHAR*)ClassNameStr, 255);
02216
02217
02218
02219
02220 if (ClassNameStr == String_16(TEXT("cc_BitmapButton"))
02221 || ClassNameStr == String_16(TEXT("cc_SmallBitmapButton")) )
02222 {
02223 SetGadgetBitmaps(hGadget, AfxGetResourceHandle(), SelectedIndex, UnselectedIndex);
02224 }
02225 #endif
02226 }
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320
02321
02322
02323
02324
02325
02326
02327
02328
02329
02330
02331
02332
02333
02334
02335
02336
02337
02338
02339
02340
02341
02342
02343
02344
02345
02346
02347
02348
02349
02350
02351
02352
02353
02354
02355
02356
02357
02358
02359
02360
02361
02362
02363
02364
02365
02366
02367
02368
02369
02370
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381 BOOL DialogManager::SetUnitGadgetValue( CWindowID WindowID,
02382 CGadgetID Gadget,
02383 UnitType Unit,
02384 MILLIPOINT Value,
02385 BOOL EndOfList,
02386 INT32 ListPos)
02387 {
02388
02389 String_256 StrValue;
02390
02391 Convert::MillipointsToString( Value, Unit, &StrValue );
02392 return( SetStringGadgetValue( WindowID, Gadget, StrValue, EndOfList, ListPos ) );
02393 }
02394
02395
02396
02397
02398
02399
02400
02401
02402
02403
02404
02405
02406
02407
02408
02409
02410
02411
02412
02413
02414
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428
02429
02430
02431
02432
02433
02434
02435
02436 BOOL DialogManager::SetDimensionUnitGadgetValue(CWindowID WindowID,
02437 CGadgetID Gadget,
02438 UnitType units,
02439 double Value,
02440 Node* pNode,
02441 BOOL IncludeUnitSpecifier,
02442 BOOL EndOfList,
02443 INT32 ListPos)
02444 {
02445 DimScale* pDimScale = DimScale::GetPtrDimScale(pNode);
02446 ERROR2IF(pDimScale==NULL,FALSE,"DialogManager::SetDimensionUnitGadgetValue() - pDimScale==NULL");
02447
02448 String_256 Str;
02449 BOOL ok = pDimScale->ConvertToUnits(Value,&Str,IncludeUnitSpecifier,-1,units);
02450 if (ok) ok = SetStringGadgetValue(WindowID,Gadget,Str,EndOfList,ListPos);
02451
02452 return ok;
02453 }
02454
02455
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472
02473
02474
02475
02476
02477
02478
02479
02480
02481
02482
02483
02484
02485
02486
02487
02488
02489
02490
02491
02492
02493
02494
02495
02496
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521
02522
02523
02524
02525 BOOL DialogManager::SetLongGadgetValue(CWindowID WindowID,
02526 CGadgetID Gadget,
02527 INT32 Value,
02528 BOOL EndOfList,
02529 INT32 ListPos)
02530 {
02531 wxWindow * pGadget = GetGadget(WindowID, Gadget);
02532 if (!pGadget) return FALSE;
02533
02534 if ( pGadget->IsKindOf(CLASSINFO(wxButton)) ||
02535 pGadget->IsKindOf(CLASSINFO(wxBitmapButton)) )
02536 {
02537
02538 PORTNOTETRACE("dialog","DialogManager::SetLongGadgetValue on BitmapButton - do nothing");
02539 return FALSE;
02540 }
02541
02542
02543 if ( pGadget->IsKindOf(CLASSINFO(wxCheckBox)) )
02544 {
02545 ((wxCheckBox *)(pGadget))->SetValue(Value !=0);
02546 return TRUE;
02547 }
02548
02549 if ( pGadget->IsKindOf(CLASSINFO(wxRadioButton)) )
02550 {
02551 ((wxRadioButton *)(pGadget))->SetValue( Value != 0 );
02552 return TRUE;
02553 }
02554
02555 if ( pGadget->IsKindOf(CLASSINFO(wxScrollBar)) )
02556 {
02557 ((wxScrollBar *)(pGadget))->SetThumbPosition(Value);
02558 return TRUE;
02559 }
02560
02561 if ( pGadget->IsKindOf(CLASSINFO(wxSlider)) )
02562 {
02563 ((wxSlider *)(pGadget))->SetValue(Value);
02564 return TRUE;
02565 }
02566
02567 if ( pGadget->IsKindOf(CLASSINFO(wxSliderCombo)) )
02568 {
02569 ((wxSliderCombo *)(pGadget))->SetSliderValue(Value);
02570 return TRUE;
02571 }
02572
02573 if ( pGadget->IsKindOf(CLASSINFO(wxGauge)) )
02574 {
02575 ((wxGauge *)(pGadget))->SetValue(Value);
02576 return TRUE;
02577 }
02578
02579 if ( pGadget->IsKindOf(CLASSINFO(wxCamArtControl)) )
02580 {
02581 ((wxCamArtControl *)(pGadget))->SetValue(Value);
02582 return TRUE;
02583 }
02584
02585
02586 #if 0
02587
02588
02589 else if (ClassNameStr == String_16(TEXT("cc_CustomEdit")))
02590 {
02591 ...
02592 }
02593 #endif
02594
02595
02596
02597 String_256 StrValue;
02598
02599 Convert::LongToString(Value, &StrValue);
02600 return(SetStringGadgetValue(WindowID, Gadget, StrValue, EndOfList, ListPos));
02601 }
02602
02603
02604
02605
02606
02607
02608
02609
02610
02611
02612
02613
02614
02615
02616
02617
02618
02619
02620
02621
02622
02623
02624
02625
02626
02627
02628
02629
02630
02631
02632
02633
02634
02635
02636
02637
02638
02639
02640
02641
02642
02643
02644
02645
02646
02647
02648
02649
02650
02651
02652
02653
02654
02655
02656
02657
02658
02659
02660
02661
02662
02663
02664
02665
02666
02667
02668
02669
02670
02671
02672
02673
02674
02675
02676 BOOL DialogManager::SetDoubleGadgetValue(CWindowID WindowID,
02677 CGadgetID Gadget,
02678 double Value,
02679 BOOL EndOfList,
02680 INT32 ListPos)
02681 {
02682 wxWindow * pGadget = GetGadget(WindowID, Gadget);
02683 if (!pGadget) return FALSE;
02684
02685 if (( pGadget->IsKindOf(CLASSINFO(wxButton))) ||
02686 ( pGadget->IsKindOf(CLASSINFO(wxBitmapButton))) ||
02687 ( pGadget->IsKindOf(CLASSINFO(wxCheckBox))) ||
02688 ( pGadget->IsKindOf(CLASSINFO(wxRadioButton))) ||
02689 ( pGadget->IsKindOf(CLASSINFO(wxScrollBar))) ||
02690 ( pGadget->IsKindOf(CLASSINFO(wxSlider))) ||
02691 ( pGadget->IsKindOf(CLASSINFO(wxSliderCombo))) ||
02692 ( pGadget->IsKindOf(CLASSINFO(wxCamArtControl))) ||
02693 ( pGadget->IsKindOf(CLASSINFO(wxGauge)))
02694 )
02695 return SetLongGadgetValue( WindowID, Gadget, (INT32)(floor(Value+0.5)), EndOfList, ListPos);
02696
02697 String_256 StrValue;
02698
02699 Convert::DoubleToString(Value, &StrValue);
02700 return(SetStringGadgetValue(WindowID, Gadget, StrValue, EndOfList, ListPos));
02701 }
02702
02703
02704
02705
02706
02707
02708
02709
02710
02711
02712
02713
02714
02715
02716
02717
02718
02719
02720
02721
02722
02723
02724
02725
02726
02727
02728
02729
02730
02731
02732
02733
02734
02735
02736
02737
02738
02739
02740
02741
02742
02743
02744
02745
02746
02747
02748
02749
02750
02751
02752
02753
02754
02755
02756
02757
02758
02759
02760
02761
02762
02763 BOOL DialogManager::SetStringGadgetValue(CWindowID WindowID,
02764 CGadgetID Gadget,
02765 UINT32 IDStr,
02766 BOOL EndOfList,
02767 INT32 ListPos)
02768 {
02769 String_256* StrVal = new String_256(IDStr);
02770 ERROR1IF(StrVal == NULL, FALSE, _R(IDS_OUT_OF_MEMORY));
02771
02772
02773
02774 DlgDiscardString *DiscardStr = new DlgDiscardString;
02775 if( DiscardStr == NULL )
02776 {
02777 delete StrVal;
02778 ERROR1(FALSE, _R(IDS_OUT_OF_MEMORY));
02779 }
02780
02781
02782
02783
02784
02785
02786 wxWindow *pCWnd = (wxWindow *)WindowID;
02787 wxWindow *WndID = pCWnd;
02788
02789
02790
02791
02792
02793
02794
02795
02796
02797
02798
02799 DiscardStr->DlgWindow = WndID;
02800 DiscardStr->pStr = StrVal;
02801 DiscardStrList.AddHead( DiscardStr );
02802
02803 return (SetStringGadgetValue(WindowID, Gadget, *StrVal, EndOfList, ListPos));
02804 }
02805
02806
02807
02808
02809
02810
02811
02812
02813
02814
02815
02816
02817
02818 wxWindow * DialogManager::GetGadget(CWindowID WindowID, CGadgetID Gadget)
02819 {
02820 ERROR2IF(!WindowID || !WindowID->IsKindOf(CLASSINFO(wxWindow)), FALSE, "Bad Window ID passed");
02821 wxWindow * pGadget=WindowID->FindWindow(Gadget);
02822
02823 if (!pGadget)
02824 {
02825
02826
02827 return NULL;
02828 }
02829 #if 0
02830 const TCHAR * pGadgetClassName = (const TCHAR *) pGadget->GetClassInfo()->GetClassName();
02831 TRACEUSER("amb",_T("Gadget is a %s"),pGadgetClassName);
02832 #endif
02833 return pGadget;
02834 }
02835
02836
02837
02838
02839
02840
02841
02842
02843
02844
02845
02846
02847
02848 OpDescriptor * DialogManager::GetGadgetOpDescriptor(CWindowID WindowID, CGadgetID Gadget)
02849 {
02850 wxWindow * pWindow = GetGadget(WindowID, Gadget);
02851 if (!pWindow) return NULL;
02852
02853
02854 if (!pWindow->IsKindOf(CLASSINFO(wxControl)))
02855 return NULL;
02856
02857 wxControl * pControl = (wxControl *)pWindow;
02858 return ControlList::Get()->Find(pControl);
02859 }
02860
02861
02862
02863
02864
02865
02866
02867
02868
02869
02870
02871
02872
02873
02874
02875
02876
02877
02878
02879
02880
02881
02882
02883
02884
02885
02886
02887
02888
02889
02890
02891
02892
02893
02894
02895
02896
02897
02898
02899
02900
02901
02902
02903
02904
02905
02906
02907
02908
02909
02910
02911
02912
02913
02914
02915
02916
02917
02918 BOOL DialogManager::SetStringGadgetValue(CWindowID WindowID,
02919 CGadgetID Gadget,
02920 const StringBase& StrVal,
02921 BOOL EndOfList,
02922 INT32 ListPos)
02923 {
02924 wxWindow * pGadget = GetGadget(WindowID, Gadget);
02925 if (!pGadget) return FALSE;
02926
02927 wxString String( (const TCHAR*)StrVal );
02928
02929
02930 if ( pGadget->IsKindOf(CLASSINFO(wxListBox)) ||
02931 pGadget->IsKindOf(CLASSINFO(wxComboBox)) ||
02932 pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)) ||
02933 pGadget->IsKindOf(CLASSINFO(wxChoice))
02934 )
02935 {
02936 if (EndOfList)
02937 {
02938 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
02939 ((wxOwnerDrawnComboBox *)pGadget)->Append(String);
02940 else
02941 ((wxControlWithItems *)pGadget)->Append(String);
02942 return TRUE;
02943 }
02944
02945 if (pGadget->IsKindOf(CLASSINFO(wxComboBox)) && (pGadget->GetWindowStyle() & wxCB_SORT))
02946 {
02947 PORTNOTETRACE("dialog", "Mainting original order of combos displayed sorted is not supported");
02948 pGadget->SetWindowStyle(pGadget->GetWindowStyle() & ~wxCB_SORT);
02949 }
02950
02951 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)) && (pGadget->GetWindowStyle() & wxCB_SORT))
02952 {
02953 PORTNOTETRACE("dialog", "Mainting original order of combos displayed sorted is not supported");
02954 pGadget->SetWindowStyle(pGadget->GetWindowStyle() & ~wxCB_SORT);
02955 }
02956
02957 if (pGadget->IsKindOf(CLASSINFO(wxListBox)) && (pGadget->GetWindowStyle() & wxLB_SORT))
02958 {
02959 PORTNOTETRACE("dialog", "Mainting original order of list boxes displayed sorted is not supported");
02960 pGadget->SetWindowStyle(pGadget->GetWindowStyle() & ~wxLB_SORT);
02961 }
02962
02963 if (ListPos >=0)
02964 {
02965 if (
02966 (pGadget->IsKindOf(CLASSINFO(wxComboBox)) && (pGadget->GetWindowStyle() & wxCB_SORT)) ||
02967 (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)) && (pGadget->GetWindowStyle() & wxCB_SORT)) ||
02968 (pGadget->IsKindOf(CLASSINFO(wxListBox)) && (pGadget->GetWindowStyle() & wxLB_SORT)) ||
02969 (pGadget->IsKindOf(CLASSINFO(wxChoice)))
02970 )
02971 {
02972
02973
02974 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
02975 ((wxOwnerDrawnComboBox *)pGadget)->Append(String);
02976 else
02977 ((wxControlWithItems *)pGadget)->Append(String);
02978 return TRUE;
02979 }
02980 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
02981 return (((wxOwnerDrawnComboBox *)pGadget)->Insert(String, ListPos) <0 )?FALSE:TRUE;
02982 else
02983 return (((wxControlWithItems *)pGadget)->Insert(String, ListPos) <0 )?FALSE:TRUE;
02984 }
02985
02986 if (pGadget->IsKindOf(CLASSINFO(wxComboBox)))
02987 {
02988 ((wxComboBox *)pGadget)->SetValue(String);
02989 return TRUE;
02990 }
02991
02992 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
02993 {
02994 ((wxOwnerDrawnComboBox *)pGadget)->SetValue(String);
02995 return TRUE;
02996 }
02997
02998 ERROR3("Attempt to insert item into edit field of gadget without one");
02999 return FALSE;
03000 }
03001
03002 if ( pGadget->IsKindOf(CLASSINFO(wxTextCtrl)) )
03003 {
03004 ((wxTextCtrl *)pGadget)->SetValue(String);
03005 return TRUE;
03006 }
03007
03008 if ( pGadget->IsKindOf(CLASSINFO(wxSliderCombo)) )
03009 {
03010 ((wxSliderCombo *)pGadget)->SetValue(String);
03011 return TRUE;
03012 }
03013
03014 pGadget->SetLabel(String);
03015
03016 return TRUE;
03017 }
03018
03019
03020
03021
03022
03023
03024
03025
03026
03027
03028
03029
03030
03031
03032
03033
03034
03035
03036
03037
03038
03039
03040
03041
03042
03043
03044
03045
03046
03047
03048
03049
03050
03051
03052
03053
03054
03055
03056
03057
03058
03059
03060
03061
03062
03063
03064
03065
03066
03067
03068
03069 BOOL DialogManager::SetCustomComboGadgetValue(CWindowID WindowID,
03070 CGadgetID Gadget,
03071 CustomComboBoxControlDataItem* TheItem,
03072 BOOL EndOfList,
03073 INT32 ListPos)
03074 {
03075 PORTNOTETRACE("dialog","DialogManager::SetCustomComboGadgetValue - do nothing");
03076 #ifndef EXCLUDE_FROM_XARALX
03077 String_256 ClassNameStr;
03078
03079 HWND hGadget = GetDlgItem((HWND)WindowID, (INT32)Gadget);
03080
03081 GetClassName(hGadget, (TCHAR*)ClassNameStr, 255);
03082
03083 if ((ClassNameStr == String_64(TEXT("cc_1dBitmapComboBoxEdit"))) ||
03084 (ClassNameStr == String_64(TEXT("cc_2dBitmapComboBoxEdit"))) )
03085 {
03086 BOOL RetVal = FALSE;
03087
03088 if (ListPos == 0)
03089 {
03090 ASSERT (TheItem);
03091
03092 RetVal = SendMessage (hGadget, WM_CCINSERTBITMAP, 0, (WPARAM) (CustomComboBoxControlDataItem*) TheItem);
03093
03094 }
03095 else if (ListPos >= 1)
03096
03097 {
03098 ASSERT (TheItem == NULL);
03099
03100 RetVal = SendMessage (hGadget, CB_SETCURSEL, (WPARAM) (ListPos-1), (LPARAM) 0);
03101 }
03102 else if ((ListPos == -1) || (ListPos == -2))
03103 {
03104 ASSERT (TheItem == NULL);
03105
03106 RetVal = SendMessage (hGadget, CB_SETCURSEL, (WPARAM) (ListPos), (LPARAM) 0);
03107 }
03108
03109 return (RetVal);
03110 }
03111 return (TRUE);
03112 ENSURE(FALSE, "Calling SetCustomComboGadgetValue for an invalid control");
03113 #endif
03114 return FALSE;
03115 }
03116
03117
03118
03119
03120
03121
03122
03123
03124
03125
03126
03127
03128
03129
03130
03131
03132
03133
03134
03135
03136
03137
03138
03139
03140
03141
03142 BOOL DialogManager::SelectCustomComboGadgetValueOnString (CWindowID WindowID,
03143 CGadgetID Gadget,
03144 StringBase* StrVal)
03145 {
03146 PORTNOTETRACE("dialog","DialogManager::SelectCustomComboGadgetValueOnString - do nothing");
03147 #ifndef EXCLUDE_FROM_XARALX
03148 String_256 ClassNameStr;
03149
03150 HWND hGadget = GetDlgItem((HWND)WindowID, (INT32)Gadget);
03151
03152 GetClassName(hGadget, (TCHAR*)ClassNameStr, 255);
03153
03154 if( ClassNameStr == String_64( TEXT("cc_2dBitmapComboBoxEdit") ) )
03155 {
03156 BOOL RetVal = FALSE;
03157
03158 RetVal = SendMessage (hGadget, CB_FINDSTRINGEXACT, (WPARAM) (-1), (INT32)(TCHAR*)(*StrVal));
03159
03160 return (RetVal);
03161 }
03162 return (TRUE);
03163 ENSURE(FALSE, "Calling SelectCustomComboGadgetValueOnString for an invalid control");
03164 #else
03165 return FALSE;
03166 #endif
03167 }
03168
03169
03170
03171
03172
03173
03174
03175
03176
03177
03178
03179
03180
03181
03182
03183
03184
03185
03186
03187
03188
03189
03190
03191
03192
03193
03194
03195
03196
03197
03198
03199
03200
03201
03202
03203
03204
03205
03206
03207
03208
03209
03210
03211 BOOL DialogManager::SetGadgetRange(CWindowID WindowID,
03212 CGadgetID Gadget,
03213 INT32 Min,
03214 INT32 Max,
03215 INT32 PgIncr)
03216 {
03217 wxWindow * pGadget = GetGadget(WindowID, Gadget);
03218 if (!pGadget) return FALSE;
03219
03220 INT32 LineIncr = (Max-Min+50)/100;
03221
03222
03223
03224 if (LineIncr<1)
03225 LineIncr=1;
03226
03227 if ( pGadget->IsKindOf(CLASSINFO(wxScrollBar)) )
03228 {
03229 wxScrollBar * pScroll = (wxScrollBar *)pGadget;
03230 ERROR3IF(Min !=0 , "Scrollbars with non-zero minimum need to be subclassed");
03231 pScroll->SetScrollbar(pScroll->GetThumbPosition(), pScroll->GetThumbSize(), Max-Min, PgIncr, TRUE);
03232 return TRUE;
03233 }
03234
03235 if ( pGadget->IsKindOf(CLASSINFO(wxSlider)) )
03236 {
03237 ((wxSlider *)(pGadget))->SetRange(Min, Max);
03238 ((wxSlider *)(pGadget))->SetLineSize(LineIncr);
03239 return TRUE;
03240 }
03241
03242 if ( pGadget->IsKindOf(CLASSINFO(wxSliderCombo)) )
03243 {
03244 ((wxSliderCombo *)(pGadget))->SetRange(Min, Max);
03245 ((wxSliderCombo *)(pGadget))->SetLineSize(LineIncr);
03246 return TRUE;
03247 }
03248
03249 if ( pGadget->IsKindOf(CLASSINFO(wxGauge)) )
03250 {
03251 ERROR3IF(Min !=0 , "Gauges with non-zero minimum need to be subclassed");
03252 ((wxGauge *)(pGadget))->SetRange(Max-Min);
03253 return TRUE;
03254 }
03255
03256 return FALSE;
03257 }
03258
03259
03260
03261
03262
03263
03264
03265
03266
03267
03268
03269
03270
03271
03272
03273
03274
03275
03276
03277
03278
03279
03280
03281
03282
03283
03284
03285
03286
03287
03288
03289
03290
03291
03292 BOOL DialogManager::SetListBoxSelection( CWindowID WindowID, CGadgetID Gadget, INT32 Index, BOOL SelectIt, BOOL SingleSelection )
03293 {
03294 wxWindow * pGadget = GetGadget(WindowID, Gadget);
03295 if (!pGadget) return FALSE;
03296
03297 if (pGadget->IsKindOf(CLASSINFO(wxListBox)))
03298 {
03299 if (SingleSelection)
03300 {
03301 ((wxListBox *)pGadget)->SetSelection(wxNOT_FOUND);
03302
03303
03304 wxArrayInt sels;
03305 INT32 i;
03306 for (i=0; i<((wxListBox *)pGadget)->GetSelections(sels); i++)
03307 ((wxListBox *)pGadget)->Deselect(sels[i]);
03308 }
03309
03310 if (Index>=0)
03311 {
03312 if (SelectIt)
03313 {
03314 ((wxListBox *)pGadget)->SetSelection(Index);
03315 }
03316 else
03317 {
03318 ((wxListBox *)pGadget)->Deselect(Index);
03319 }
03320 return TRUE;
03321 }
03322 else
03323 {
03324 INT32 i;
03325 for (i=0; i<(INT32)((wxListBox *)pGadget)->GetCount(); i++)
03326 {
03327 if (SelectIt)
03328 {
03329 ((wxListBox *)pGadget)->SetSelection(i);
03330 }
03331 else
03332 {
03333 ((wxListBox *)pGadget)->Deselect(i);
03334 }
03335 }
03336 }
03337 }
03338
03339 ERROR3("SetListBoxSelection called for non-listbox control");
03340 return(FALSE);
03341 }
03342
03343
03344
03345
03346
03347
03348
03349
03350
03351
03352
03353
03354
03355
03356
03357
03358
03359
03360
03361
03362
03363
03364
03365
03366
03367
03368
03369
03370
03371
03372
03373
03374
03375
03376 BOOL DialogManager::SetBoolGadgetSelected(CWindowID WindowID, CGadgetID Gadget,
03377 BOOL SelectIt, INT32 Index)
03378 {
03379
03380 wxWindow * pGadget = GetGadget(WindowID, Gadget);
03381 if (!pGadget) return FALSE;
03382
03383 if ( pGadget->IsKindOf(CLASSINFO(wxListBox)) ||
03384 pGadget->IsKindOf(CLASSINFO(wxComboBox)) ||
03385 pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)) ||
03386 pGadget->IsKindOf(CLASSINFO(wxChoice))
03387 )
03388 {
03389
03390 if (pGadget->IsKindOf(CLASSINFO(wxListBox)))
03391 {
03392 return SetListBoxSelection(WindowID, Gadget, Index, SelectIt, FALSE);
03393 }
03394
03395 if (Index>=0)
03396 {
03397 if (SelectIt)
03398 {
03399 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
03400 ((wxOwnerDrawnComboBox *)pGadget)->SetSelection(Index);
03401 else
03402 ((wxControlWithItems *)pGadget)->SetSelection(Index);
03403 }
03404 else
03405 {
03406
03407 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
03408 {
03409 if (((wxOwnerDrawnComboBox *)pGadget)->GetSelection() == Index)
03410 ((wxOwnerDrawnComboBox *)pGadget)->SetSelection(wxNOT_FOUND);
03411 }
03412 else
03413 {
03414 if (((wxControlWithItems *)pGadget)->GetSelection() == Index)
03415 ((wxControlWithItems *)pGadget)->SetSelection(wxNOT_FOUND);
03416 }
03417 }
03418 return TRUE;
03419 }
03420 else
03421 {
03422 if (SelectIt)
03423 {
03424
03425
03426
03427 INT32 i;
03428 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
03429 for (i=0; i<(INT32)((wxOwnerDrawnComboBox *)pGadget)->GetCount(); i++)
03430 ((wxOwnerDrawnComboBox *)pGadget)->SetSelection(i);
03431 else
03432 for (i=0; i<(INT32)((wxControlWithItems *)pGadget)->GetCount(); i++)
03433 ((wxControlWithItems *)pGadget)->SetSelection(i);
03434 }
03435 else
03436 {
03437 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
03438 ((wxOwnerDrawnComboBox *)pGadget)->SetSelection(wxNOT_FOUND);
03439 else
03440 ((wxControlWithItems *)pGadget)->SetSelection(wxNOT_FOUND);
03441 }
03442 }
03443 }
03444
03445
03446
03447 if ( pGadget->IsKindOf(CLASSINFO(wxScrollBar))
03448 || pGadget->IsKindOf(CLASSINFO(wxSlider))
03449 || pGadget->IsKindOf(CLASSINFO(wxSliderCombo))
03450 || pGadget->IsKindOf(CLASSINFO(wxGauge)) )
03451 return TRUE;
03452
03453
03454 return(SetLongGadgetValue(WindowID, Gadget, SelectIt));
03455 }
03456
03457
03458
03459
03460
03461
03462
03463
03464
03465
03466
03467
03468
03469
03470
03471
03472
03473
03474
03475
03476
03477
03478
03479
03480
03481
03482
03483
03484
03485
03486
03487
03488
03489
03490
03491
03492 BOOL DialogManager::SetSelectedValueIndex(CWindowID WindowID,
03493 CGadgetID Gadget,
03494 INT32 Index)
03495 {
03496 if (Index>=0)
03497 return SetBoolGadgetSelected(WindowID, Gadget, TRUE, Index);
03498 return SetBoolGadgetSelected(WindowID, Gadget, FALSE, -1);
03499 }
03500
03501
03502
03503
03504
03505
03506
03507
03508
03509
03510
03511
03512
03513
03514
03515
03516
03517
03518
03519
03520
03521
03522
03523
03524
03525
03526
03527
03528
03529
03530
03531
03532
03533
03534
03535 BOOL DialogManager::SetSelectedValueRange(CWindowID WindowID,
03536 CGadgetID Gadget,
03537 WORD StartIndex,
03538 WORD EndIndex,
03539 BOOL Selected)
03540 {
03541 INT32 i;
03542 for (i=StartIndex; i<=EndIndex; i++)
03543 SetBoolGadgetSelected(WindowID, Gadget, Selected, i);
03544 return (TRUE);
03545 }
03546
03547
03548
03549
03550
03551
03552
03553
03554
03555
03556
03557
03558
03559
03560
03561
03562
03563
03564
03565
03566
03567
03568
03569
03570
03571
03572
03573
03574
03575
03576
03577
03578
03579
03580
03581
03582
03583
03584
03585
03586
03587
03588
03589
03590
03591
03592
03593
03594
03595
03596
03597
03598
03599
03600
03601 BOOL DialogManager::SetDimensionGadgetValue( CWindowID WindowID,
03602 CGadgetID Gadget,
03603 MILLIPOINT Value,
03604 Node* pNode,
03605 BOOL IncludeUnitSpecifier,
03606 BOOL EndOfList,
03607 INT32 ListPos)
03608 {
03609 DimScale *pDimScale = DimScale::GetPtrDimScale(pNode);
03610 String_256 Str;
03611
03612 pDimScale->ConvertToUnits( Value, &Str, IncludeUnitSpecifier );
03613 SetStringGadgetValue( WindowID, Gadget, Str, EndOfList, ListPos );
03614
03615 return TRUE;
03616 }
03617
03618
03619
03620
03621
03622
03623
03624
03625
03626
03627
03628
03629
03630
03631
03632
03633
03634
03635
03636
03637
03638
03639
03640
03641
03642
03643
03644
03645
03646
03647
03648
03649
03650
03651
03652
03653
03654
03655
03656
03657
03658
03659
03660
03661
03662
03663
03664
03665
03666
03667
03668
03669
03670
03671
03672
03673
03674
03675
03676
03677
03678
03679 BOOL DialogManager::SetMemoryGadgetValue( CWindowID WindowID,
03680 CGadgetID Gadget,
03681 UINT32 Value,
03682 BOOL EndOfList,
03683 INT32 ListPos)
03684 {
03685 String_256 StrValue;
03686 Convert::BytesToString(&StrValue, Value);
03687 return (SetStringGadgetValue(WindowID, Gadget, StrValue, EndOfList, ListPos));
03688 }
03689
03690
03691
03692
03693
03694
03695
03696
03697
03698
03699
03700
03701
03702
03703
03704
03705
03706
03707
03708
03709
03710
03711
03712
03713
03714
03715
03716 BOOL DialogManager::SetGadgetHelp( CWindowID WindowID,
03717 CGadgetID Gadget,
03718 UINT32 BubbleID,
03719 UINT32 StatusID,
03720 UINT32 ModuleID)
03721 {
03722 PORTNOTE("dialog","DialogManager::SetGadgetHelp - do nothing")
03723 #ifndef EXCLUDE_FROM_XARALX
03724
03725 HWND hGadget = GetDlgItem((HWND)WindowID, (INT32)Gadget);
03726
03727
03728 ControlHelpInfo Info;
03729 Info.BubbleID = BubbleID;
03730 Info.StatusID = StatusID;
03731 Info.ModuleID = ModuleID;
03732
03733
03734
03735 do
03736 {
03737 if (!ControlHelper::NotifyControlChanged(hGadget, &Info))
03738 return FALSE;
03739
03740 hGadget = GetWindow(hGadget, GW_CHILD);
03741 }
03742 while (hGadget != NULL);
03743 #endif
03744 return TRUE;
03745 }
03746
03747
03748
03749
03750
03751
03752
03753
03754
03755
03756
03757
03758
03759
03760
03761
03762
03763
03764
03765
03766
03767
03768
03769
03770
03771
03772
03773
03774
03775
03776
03777
03778
03779
03780
03781
03782
03783
03784
03785
03786
03787
03788
03789
03790
03791
03792
03793
03794
03795
03796
03797
03798
03799
03800
03801
03802
03803
03804
03805
03806
03807
03808
03809
03810 MILLIPOINT DialogManager::GetUnitGadgetValue(CWindowID WindowID,
03811 CGadgetID Gadget,
03812 UnitType DefaultType,
03813 MILLIPOINT StartRange,
03814 MILLIPOINT EndRange,
03815 UINT32 IDSInvalidMsg,
03816 BOOL* Valid)
03817 {
03818 MILLIPOINT Value = 0;
03819
03820 BOOL IsValid;
03821
03822
03823 String_256 StrValue = GetStringGadgetValue(WindowID, Gadget, NULL);
03824
03825
03826 Value = Convert::StringToMillipoints(StrValue, DefaultType, &IsValid);
03827
03828 if (Valid == NULL)
03829 return(Value);
03830
03831 if (IsValid)
03832 {
03833
03834 if ((Value >= StartRange) && (Value <= EndRange))
03835 {
03836 *Valid = TRUE;
03837 return (Value);
03838 }
03839 }
03840
03841
03842 if (IDSInvalidMsg != 0)
03843 InformWarning(IDSInvalidMsg);
03844
03845 return( 0 );
03846 }
03847
03848
03849
03850
03851
03852
03853
03854
03855
03856
03857
03858
03859
03860
03861
03862
03863
03864
03865
03866
03867
03868
03869
03870
03871
03872
03873
03874
03875
03876
03877
03878
03879
03880
03881
03882
03883
03884
03885
03886
03887
03888
03889
03890
03891
03892
03893
03894
03895
03896
03897
03898
03899
03900
03901
03902
03903
03904
03905
03906
03907
03908
03909
03910
03911
03912
03913
03914
03915
03916
03917
03918
03919
03920
03921
03922
03923
03924
03925
03926
03927
03928 INT32 DialogManager::GetLongGadgetValue(CWindowID WindowID,
03929 CGadgetID Gadget,
03930 INT32 StartRange,
03931 INT32 EndRange,
03932 UINT32 IDSInvalidMsg,
03933 BOOL* Valid,
03934 Convert::PFNSTRINGTOINT32 pfnParser)
03935 {
03936 wxWindow * pGadget = GetGadget(WindowID, Gadget);
03937 if (!pGadget) return FALSE;
03938
03939 if ( pGadget->IsKindOf(CLASSINFO(wxButton)) ||
03940 pGadget->IsKindOf(CLASSINFO(wxBitmapButton)) )
03941 {
03942
03943 PORTNOTETRACE("dialog","DialogManager::GetLongGadgetValue on BitmapButton - do nothing");
03944 return 0;
03945 }
03946
03947 if ( pGadget->IsKindOf(CLASSINFO(wxCheckBox)) )
03948 {
03949 if (Valid) *Valid=TRUE;
03950 return ((wxCheckBox *)(pGadget))->GetValue() != 0;
03951 }
03952
03953 if ( pGadget->IsKindOf(CLASSINFO(wxRadioButton)) )
03954 {
03955 if (Valid) *Valid=TRUE;
03956 return ((wxRadioButton *)(pGadget))->GetValue() != 0;
03957 }
03958
03959 if ( pGadget->IsKindOf(CLASSINFO(wxScrollBar)) )
03960 {
03961 if (Valid) *Valid=TRUE;
03962 return (INT32)(((wxScrollBar *)(pGadget))->GetThumbPosition());
03963 }
03964
03965 if ( pGadget->IsKindOf(CLASSINFO(wxSlider)) )
03966 {
03967 if (Valid) *Valid=TRUE;
03968 return (INT32)(((wxSlider *)(pGadget))->GetValue());
03969 }
03970
03971 if ( pGadget->IsKindOf(CLASSINFO(wxSliderCombo)) )
03972 {
03973 if (Valid) *Valid=TRUE;
03974 return (INT32)(((wxSliderCombo *)(pGadget))->GetSliderValue());
03975 }
03976
03977 if ( pGadget->IsKindOf(CLASSINFO(wxGauge)) )
03978 {
03979 if (Valid) *Valid=TRUE;
03980 return (INT32)(((wxGauge *)(pGadget))->GetValue());
03981 }
03982
03983 if ( pGadget->IsKindOf(CLASSINFO(wxCamArtControl)) )
03984 {
03985 if (Valid) *Valid=TRUE;
03986 return (INT32)(((wxCamArtControl *)(pGadget))->GetValue());
03987 }
03988
03989 #if 0
03990
03991
03992 else if (ClassNameStr == String_16(TEXT("cc_CustomEdit")))
03993 {
03994 CCustomEdit* pCEdit = (CCustomEdit*)CWnd::FromHandlePermanent(hGadget);
03995 Value = pCEdit->GetPos();
03996 IsValid = ((Value >= StartRange) && (Value <= EndRange));
03997 TRACEUSER( "Marc", _T("dlgmgr.cpp, getting pos %d\n"),Value);
03998 }
03999 #endif
04000
04001
04002
04003
04004 String_256 StrValue = GetStringGadgetValue(WindowID, Gadget, NULL);
04005
04006
04007 INT32 Value=0;
04008 BOOL IsValid = (*pfnParser)(StrValue, &Value);
04009 if (IsValid)
04010 {
04011 IsValid = ((Value >= StartRange) && (Value <= EndRange));
04012 }
04013
04014 if (Valid != NULL)
04015 {
04016 *Valid = IsValid;
04017
04018 if (!IsValid)
04019 {
04020 if (IDSInvalidMsg != 0)
04021 InformWarning(IDSInvalidMsg);
04022 return (0);
04023 }
04024 }
04025
04026 return Value;
04027 }
04028
04029
04030
04031
04032
04033
04034
04035
04036
04037
04038
04039
04040
04041
04042
04043
04044
04045
04046
04047
04048
04049
04050
04051
04052
04053
04054
04055
04056
04057
04058
04059
04060
04061
04062
04063
04064
04065
04066
04067
04068
04069
04070
04071
04072
04073
04074
04075
04076
04077
04078
04079
04080
04081
04082
04083
04084
04085
04086
04087
04088
04089
04090
04091
04092
04093
04094
04095
04096
04097
04098
04099
04100
04101
04102
04103
04104
04105
04106
04107
04108
04109
04110
04111
04112
04113 double DialogManager::GetDoubleGadgetValue(CWindowID WindowID,
04114 CGadgetID Gadget,
04115 double StartRange,
04116 double EndRange,
04117 UINT32 IDSInvalidMsg,
04118 BOOL* Valid,
04119 Convert::PFNSTRINGTODOUBLE pfnParser)
04120 {
04121 wxWindow * pGadget = GetGadget(WindowID, Gadget);
04122 if (!pGadget) return FALSE;
04123
04124 if (( pGadget->IsKindOf(CLASSINFO(wxButton))) ||
04125 ( pGadget->IsKindOf(CLASSINFO(wxBitmapButton))) ||
04126 ( pGadget->IsKindOf(CLASSINFO(wxCheckBox))) ||
04127 ( pGadget->IsKindOf(CLASSINFO(wxRadioButton))) ||
04128 ( pGadget->IsKindOf(CLASSINFO(wxScrollBar))) ||
04129 ( pGadget->IsKindOf(CLASSINFO(wxSlider))) ||
04130 ( pGadget->IsKindOf(CLASSINFO(wxSliderCombo))) ||
04131 ( pGadget->IsKindOf(CLASSINFO(wxGauge)))
04132 )
04133 return (double)GetLongGadgetValue( WindowID, Gadget, (INT32)(floor(StartRange+0.5)), (INT32)(floor(EndRange+0.5)), IDSInvalidMsg, Valid);
04134
04135 String_256 StrValue = GetStringGadgetValue(WindowID, Gadget, NULL);
04136
04137
04138 double Value=0.0;
04139 BOOL IsValid = (*pfnParser)(StrValue, &Value);
04140 if (IsValid)
04141 {
04142 IsValid = ((Value >= StartRange) && (Value <= EndRange));
04143 }
04144
04145 if (Valid != NULL)
04146 {
04147 *Valid = IsValid;
04148
04149 if (!IsValid)
04150 {
04151 if (IDSInvalidMsg != 0)
04152 InformWarning(IDSInvalidMsg);
04153 return (0);
04154 }
04155 }
04156
04157 return Value;
04158 }
04159
04160
04161
04162
04163
04164
04165
04166
04167
04168
04169
04170
04171
04172
04173
04174
04175
04176
04177
04178
04179
04180
04181
04182
04183
04184
04185
04186
04187
04188
04189
04190
04191
04192
04193
04194
04195
04196
04197
04198
04199
04200
04201
04202
04203
04204
04205
04206
04207
04208
04209
04210
04211
04212
04213
04214
04215 BOOL DialogManager::GetBoolGadgetSelected(CWindowID WindowID,
04216 CGadgetID Gadget,
04217 UINT32 IDSInvalidMsg,
04218 BOOL* Valid,
04219 INT32 ListPos)
04220 {
04221 wxWindow * pGadget = GetGadget(WindowID, Gadget);
04222 if (!pGadget) return FALSE;
04223
04224 if ( pGadget->IsKindOf(CLASSINFO(wxListBox)) ||
04225 pGadget->IsKindOf(CLASSINFO(wxComboBox)) ||
04226 pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)) ||
04227 pGadget->IsKindOf(CLASSINFO(wxChoice)) )
04228 {
04229
04230 if (pGadget->IsKindOf(CLASSINFO(wxListBox)))
04231 {
04232 return ((wxListBox *)pGadget)->IsSelected(ListPos);
04233 }
04234 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
04235 return (((wxOwnerDrawnComboBox *)pGadget)->GetSelection() == ListPos);
04236 else
04237 return (((wxControlWithItems *)pGadget)->GetSelection() == ListPos);
04238 }
04239
04240 return GetLongGadgetValue(WindowID, Gadget, 0, 1, IDSInvalidMsg, Valid);
04241 }
04242
04243
04244
04245
04246
04247
04248
04249
04250
04251
04252
04253
04254
04255
04256
04257
04258
04259
04260
04261
04262
04263
04264
04265
04266
04267
04268
04269
04270
04271
04272
04273
04274
04275
04276
04277
04278
04279
04280
04281
04282
04283
04284
04285
04286
04287
04288
04289
04290
04291
04292
04293
04294 String_256 DialogManager::GetStringGadgetValue(CWindowID WindowID,
04295 CGadgetID Gadget,
04296 BOOL* Valid,
04297 INT32 ListPos)
04298 {
04299 if (Valid)
04300 *Valid = TRUE;
04301 String_256 StrVal;
04302
04303 wxWindow * pGadget = GetGadget(WindowID, Gadget);
04304 wxString String;
04305
04306 if (!pGadget) goto invalid;
04307
04308
04309 if ( pGadget->IsKindOf(CLASSINFO(wxListBox)) ||
04310 pGadget->IsKindOf(CLASSINFO(wxComboBox)) ||
04311 pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)) ||
04312 pGadget->IsKindOf(CLASSINFO(wxChoice)) )
04313 {
04314 if (ListPos >=0)
04315 {
04316 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
04317 {
04318 if (ListPos>=(INT32)((wxOwnerDrawnComboBox *)pGadget)->GetCount()) goto invalid;
04319 String = ((wxOwnerDrawnComboBox *)pGadget)->GetString(ListPos);
04320 }
04321 else
04322 {
04323 if (ListPos>=(INT32)((wxControlWithItems *)pGadget)->GetCount()) goto invalid;
04324 String = ((wxControlWithItems *)pGadget)->GetString(ListPos);
04325 }
04326 goto out;
04327 }
04328
04329 if (pGadget->IsKindOf(CLASSINFO(wxComboBox)))
04330 {
04331 String = ((wxComboBox *)pGadget)->GetValue();
04332 goto out;
04333 }
04334
04335 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
04336 {
04337 String = ((wxOwnerDrawnComboBox *)pGadget)->GetValue();
04338 goto out;
04339 }
04340
04341 INT32 sel;
04342 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
04343 sel = ((wxOwnerDrawnComboBox *)pGadget)->GetSelection();
04344 else
04345 sel = ((wxControlWithItems *)pGadget)->GetSelection();
04346
04347 if ( (sel == wxNOT_FOUND) || (sel < 0)) goto invalid;
04348
04349 if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
04350 String = ((wxOwnerDrawnComboBox *)pGadget)->GetString(sel);
04351 else
04352 String = ((wxControlWithItems *)pGadget)->GetString(sel);
04353
04354 goto out;
04355 }
04356
04357 if ( pGadget->IsKindOf(CLASSINFO(wxTextCtrl)) )
04358 {
04359 String = ((wxTextCtrl *)pGadget)->GetValue();
04360 goto out;
04361 }
04362
04363 if ( pGadget->IsKindOf(CLASSINFO(wxSliderCombo)) )
04364 {
04365 String = ((wxSliderCombo *)pGadget)->GetValue();
04366 goto out;
04367 }
04368
04369 String = pGadget->GetLabel();
04370
04371 out:
04372 StrVal = String.c_str();
04373 return StrVal;
04374
04375 invalid:
04376 if (Valid)
04377 *Valid=FALSE;
04378 return StrVal;
04379 }
04380
04381
04382
04383
04384
04385
04386
04387
04388
04389
04390
04391
04392
04393
04394
04395
04396
04397
04398
04399
04400
04401
04402
04403
04404
04405
04406
04407
04408
04409
04410
04411
04412 BOOL DialogManager::GetGadgetRange(CWindowID WindowID,
04413 CGadgetID Gadget,
04414 INT32* Min,
04415 INT32* Max)
04416 {
04417 INT32 min=0;
04418 INT32 max=0;
04419
04420 wxWindow * pGadget = GetGadget(WindowID, Gadget);
04421 if (!pGadget) return FALSE;
04422
04423 if ( pGadget->IsKindOf(CLASSINFO(wxScrollBar)) )
04424 {
04425 max = ((wxScrollBar *)pGadget)->GetRange();
04426 }
04427
04428 if ( pGadget->IsKindOf(CLASSINFO(wxSlider)) )
04429 {
04430 min=((wxSlider *)(pGadget))->GetMin();
04431 max=((wxSlider *)(pGadget))->GetMax();
04432 }
04433
04434 if ( pGadget->IsKindOf(CLASSINFO(wxSliderCombo)) )
04435 {
04436 min=((wxSliderCombo *)(pGadget))->GetSliderMin();
04437 max=((wxSliderCombo *)(pGadget))->GetSliderMax();
04438 }
04439
04440 if ( pGadget->IsKindOf(CLASSINFO(wxGauge)) )
04441 {
04442 max = ((wxGauge *)(pGadget))->GetRange();
04443 }
04444
04445 if (Min) *Min=min;
04446 if (Max) *Max=max;
04447
04448 return TRUE;
04449 }
04450
04451
04452
04453
04454
04455
04456
04457
04458
04459
04460
04461
04462
04463
04464
04465
04466
04467
04468
04469
04470
04471
04472
04473
04474
04475
04476
04477
04478
04479
04480
04481
04482
04483 MILLIPOINT DialogManager::GetDimensionGadgetValue( CWindowID WindowID,
04484 CGadgetID Gadget,
04485 Node* pNode,
04486 BOOL* Valid,
04487 INT32 ListPos)
04488 {
04489 MILLIPOINT Val=72000;
04490 DimScale* pDimScale = DimScale::GetPtrDimScale(pNode);
04491 String_256 Str;
04492
04493 Str = GetStringGadgetValue(WindowID,Gadget,Valid,ListPos);
04494 if (Valid != NULL && *Valid)
04495 *Valid = pDimScale->ConvertToMillipoints(Str,&Val);
04496 return Val;
04497 }
04498
04499
04500
04501
04502
04503
04504
04505
04506
04507
04508
04509
04510
04511
04512
04513
04514
04515
04516
04517
04518
04519
04520
04521 BOOL DialogManager::GetDoubleAndUnitGadgetValue(double* pMPValue,
04522 double* pUnitValue,
04523 UnitType* pUnitType,
04524 CWindowID WindowID,
04525 CGadgetID Gadget,
04526 Node* pNode)
04527 {
04528 ERROR2IF( pMPValue==NULL,FALSE,"DialogManager::GetDoubleAndUnitGadgetValue() - pMPValue==NULL");
04529 ERROR2IF(pUnitValue==NULL,FALSE,"DialogManager::GetDoubleAndUnitGadgetValue() - pUnitValue==NULL");
04530 ERROR2IF( pUnitType==NULL,FALSE,"DialogManager::GetDoubleAndUnitGadgetValue() - pUnitType==NULL");
04531 ERROR2IF( pNode==NULL,FALSE,"DialogManager::GetDoubleAndUnitGadgetValue() - pNode==NULL");
04532 DimScale* pDimScale = DimScale::GetPtrDimScale(pNode);
04533 ERROR2IF( pDimScale==NULL,FALSE,"DialogManager::GetDoubleAndUnitGadgetValue() - pDimScale==NULL");
04534
04535
04536 BOOL ok = TRUE;
04537 double UnitValue = 1.0;
04538 UnitType units;
04539 String_256 GadgetString=GetStringGadgetValue(WindowID,Gadget,&ok);
04540 if (ok) ok=Convert::StringToComponents(GadgetString, &UnitValue, &units);
04541 if (!ok) return FALSE;
04542
04543
04544 if (units==NOTYPE)
04545 units=pDimScale->GetUnits();
04546
04547
04548 double MPValue = 1.0;
04549 ok=pDimScale->ConvertToDouble(GadgetString,&MPValue);
04550 if (!ok) return FALSE;
04551
04552
04553 *pMPValue = MPValue;
04554 *pUnitValue = UnitValue;
04555 *pUnitType = units;
04556
04557 return TRUE;
04558 }
04559
04560
04561
04562
04563
04564
04565
04566
04567
04568
04569
04570
04571
04572
04573
04574
04575
04576
04577
04578
04579
04580
04581
04582
04583
04584
04585
04586
04587
04588
04589
04590
04591
04592
04593
04594
04595
04596
04597
04598
04599
04600
04601
04602
04603
04604
04605
04606
04607
04608
04609
04610
04611
04612
04613
04614
04615
04616
04617
04618
04619 UINT32 DialogManager::GetMemoryGadgetValue(CWindowID WindowID,
04620 CGadgetID Gadget,
04621 UINT32 StartRange,
04622 UINT32 EndRange,
04623 UINT32 IDSInvalidMsg,
04624 BOOL* Valid)
04625 {
04626 BOOL IsValid;
04627
04628
04629 String_256 StrValue = GetStringGadgetValue(WindowID, Gadget, NULL);
04630
04631
04632 UINT32 Value = Convert::StringToBytes(StrValue, &IsValid);
04633
04634 if (Valid == NULL)
04635 return(Value);
04636
04637 if (IsValid)
04638 {
04639
04640 if ((Value >= StartRange) && (Value <= EndRange))
04641 {
04642 *Valid = TRUE;
04643 return (Value);
04644 }
04645 }
04646
04647
04648 if (IDSInvalidMsg != 0)
04649 InformWarning(IDSInvalidMsg);
04650
04651 return( 0 );
04652 }
04653
04654
04655
04656
04657
04658
04659
04660
04661
04662
04663
04664
04665
04666
04667
04668
04669
04670
04671
04672
04673
04674
04675
04676
04677
04678
04679
04680
04681
04682
04683 BOOL DialogManager::DeleteAllValues(CWindowID WindowID, CGadgetID Gadget)
04684 {
04685 wxWindow * pGadget = GetGadget(WindowID, Gadget);
04686 if (!pGadget) return FALSE;
04687
04688
04689 if ( pGadget->IsKindOf(CLASSINFO(wxListBox)) ||
04690 pGadget->IsKindOf(CLASSINFO(wxComboBox)) ||
04691 pGadget->IsKindOf(CLASSINFO(wxChoice))
04692 )
04693 {
04694 ((wxControlWithItems *)pGadget)->Clear();
04695 return TRUE;
04696 }
04697 else if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
04698 {
04699 ((wxOwnerDrawnComboBox *)pGadget)->Clear();
04700 return TRUE;
04701 }
04702 else if ( pGadget->IsKindOf(CLASSINFO(wxTreeCtrl))
04703 )
04704 {
04705 ((wxTreeCtrl*)pGadget)->DeleteAllItems();
04706 return TRUE;
04707 }
04708
04709 ERROR3("Invalid control");
04710 return FALSE;
04711 }
04712
04713
04714
04715
04716
04717
04718
04719
04720
04721
04722
04723
04724
04725
04726
04727
04728
04729
04730
04731
04732
04733
04734
04735
04736
04737
04738
04739
04740
04741
04742
04743
04744
04745
04746
04747
04748
04749
04750
04751
04752
04753 BOOL DialogManager::DeleteValue(CWindowID WindowID,
04754 CGadgetID Gadget,
04755 BOOL EndOfList,
04756 INT32 ListPos)
04757 {
04758 wxWindow * pGadget = GetGadget(WindowID, Gadget);
04759 if (!pGadget) return FALSE;
04760
04761
04762 if ( pGadget->IsKindOf(CLASSINFO(wxListBox)) ||
04763 pGadget->IsKindOf(CLASSINFO(wxComboBox)) ||
04764 pGadget->IsKindOf(CLASSINFO(wxChoice))
04765 )
04766 {
04767 if (EndOfList)
04768 ((wxControlWithItems *)pGadget)->Delete(((wxControlWithItems *)pGadget)->GetCount()-1);
04769 else
04770 ((wxControlWithItems *)pGadget)->Delete(ListPos);
04771 return TRUE;
04772 }
04773 else if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
04774 {
04775 if (EndOfList)
04776 ((wxOwnerDrawnComboBox *)pGadget)->Delete(((wxOwnerDrawnComboBox *)pGadget)->GetCount()-1);
04777 else
04778 ((wxOwnerDrawnComboBox *)pGadget)->Delete(ListPos);
04779 return TRUE;
04780 }
04781
04782 ERROR3("Invalid control");
04783 return FALSE;
04784 }
04785
04786
04787
04788
04789
04790
04791
04792
04793
04794
04795
04796
04797
04798
04799
04800
04801
04802
04803
04804
04805
04806
04807
04808
04809
04810
04811
04812
04813
04814
04815
04816 BOOL DialogManager::GetValueCount(CWindowID WindowID,
04817 CGadgetID Gadget,
04818 INT32* Count)
04819 {
04820 wxWindow * pGadget = GetGadget(WindowID, Gadget);
04821 if (!pGadget) return FALSE;
04822
04823
04824 if ( pGadget->IsKindOf(CLASSINFO(wxListBox)) ||
04825 pGadget->IsKindOf(CLASSINFO(wxComboBox)) ||
04826 pGadget->IsKindOf(CLASSINFO(wxChoice))
04827 )
04828 {
04829 INT32 c = ((wxControlWithItems *)pGadget)->GetCount();
04830 if (Count) *Count=c;
04831 return TRUE;
04832 }
04833 else if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
04834 {
04835 INT32 c = ((wxOwnerDrawnComboBox *)pGadget)->GetCount();
04836 if (Count) *Count=c;
04837 return TRUE;
04838 }
04839
04840 ERROR3("Invalid control");
04841 return FALSE;
04842 }
04843
04844
04845
04846
04847
04848
04849
04850
04851
04852
04853
04854
04855
04856
04857
04858 INT32 DialogManager::GetSelectedCount(CWindowID WindowID,CGadgetID Gadget)
04859 {
04860
04861 wxWindow * pGadget = GetGadget(WindowID, Gadget);
04862 if (!pGadget) return FALSE;
04863
04864 if ( pGadget->IsKindOf(CLASSINFO(wxListBox)) ||
04865 pGadget->IsKindOf(CLASSINFO(wxComboBox)) ||
04866 pGadget->IsKindOf(CLASSINFO(wxChoice))
04867 )
04868 {
04869
04870 if (pGadget->IsKindOf(CLASSINFO(wxListBox)))
04871 {
04872 wxArrayInt sels;
04873 return ((wxListBox *)pGadget)->GetSelections(sels);
04874 }
04875
04876 return (((wxControlWithItems *)pGadget)->GetSelection() == wxNOT_FOUND)?0:1;
04877 }
04878 else if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
04879 return (((wxOwnerDrawnComboBox *)pGadget)->GetSelection() == wxNOT_FOUND)?0:1;
04880
04881 return -1;
04882 }
04883
04884
04885
04886
04887
04888
04889
04890
04891
04892
04893
04894
04895
04896
04897
04898 INT32 DialogManager::GetFirstSelectedItem( CWindowID WindowID, CGadgetID Gadget )
04899 {
04900 wxWindow * pGadget = GetGadget(WindowID, Gadget);
04901 if (!pGadget) return -1;
04902
04903 if ( pGadget->IsKindOf(CLASSINFO(wxListBox)) ||
04904 pGadget->IsKindOf(CLASSINFO(wxComboBox)) ||
04905 pGadget->IsKindOf(CLASSINFO(wxChoice)) )
04906 {
04907
04908 if (pGadget->IsKindOf(CLASSINFO(wxListBox)))
04909 {
04910 wxArrayInt sels;
04911 if ( ((wxListBox *)pGadget)->GetSelections(sels) )
04912 {
04913 return sels[0];
04914 }
04915 return -1;
04916 }
04917 return ((wxControlWithItems *)pGadget)->GetSelection();
04918 }
04919 else if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
04920 return ((wxOwnerDrawnComboBox *)pGadget)->GetSelection();
04921
04922 return -1;
04923 }
04924
04925
04926
04927
04928
04929
04930
04931
04932
04933
04934
04935
04936
04937
04938
04939
04940
04941
04942
04943
04944
04945
04946
04947
04948
04949
04950
04951 INT32* DialogManager::GetSelectedItems(CWindowID WindowID, CGadgetID Gadget)
04952 {
04953 INT32* pList = NULL;
04954
04955 wxArrayInt sels;
04956
04957 wxWindow * pGadget = GetGadget(WindowID, Gadget);
04958 if (!pGadget) return NULL;
04959
04960 if ( pGadget->IsKindOf(CLASSINFO(wxListBox)) ||
04961 pGadget->IsKindOf(CLASSINFO(wxComboBox)) ||
04962 pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)) ||
04963 pGadget->IsKindOf(CLASSINFO(wxChoice)) )
04964 {
04965
04966 if (pGadget->IsKindOf(CLASSINFO(wxListBox)))
04967 {
04968 ((wxListBox *)pGadget)->GetSelections(sels);
04969 }
04970 else if (pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
04971 {
04972 sels[0]=((wxOwnerDrawnComboBox *)pGadget)->GetSelection();
04973 }
04974 else
04975 {
04976 sels[0]=((wxControlWithItems *)pGadget)->GetSelection();
04977 }
04978
04979 size_t Count = sels.GetCount();
04980
04981 pList = new INT32[Count+1];
04982
04983 if (pList)
04984 {
04985 UINT32 i;
04986 for (i=0; i<Count; i++)
04987 {
04988 pList[i]=sels[i];
04989 }
04990 pList[Count] = -1;
04991 }
04992
04993 return pList;
04994
04995 }
04996 return NULL;
04997 }
04998
04999
05000
05001
05002
05003
05004
05005
05006
05007
05008
05009
05010
05011
05012
05013
05014
05015
05016
05017
05018
05019
05020
05021
05022
05023
05024
05025
05026
05027
05028
05029
05030
05031
05032
05033
05034
05035
05036
05037 BOOL DialogManager::GetValueIndex(CWindowID WindowID,
05038 CGadgetID Gadget,
05039 INT32* Index)
05040 {
05041 INT32 index = GetFirstSelectedItem(WindowID, Gadget);
05042 if (Index) *Index=index;
05043 TRACEUSER("amb", _T("Index is %d"),index);
05044 return TRUE;
05045 }
05046
05047
05048
05049
05050
05051
05052
05053
05054
05055
05056
05057
05058
05059
05060
05061
05062
05063
05064
05065
05066
05067
05068
05069
05070
05071
05072
05073
05074
05075
05076
05077
05078
05079 BOOL DialogManager::GetValueIndex(CWindowID WindowID,
05080 CGadgetID Gadget,
05081 WORD* Index)
05082 {
05083 if (Index) *Index=GetFirstSelectedItem(WindowID, Gadget);
05084 return TRUE;
05085 }
05086
05087
05088
05089
05090
05091
05092
05093
05094
05095
05096
05097
05098
05099
05100
05101
05102
05103 BOOL DialogManager::AddDialogControlToHelper(CWindowID WindowID, CGadgetID Gadget)
05104 {
05105
05106 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05107 if (!pGadget) return FALSE;
05108 pGadget->Show(TRUE);
05109 return TRUE;
05110 }
05111
05112
05113
05114
05115
05116
05117
05118
05119
05120
05121
05122
05123
05124
05125
05126
05127 BOOL DialogManager::RemoveDialogControlFromHelper(CWindowID WindowID, CGadgetID Gadget)
05128 {
05129
05130 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05131 if (!pGadget) return FALSE;
05132 pGadget->Show(FALSE);
05133 return TRUE;
05134 }
05135
05136
05137
05138
05139
05140
05141
05142
05143
05144
05145
05146
05147
05148
05149
05150
05151
05152
05153
05154
05155
05156
05157
05158
05159
05160 BOOL DialogManager::EnableGadget(CWindowID WindowID, CGadgetID Gadget, BOOL Enabled)
05161 {
05162 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05163 if (!pGadget) return FALSE;
05164 pGadget->Enable( FALSE != Enabled );
05165 return (TRUE);
05166 }
05167
05168
05169
05170
05171
05172
05173
05174
05175
05176
05177
05178
05179
05180
05181 BOOL DialogManager::SetGadgetWritable(CWindowID WindowID, CGadgetID Gadget, BOOL enable)
05182 {
05183
05184 wxWindow* pGadget = GetGadget( WindowID, Gadget );
05185 if( !pGadget )
05186 return FALSE;
05187
05188 if( pGadget->IsKindOf( CLASSINFO(wxTextCtrl) ) )
05189 ( (wxTextCtrl*)pGadget )->SetEditable( FALSE != enable );
05190 else
05191 {
05192 PORTNOTETRACE("other", "Removed SetGadgetWritable handling of on TextCtrl");
05193 #ifndef EXCLUDE_FROM_XARALX
05194
05195 HWND hEdit = ::ChildWindowFromPoint(gadget, CPoint(1,1));
05196
05197 if (hEdit)
05198 gadget = hEdit;
05199
05200 if (enable)
05201 ::SendMessage(gadget, EM_SETREADONLY, FALSE, 0);
05202 else
05203 ::SendMessage(gadget, EM_SETREADONLY, TRUE, 0);
05204 #else
05205 return FALSE;
05206 #endif
05207 }
05208
05209 return TRUE;
05210 }
05211
05212
05213
05214
05215
05216
05217
05218
05219
05220
05221
05222
05223
05224
05225
05226
05227
05228
05229 BOOL DialogManager::IsGadgetEnabled( CWindowID WindowID, CGadgetID Gadget )
05230 {
05231 wxWindow* pGadget = GetGadget(WindowID, Gadget);
05232 if (!pGadget)
05233 return FALSE;
05234
05235 return pGadget->IsEnabled();
05236 }
05237
05238
05239
05240
05241
05242
05243
05244
05245
05246
05247
05248
05249
05250
05251
05252
05253
05254
05255
05256
05257
05258
05259
05260
05261
05262
05263 BOOL DialogManager::HideGadget(CWindowID WindowID, CGadgetID Gadget, BOOL Hide)
05264 {
05265
05266 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05267 if (!pGadget) return FALSE;
05268 pGadget->Show(!Hide);
05269 return TRUE;
05270 }
05271
05272
05273
05274
05275
05276
05277
05278
05279
05280
05281
05282
05283
05284
05285
05286
05287 void DialogManager::Layout(CWindowID WindowID, BOOL CanYield )
05288 {
05289 ((wxWindow *)WindowID)->Layout();
05290 if (CanYield)
05291 {
05292
05293 wxWindowDisabler(WindowID);
05294 wxYieldIfNeeded();
05295 }
05296 }
05297
05298
05299
05300
05301
05302
05303
05304
05305
05306
05307
05308
05309
05310
05311
05312
05313
05314
05315
05316
05317
05318
05319
05320
05321
05322
05323
05324 BOOL DialogManager::GadgetRedraw(CWindowID WindowID, CGadgetID Gadget, BOOL Redraw)
05325 {
05326 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05327 if (!pGadget) return FALSE;
05328
05329 if( Redraw )
05330 {
05331 pGadget->Thaw();
05332 }
05333 else
05334 {
05335 pGadget->Freeze();
05336 }
05337
05338 return TRUE;
05339 }
05340
05341
05342
05343
05344
05345
05346
05347
05348
05349
05350
05351
05352
05353
05354
05355
05356
05357 BOOL DialogManager::SetKeyboardFocus(CWindowID WindowID, CGadgetID Gadget)
05358 {
05359
05360
05361 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05362 if (!pGadget) return FALSE;
05363
05364 pGadget->SetFocus();
05365 return TRUE;
05366 }
05367
05368
05369
05370
05371
05372
05373
05374
05375
05376
05377
05378
05379
05380
05381
05382
05383
05384 BOOL DialogManager::CaptureMouse(CWindowID WindowID, CGadgetID Gadget)
05385 {
05386
05387
05388 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05389 if (!pGadget) return FALSE;
05390
05391 pGadget->CaptureMouse();
05392 return TRUE;
05393 }
05394
05395
05396
05397
05398
05399
05400
05401
05402
05403
05404
05405
05406
05407
05408
05409
05410
05411 BOOL DialogManager::ReleaseMouse(CWindowID WindowID, CGadgetID Gadget)
05412 {
05413
05414
05415 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05416 if (!pGadget) return FALSE;
05417
05418
05419 if( wxWindow::GetCapture() == pGadget )
05420 {
05421 pGadget->ReleaseMouse();
05422 return TRUE;
05423 }
05424 else
05425 return FALSE;
05426 }
05427
05428
05429
05430
05431
05432
05433
05434
05435
05436
05437
05438
05439
05440
05441
05442
05443
05444 BOOL DialogManager::DefaultKeyboardFocus()
05445 {
05446
05447 GetMainFrame()->SetFocus();
05448 return TRUE;
05449 }
05450
05451
05452
05453
05454
05455
05456
05457
05458
05459
05460
05461
05462
05463
05464
05465
05466
05467
05468
05469
05470
05471
05472 BOOL DialogManager::HighlightText(CWindowID WindowID, CGadgetID Gadget, INT32 nStart, INT32 nEnd)
05473 {
05474
05475
05476
05477 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05478 if (!pGadget) return FALSE;
05479
05480 #ifdef _DEBUG
05481 ERROR3IF( !pGadget->IsKindOf( CLASSINFO(wxListBox) ) &&
05482 !pGadget->IsKindOf( CLASSINFO(wxComboBox) ) &&
05483 !pGadget->IsKindOf( CLASSINFO(wxOwnerDrawnComboBox) ) &&
05484 !pGadget->IsKindOf( CLASSINFO(wxTextCtrl) ),
05485 "Wrong kind of control in DialogManager::HighlightText");
05486 #endif
05487
05488 if( pGadget->IsKindOf( CLASSINFO(wxTextCtrl) ) )
05489 {
05490 ( (wxTextCtrl *)pGadget )->SetSelection( -1, -1 );
05491 }
05492 else if( pGadget->IsKindOf( CLASSINFO(wxComboBox) ) )
05493 {
05494 ( (wxComboBox *)pGadget )->SetSelection( -1, -1 );
05495 }
05496 else if( pGadget->IsKindOf( CLASSINFO(wxOwnerDrawnComboBox) ) )
05497 {
05498 ( (wxOwnerDrawnComboBox *)pGadget )->SetSelection( -1 );
05499 }
05500
05501 return TRUE;
05502 }
05503
05504
05505
05506
05507
05508
05509
05510
05511
05512
05513
05514
05515
05516
05517
05518
05519
05520
05521 void DialogManager::PaintGadgetNow(CWindowID WindowID, CGadgetID Gadget)
05522 {
05523 if (!Gadget)
05524 {
05525 ((wxWindow *)WindowID)->Update();
05526 wxPlatformDependent::Get()->FixUpdate((wxWindow *)WindowID);
05527 return;
05528 }
05529
05530 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05531 if (!pGadget) return;
05532
05533 pGadget->Update();
05534 wxPlatformDependent::Get()->FixUpdate(pGadget);
05535 }
05536
05537
05538
05539
05540
05541
05542
05543
05544
05545
05546
05547
05548
05549
05550
05551 void DialogManager::InvalidateGadget(CWindowID WindowID, CGadgetID Gadget, BOOL EraseBackground )
05552 {
05553 if (!Gadget)
05554 {
05555 ((wxWindow *)WindowID)->Refresh(EraseBackground);
05556 return;
05557 }
05558
05559 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05560 if (!pGadget) return;
05561
05562 pGadget->Refresh(EraseBackground);
05563 }
05564
05565
05566
05567
05568
05569
05570
05571
05572
05573
05574
05575
05576
05577
05578
05579
05580
05581
05582
05583
05584
05585
05586
05587
05588
05589
05590
05591
05592
05593
05594 void DialogManager::InvalidateGadget(CWindowID WindowID, CGadgetID Gadget,
05595 ReDrawInfoType *ExtraInfo,
05596 DocRect *InvalidRect)
05597 {
05598 if (InvalidRect == NULL)
05599 {
05600 InvalidateGadget(WindowID, Gadget);
05601 return;
05602 }
05603
05604 if (ExtraInfo == NULL || WindowID == 0)
05605 {
05606 ERROR2RAW("DialogManager::InvalidateGadget was passed illegal NULL parameter(s)");
05607 return;
05608 }
05609
05610 ERROR3IF(ExtraInfo->Dpi == 0, "Screen DPI is zero? I think not! Divide-by-zeros imminent!");
05611 if (!ExtraInfo->Dpi) return;
05612
05613 INT32 PixelSize = 72000 / ExtraInfo->Dpi;
05614
05615 DocRect irect=*InvalidRect;
05616 if (irect.lo.y > irect.hi.y)
05617 {
05618
05619 TRACEALL( _T("Rectangle upside down in InvalidateGadget\n") );
05620
05621 INT32 temp=irect.lo.y;
05622 irect.lo.y=irect.hi.y;
05623 irect.lo.y=temp;
05624 }
05625
05626 wxRect ToRedraw(irect.lo.x / PixelSize, (ExtraInfo->dy-irect.hi.y) / PixelSize,
05627 (irect.hi.x-irect.lo.x) / PixelSize, (irect.hi.y-irect.lo.y)/PixelSize);
05628
05629 wxWindow * pGadget = GetGadget(WindowID, Gadget);
05630
05631 ERROR3IF((!pGadget), "DialogManager::InvalidateGadget - Gadget not valid");
05632
05633 if (pGadget)
05634 {
05635
05636 wxRect GadgetRect(pGadget->GetClientSize());
05637 ToRedraw=ToRedraw.Intersect(GadgetRect);
05638 pGadget->Refresh(TRUE, &ToRedraw);
05639 }
05640 }
05641
05642
05643
05644
05645
05646
05647
05648
05649
05650
05651
05652
05653
05654
05655
05656
05657
05658
05659
05660
05661
05662
05663
05664
05665
05666
05667
05668
05669
05670
05671
05672
05673
05674
05675
05676
05677
05678
05679
05680
05681
05682
05683
05684
05685
05686
05687
05688
05689
05690 void DialogManager::ScrollKernelRenderedGadget(CWindowID WindowID, CGadgetID Gadget,
05691 DocRect *RectToScroll, DocCoord *ScrollBy)
05692 {
05693 ERROR3IF(ScrollBy == NULL || WindowID == 0 || Gadget == 0,
05694 "DialogManager::ScrollKernelRenderedGadget - NULL Params are illegal");
05695
05696
05697 wxWindow * pWinToScroll = GetGadget(WindowID, Gadget);
05698 if (!pWinToScroll) return;
05699
05700 ERROR3IF( pWinToScroll == 0,
05701 "DialogManager::ScrollKernelRenderedGadget - Illegal window/gadget");
05702
05703 if( pWinToScroll == 0 )
05704 return;
05705
05706 ReDrawInfoType ExtraInfo;
05707 GetKernelRenderedGadgetInfo(WindowID, Gadget, &ExtraInfo);
05708
05709 INT32 PixelSize = 72000 / ExtraInfo.Dpi;
05710
05711 INT32 ScrollDX = ScrollBy->x / PixelSize;
05712 INT32 ScrollDY = ScrollBy->y / PixelSize;
05713
05714
05715 ScrollBy->x = ScrollDX * PixelSize;
05716 ScrollBy->y = ScrollDY * PixelSize;
05717
05718 if (abs(ScrollBy->x) >= RectToScroll->Width() ||
05719 abs(ScrollBy->y) >= RectToScroll->Height())
05720 {
05721
05722
05723
05724
05725
05726 InvalidateGadget(WindowID, Gadget, &ExtraInfo, RectToScroll);
05727 }
05728 else
05729 {
05730 if (RectToScroll != NULL)
05731 {
05732
05733 wxRect BaseRect;
05734 BaseRect.x = RectToScroll->lo.x / PixelSize;
05735 BaseRect.width = ( RectToScroll->hi.x - RectToScroll->lo.x ) / PixelSize;
05736 BaseRect.y = ( ExtraInfo.dy - RectToScroll->hi.y ) / PixelSize;
05737
05738 BaseRect.height = ( RectToScroll->hi.y - RectToScroll->lo.y ) / PixelSize;
05739
05740
05741 pWinToScroll->ScrollWindow( -ScrollDX, -ScrollDY, &BaseRect );
05742 }
05743 else
05744 {
05745
05746 pWinToScroll->ScrollWindow( -ScrollDX, -ScrollDY, NULL );
05747 }
05748 }
05749 }
05750
05751
05752
05753
05754
05755
05756
05757
05758
05759
05760
05761
05762
05763
05764
05765
05766
05767
05768
05769
05770
05771
05772
05773
05774
05775
05776
05777
05778
05779
05780
05781
05782 BOOL DialogManager::GetKernelRenderedGadgetInfo(CWindowID WindowID, CGadgetID Gadget,
05783 ReDrawInfoType *Result)
05784 {
05785 ERROR3IF(WindowID == 0 || Gadget == 0 || Result == NULL,
05786 "DialogManager::GetKernelRenderedGadgetInfo: NULL parameters are illegal!");
05787
05788
05789 wxWindow * pTheWindow = GetGadget(WindowID, Gadget);
05790 if (!pTheWindow) return FALSE;
05791
05792 Result->pDC = NULL;
05793 Result->pClipRect = NULL;
05794 Result->pMousePos = NULL;
05795
05796
05797 Result->dx = Result->dy = 72000;
05798 Result->Dpi = 96;
05799
05800
05801 ERROR3IF( NULL == pTheWindow,
05802 "DialogManager::GetKernelRenderedGadgetInfo - Illegal window/gadget");
05803 if( pTheWindow == 0 )
05804 return(FALSE);
05805
05806
05807 wxScreenDC ScreenDC;
05808 PORTNOTE("dialog","Can't handle different DPIs, using X")
05809 Result->Dpi = OSRenderRegion::GetFixedDCPPI(ScreenDC).x;
05810
05811
05812 wxSize WindowSize( pTheWindow->GetClientSize() );
05813
05814 Result->dx = ( INT32(WindowSize.GetWidth())*72000 ) / Result->Dpi;
05815 Result->dy = ( INT32(WindowSize.GetHeight())*72000) / Result->Dpi;
05816 return(TRUE);
05817 }
05818
05819
05820
05821
05822
05823
05824
05825
05826
05827
05828
05829
05830
05831
05832
05833
05834
05835
05836
05837
05838
05839
05840
05841
05842
05843 void DialogManager::SetGadgetIDToFocus( wxWindow *pDialogWnd )
05844 {
05845 PORTNOTETRACE("dialog","DialogManager::SetGadgetIDToFocus - do nothing");
05846 #ifndef EXCLUDE_FROM_XARALX
05847
05848 wxWindow *pFocusWindow = wxWindow::FindFocus();
05849
05850
05851
05852 wxWindow *pCurrentChild;
05853 wxWindowList &listChild = pDialogWnd->GetChildren();
05854 wxWindowList::iterator iter = listChild.begin();
05855 wxWindowList::iterator end = listChild.end();
05856 for(;
05857 iter != end;
05858 ++iter )
05859 {
05860 if( CurrentChild == FocusWindow )
05861 {
05862
05863 Gadget = GetDlgCtrlID( FocusWindow );
05864 break;
05865 }
05866 }
05867 #endif
05868 }
05869
05870
05871
05872
05873
05874
05875
05876
05877
05878
05879
05880
05881
05882
05883
05884 BOOL DialogManager::CustomControlMsg( wxWindow *pDlg, UINT32 wParam, INT32 lParam )
05885 {
05886 PORTNOTETRACE("dialog","DialogManager::CustomControlMsg - do nothing");
05887 #ifndef EXCLUDE_FROM_XARALX
05888 String_256 ClassNameStr;
05889 GetClassName( HWND(lParam), (TCHAR*)ClassNameStr, 255);
05890 if ((ClassNameStr == String_16(TEXT("cc_BitmapButton")))||
05891 ClassNameStr == String_16(TEXT("cc_SmallButton")))
05892 {
05893 Gadget = HIWORD(wParam);
05894 switch (LOWORD(wParam))
05895 {
05896 case BN_CLICKED:
05897 DialogManager::DIM = DIM_LFT_BN_CLICKED;
05898 DialogManager::HandleMessage = TRUE;
05899 return TRUE;
05900
05901 case BN_BUTTONUP:
05902 DialogManager::DIM = DIM_LFT_BN_UP;
05903 DialogManager::HandleMessage = TRUE;
05904 return TRUE;
05905
05906 case WM_MOUSEMOVE:
05907 DialogManager::DIM = DIM_MOUSE_MOVE;
05908 DialogManager::HandleMessage = TRUE;
05909 return TRUE;
05910
05911
05912 default:
05913 TRACEUSER( "JustinF", _T("Unknown message ID in DialogManager::CustomControlMsg\n"));
05914 break;
05915 }
05916 }
05917 #endif
05918 return FALSE;
05919 }
05920
05921
05922
05923
05924
05925
05926
05927
05928
05929
05930
05931
05932
05933
05934
05935
05936
05937
05938
05939 void DialogManager::EnableAllDialogs( BOOL Enable, wxWindow *pExceptMe )
05940 {
05941
05942 List *pDlgList = MessageHandler::GetClassList( CC_RUNTIME_CLASS(DialogOp) );
05943
05944 ERROR3IF( pDlgList == NULL, "Could not find the DialogOp Class List" );
05945 if( NULL != pDlgList )
05946 {
05947 ListItem *CurrentOp = pDlgList->GetHead();
05948 DialogOp *pDlgOp;
05949 while( CurrentOp != NULL )
05950 {
05951 if (CurrentOp->IS_KIND_OF(DialogOp))
05952 {
05953 pDlgOp = (DialogOp*)CurrentOp;
05954
05955 if (pDlgOp->HasWindow())
05956 {
05957 if (pDlgOp->WindowID != pExceptMe)
05958 {
05959 ( (wxWindow *)pDlgOp->WindowID )->Enable( FALSE != Enable );
05960 }
05961 }
05962 }
05963 CurrentOp = pDlgList->GetNext(CurrentOp);
05964 }
05965 }
05966
05967
05968
05969
05970 wxWindow *pActiveWindow = wxWindow::FindFocus();
05971 if( NULL != pActiveWindow )
05972 {
05973 if( pActiveWindow != pExceptMe )
05974 {
05975 pActiveWindow->Enable( FALSE != Enable );
05976 }
05977 }
05978 }
05979
05980
05981
05982
05983
05984
05985
05986
05987
05988
05989
05990
05991
05992
05993
05994
05995
05996
05997
05998
05999
06000
06001
06002
06003
06004
06005
06006
06007
06008
06009
06010
06011
06012
06013 void DialogManager::SetEditGadgetType(CWindowID Win,
06014 CGadgetID Gadget,
06015 EditGadgetType Type)
06016 {
06017 UINT32 IDSValidChars=0;
06018 switch (Type)
06019 {
06020
06021
06022 case UNIT_NUMERIC: IDSValidChars = _R(IDS_UNIT_NUMERIC_CHARS); break;
06023 case INT_NUMERIC: IDSValidChars = _R(IDS_INT_NUMERIC_CHARS); break;
06024 case REAL_NUMERIC: IDSValidChars = _R(IDS_REAL_NUMERIC_CHARS); break;
06025 };
06026 SetEditGadgetType(Win, Gadget, IDSValidChars);
06027 }
06028
06029
06030 class wxTextValidatorFixed : public wxTextValidator
06031 {
06032 DECLARE_DYNAMIC_CLASS(wxTextValidatorFixed);
06033 public:
06034 wxTextValidatorFixed( long style = wxFILTER_NONE, wxString *val = 0) : wxTextValidator(style, val) {}
06035 wxTextValidatorFixed(const wxTextValidator& val) : wxTextValidator(val) {}
06036 ~wxTextValidatorFixed(){}
06037 virtual wxObject *Clone() const { return new wxTextValidatorFixed(*this); }
06038 virtual bool TransferToWindow(void)
06039 {
06040 if ( m_stringValue )
06041 {
06042 if( !CheckValidator() ) return false;
06043 wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow;
06044 control->SetValue(* m_stringValue);
06045 }
06046 return true;
06047 }
06048 virtual bool TransferFromWindow(void)
06049 {
06050 if ( m_stringValue )
06051 {
06052 if( !CheckValidator() ) return false;
06053 wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow;
06054 *m_stringValue = control->GetValue();
06055 }
06056 return true;
06057 }
06058 };
06059 IMPLEMENT_DYNAMIC_CLASS(wxTextValidatorFixed, wxTextValidator);
06060
06061
06062
06063
06064
06065
06066
06067
06068
06069
06070
06071
06072
06073
06074
06075
06076
06077
06078
06079
06080
06081
06082
06083
06084 void DialogManager::SetEditGadgetType(CWindowID WindowID,
06085 CGadgetID Gadget,
06086 UINT32 IDSValidChar)
06087 {
06088 wxWindow * pGadget = GetGadget(WindowID, Gadget);
06089 if (!pGadget) return;
06090
06091 String_256 s;
06092 if (!s.Load(IDSValidChar))
06093 {
06094 ERROR3("Could not load validator string");
06095 return;
06096 }
06097 wxArrayString valstring;
06098 TCHAR * p = (TCHAR *)s;
06099 TCHAR c;
06100 while ((c=*p++)!=0)
06101 {
06102 valstring.Add(wxString(c));
06103 }
06104 wxTextValidatorFixed validator(wxFILTER_INCLUDE_CHAR_LIST);
06105 validator.SetIncludes(valstring);
06106 pGadget->SetValidator(validator);
06107 }
06108
06109
06110
06111
06112
06113
06114
06115
06116
06117
06118
06119
06120
06121
06122
06123
06124
06125
06126 void DialogManager::DualFunctionButton(CWindowID DialogWnd,
06127 CGadgetID ButtonGadget)
06128 {
06129 PORTNOTETRACE("dialog","DialogManager::DualFunctionButton - do nothing");
06130 #ifndef EXCLUDE_FROM_XARALX
06131
06132 HWND hGadget = GetDlgItem((HWND)DialogWnd, (INT32)ButtonGadget);
06133 #if _DEBUG
06134 String_256 ClassNameStr;
06135 GetClassName(hGadget, (TCHAR*)ClassNameStr, 255);
06136
06137 ENSURE((ClassNameStr == String_8(TEXT("Button"))), "DualFunctionButton function called\n"
06138 "on a gadget which is not a button");
06139 #endif
06140
06141 ControlInfo* ControlInfoPtr;
06142
06143
06144 ControlInfoPtr = new ControlInfo;
06145 ControlInfoPtr->pControlWnd = hGadget;
06146 ControlInfoPtr->lpfnOldProc = (FARPROC) GetWindowLong(hGadget, GWL_WNDPROC);
06147
06148
06149 GetControlList( DialogWnd )->AddHead(ControlInfoPtr);
06150
06151 FARPROC lpfnDualFn = MakeProcInstance((FARPROC) DialogManager::RgtMouseButtonProc,
06152 AfxGetApp()->m_hInstance);
06153
06154
06155 SetWindowLong(hGadget, GWL_WNDPROC, (INT32) lpfnDualFn );
06156 #endif
06157 }
06158
06159
06160
06161
06162
06163
06164
06165
06166
06167
06168
06169
06170
06171
06172
06173
06174
06175
06176
06177
06178 BOOL DialogManager::MakeListBoxDragable(CWindowID WindowID,
06179 CGadgetID Gadget)
06180 {
06181
06182
06183 wxWindow * pGadget = GetGadget(WindowID, Gadget);
06184 if (!pGadget) return FALSE;
06185 #if _DEBUG
06186 ENSURE( pGadget->IsKindOf( CLASSINFO( wxListBox ) ),
06187 "MakeListBoxDragable function called\non a gadget which is not a Listbox" );
06188 #endif
06189
06190 return TRUE;
06191 }
06192
06193
06194
06195
06196
06197
06198
06199
06200
06201
06202
06203
06204
06205
06206
06207
06208
06209
06210
06211
06212
06213
06214
06215
06216 INT32 FAR PASCAL EXPORT DialogManager::ValidateEditGadgetProc( wxWindow *pWnd,
06217 UINT32 message,
06218 UINT32 wParam,
06219 INT32 lParam)
06220 {
06221 PORTNOTETRACE("dialog","DialogManager::DualFunctionButton - do nothing");
06222 #ifndef EXCLUDE_FROM_XARALX
06223
06224
06225
06226 HWND DlgWin = GetParent(hwnd);
06227
06228
06229
06230 List* ControlInfoList = GetControlList(DlgWin);
06231 ControlInfo* CurrentCntrl = (ControlInfo*)ControlInfoList->GetHead();
06232
06233 while (CurrentCntrl != NULL)
06234 {
06235 if (CurrentCntrl->ControlWnd == hwnd)
06236 break;
06237 CurrentCntrl = (ControlInfo*)ControlInfoList->GetNext(CurrentCntrl);
06238 }
06239
06240 ENSURE(CurrentCntrl != NULL, "Could not find information for a typed edit control");
06241
06242
06243 String_256 ValidChars;
06244 ValidChars.Load(CurrentCntrl->IDSValidCh, NULL);
06245
06246 if (message == WM_CHAR)
06247 {
06248
06249 BOOL CharValid = FALSE;
06250
06251 INT32 LenValidChars = ValidChars.Length();
06252 TCHAR KeyCh = ((TCHAR)wParam);
06253 for (INT32 i=0; ( (i < LenValidChars) && (!CharValid) ); i++)
06254 if (((TCHAR*)ValidChars)[i] == (TCHAR)KeyCh)
06255 {
06256 CharValid = TRUE;
06257 }
06258 if (!CharValid)
06259 {
06260
06261 if ((KeyCh != (TCHAR)'\b') &&
06262 (KeyCh != (TCHAR)'\t') &&
06263 (KeyCh != (TCHAR)'\n') &&
06264 (KeyCh != (TCHAR)'\r'))
06265
06266 return (0);
06267 }
06268 }
06269 else if (message==WM_DESTROY)
06270 DeleteControlList( hwnd );
06271
06272 return CallWindowProc((WNDPROC)(CurrentCntrl->lpfnOldProc), hwnd, message, wParam, lParam);
06273 #else
06274 return 0;
06275 #endif
06276 }
06277
06278
06279
06280
06281
06282
06283
06284
06285
06286
06287
06288
06289
06290
06291
06292
06293
06294
06295
06296
06297
06298 INT32 FAR PASCAL EXPORT DialogManager::RgtMouseButtonProc( wxWindow *pWnd,
06299 UINT32 message,
06300 UINT32 wParam,
06301 INT32 lParam)
06302 {
06303 PORTNOTETRACE("dialog","DialogManager::DualFunctionButton - do nothing");
06304 #ifndef EXCLUDE_FROM_XARALX
06305
06306 HWND DlgWin = GetParent(hwnd);
06307
06308
06309
06310 List* ControlInfoList = GetControlList(DlgWin);
06311 ControlInfo* CurrentCntrl = (ControlInfo*)ControlInfoList->GetHead();
06312
06313 while (CurrentCntrl != NULL)
06314 {
06315 if (CurrentCntrl->ControlWnd == hwnd)
06316 break;
06317 CurrentCntrl = (ControlInfo*)ControlInfoList->GetNext(CurrentCntrl);
06318 }
06319
06320 ENSURE(CurrentCntrl != NULL, "Could not find information for a dual function button");
06321 if ((message == WM_RBUTTONDOWN) || (message == WM_RBUTTONUP))
06322 {
06323
06324
06325 wParam = (message == WM_RBUTTONDOWN) ? 1:0;
06326 message = BM_SETSTATE;
06327 lParam = 0L;
06328 CallWindowProc((WNDPROC)(CurrentCntrl->lpfnOldProc), hwnd, message, wParam, lParam);
06329
06330
06331 if (wParam == 1)
06332 #if WIN32
06333 SendMessage(DlgWin, WM_COMMAND, MAKEINT32(GetWindowLong(hwnd, GWL_ID),BN_RGT_CLICKED), LPARAM(hwnd));
06334 #else
06335 SendMessage(DlgWin, WM_COMMAND, GetWindowWord(hwnd, GWW_ID), MAKEINT32(hwnd,BN_RGT_CLICKED));
06336 #endif
06337 }
06338 else if (message==WM_DESTROY)
06339 DeleteControlList( hwnd );
06340 return CallWindowProc((WNDPROC)(CurrentCntrl->lpfnOldProc), hwnd, message, wParam, lParam);
06341 #else
06342 return 0;
06343 #endif
06344 }
06345
06346
06347
06348
06349
06350
06351
06352
06353
06354
06355
06356
06357
06358
06359
06360
06361 void DialogManager::DeInit()
06362 {
06363
06364
06365
06366
06367
06368
06369
06370
06371
06372 static BOOL fCalledOnceBodge = FALSE;
06373 if (!fCalledOnceBodge) fCalledOnceBodge = TRUE;
06374 else
06375 {
06376 ERROR3( wxT("DialogManager::DeInit called twice - please fix me properly sometime\n") );
06377 return;
06378 }
06379
06380
06381 PORTNOTE("dialog","Removed IsFullScreenMode usage")
06382 #ifndef EXCLUDE_FROM_XARALX
06383 if( GetMainFrame()->IsFullScreenMode() )
06384 DialogBarOp::WriteNamedBars("clean");
06385 else
06386 DialogBarOp::WriteNamedBars("normal");
06387 #endif
06388
06389
06390 BROADCAST_TO_CLASS(DialogMsg(NULL, DIM_CANCEL, 0), DialogOp);
06391
06392
06393
06394
06395 InformationBarOp::SetVisibility(FALSE, TRUE);
06396
06397
06398 ListItem* DlgPos = DialogPositionList.GetHead();
06399 ListItem* NextPos;
06400 while (DlgPos != NULL)
06401 {
06402
06403 ENSURE( ((DialogPosition*)DlgPos)->DlgWinList.IsEmpty(),
06404 "Live Dialog box found whilst destoying dialog manager");
06405
06406 NextPos = DialogPositionList.GetNext(DlgPos);
06407 delete DialogPositionList.RemoveItem(DlgPos);
06408 DlgPos = NextPos;
06409 }
06410
06411 }
06412
06413
06414
06415
06416
06417
06418
06419
06420
06421
06422
06423
06424
06425
06426
06427
06428 DialogManager::~DialogManager()
06429 {
06430 }
06431
06432
06433
06434
06435
06436
06437
06438
06439
06440
06441
06442
06443
06444
06445
06446
06447
06448
06449 List *DialogManager::GetControlList( CWindowID hWnd )
06450 {
06451 PORTNOTETRACE("dialog","DialogManager::GetControlList - do nothing");
06452 #ifndef EXCLUDE_FROM_XARALX
06453 HANDLE Prop = GetProp( hWnd, MAKEINTATOM(GetListAtom) );
06454 if (Prop)
06455 {
06456 #if WIN32
06457 return (List*)(INT32)Prop;
06458 #else
06459 HANDLE Seg = GetProp( hWnd, MAKEINTATOM(GetListAtomSegment) );
06460 INT32 ptr = MAKEINT32( Prop, Seg );
06461 return (List*)ptr;
06462 #endif
06463 }
06464 else
06465 #endif
06466 return NULL;
06467 }
06468
06469
06470
06471
06472
06473
06474
06475
06476
06477
06478
06479
06480
06481
06482
06483
06484 void DialogManager::DeleteControlList( CWindowID hWnd )
06485 {
06486 PORTNOTETRACE("dialog","DialogManager::DeleteControlList - do nothing");
06487 #ifndef EXCLUDE_FROM_XARALX
06488 RemoveProp( hWnd, MAKEINTATOM(GetListAtom) );
06489 #ifndef WIN32
06490 RemoveProp( hWnd, MAKEINTATOM(GetListAtomSegment) );
06491 #endif
06492 #endif
06493 }
06494
06495
06496
06497
06498 #if WIN32
06499 #define DWORD_ALIGN(x) if( DWORD_PTR(x) % 4 ) x = ADDR(( DWORD_PTR(x) + 3 ) & ~3);
06500 #else
06501 #define DWORD_ALIGN(x)
06502 #endif
06503
06504
06505
06506
06507
06508
06509
06510
06511
06512
06513
06514
06515
06516
06517
06518 LPWSTR DialogManager::MovePastWideStr(LPWSTR pWideStr)
06519 {
06520
06521 while (*pWideStr++)
06522 ;
06523
06524
06525 return pWideStr;
06526 }
06527
06528
06529
06530
06531
06532
06533
06534
06535
06536
06537
06538
06539
06540
06541 size_t DialogManager::SizeDlgHeader(DLGTEMPLATE *pHeader)
06542 {
06543
06544 ADDR pResult = (ADDR) (pHeader + 1);
06545
06546
06547
06548 #if WIN32
06549
06550 pResult = (ADDR) MovePastWideStr((LPWSTR) pResult);
06551
06552 #else
06553
06554 switch (*pResult++)
06555 {
06556
06557 case 0:
06558 break;
06559
06560 case 0xFF:
06561 pResult += 2;
06562 break;
06563
06564 default:
06565 pResult += camStrlen((LPTCHAR) (pResult)) + 1;
06566 break;
06567 }
06568
06569 #endif
06570
06571
06572
06573 pResult = (ADDR) MovePastWideStr((LPWSTR) pResult);
06574
06575
06576
06577 pResult = (ADDR) MovePastWideStr((LPWSTR) pResult);
06578
06579 PORTNOTE("dialog","Removed DLGTEMPLATE usage")
06580 #ifndef EXCLUDE_FROM_XARALX
06581
06582 if( (pHeader->style) & DS_SETFONT )
06583 pResult = (ADDR) MovePastWideStr((LPWSTR) (pResult + 2));
06584 #endif
06585
06586 DWORD_ALIGN(pResult);
06587
06588
06589 return (size_t) (pResult - ((ADDR) pHeader));
06590 }
06591
06592
06593
06594
06595
06596
06597
06598
06599
06600
06601
06602
06603
06604
06605
06606 size_t DialogManager::SizeCtrlData(DLGITEMTEMPLATE *pControl)
06607 {
06608 #if WIN32
06609
06610 WORD *pData = (WORD *) (pControl + 1);
06611
06612
06613 if (*pData == 0xFFFF)
06614
06615 pData += 2;
06616 else
06617
06618 pData = (WORD *) MovePastWideStr((LPWSTR) pData);
06619
06620
06621 if (*pData == 0xFFFF)
06622
06623 pData += 2;
06624 else
06625
06626 pData = (WORD *) MovePastWideStr((LPWSTR) pData);
06627
06628
06629 UINT32 Extra = (UINT32) *pData;
06630 pData++;
06631
06632 #else
06633
06634 ADDR pData = (ADDR) (pControl + 1);
06635
06636
06637 if ((*pData) & 0x80)
06638 pData++;
06639 else
06640 pData = (ADDR) MovePastWideStr((LPWSTR) pData);
06641
06642
06643 pData = (ADDR) MovePastWideStr((LPWSTR) pData);
06644
06645
06646 BYTE Extra = *pData;
06647 pData++;
06648
06649 #endif
06650
06651
06652 ADDR pEnd = (ADDR) pData;
06653 DWORD_ALIGN(pEnd);
06654
06655
06656 ADDR pStart = (ADDR) pControl;
06657 pEnd += Extra;
06658 return (size_t) (pEnd - pStart);
06659 }
06660
06661
06662
06663
06664
06665
06666
06667
06668
06669
06670
06671
06672
06673
06674
06675
06676
06677
06678
06679
06680
06681
06682
06683
06684
06685
06686 DLGTEMPLATE *DialogManager::MergeDialog( CDlgResID MainID,
06687 CDlgResID OtherID)
06688 {
06689 PORTNOTETRACE("dialog","DialogManager::MergeDialog - do nothing");
06690 #ifndef EXCLUDE_FROM_XARALX
06691 HGLOBAL hGlobal[2];
06692 HRSRC hRes[2];
06693 DLGTEMPLATE *pDlg[2];
06694 INT32 HeaderSize[2];
06695 ADDR pNew,
06696 pOld;
06697 INT32 Size;
06698 DLGTEMPLATE *pHeader;
06699
06700 #if WIN32
06701 WORD Count, Total;
06702 #else
06703 BYTE Count, Total;
06704 #endif
06705
06706 size_t Len[2],
06707 ItemSize;
06708 UINT32 xOffset = 0;
06709
06710
06711 hRes[0] = FindResource(MainInst, MAKEINTRESOURCE(MainID), RT_DIALOG);
06712 hGlobal[0] = LoadResource(MainInst, hRes[0]);
06713 pDlg[0] = (DLGTEMPLATE *) LockResource(hGlobal[0]);
06714
06715 hRes[1] = FindResource(OtherInst, MAKEINTRESOURCE(OtherID), RT_DIALOG);
06716 hGlobal[1] = LoadResource(OtherInst, hRes[1]);
06717 pDlg[1] = (DLGTEMPLATE *) LockResource(hGlobal[1]);
06718
06719
06720
06721
06722 Total = 0;
06723
06724 for (UINT32 i = 0; i <= 1; i++)
06725 {
06726 Count = pDlg[i]->cdit;
06727 Total += Count;
06728 HeaderSize[i] = SizeDlgHeader(pDlg[i]);
06729 pOld = ((ADDR) pDlg[i]) + HeaderSize[i];
06730 Len[i] = 0;
06731
06732 while (Count--)
06733 {
06734 DLGITEMTEMPLATE *pControl = (DLGITEMTEMPLATE *) pOld;
06735
06736
06737 ItemSize = SizeCtrlData(pControl);
06738
06739
06740 if (i == 0)
06741 {
06742 UINT32 xLimit = pControl->x + pControl->cx;
06743 xOffset= max(xOffset, xLimit);
06744 }
06745
06746
06747 Len[i] += ItemSize;
06748 pOld += ItemSize;
06749 }
06750 }
06751
06752
06753
06754 Size = SizeDlgHeader(pDlg[0]);
06755 pNew = (ADDR) CCMalloc(Size + Len[0] + Len[1]);
06756
06757
06758 memcpy( pNew, pDlg[0], (size_t) Size );
06759
06760 pHeader = (DLGTEMPLATE *) pNew;
06761 pNew += Size;
06762
06763
06764 memcpy(pNew, ((ADDR) pDlg[0]) + HeaderSize[0], Len[0]);
06765 pNew += Len[0];
06766
06767
06768 memcpy(pNew, ((ADDR) pDlg[1]) + HeaderSize[1], Len[1]);
06769
06770
06771 pHeader->cdit = Total;
06772
06773
06774
06775 Count = pDlg[1]->cdit;
06776
06777 while (Count--)
06778 {
06779 DLGITEMTEMPLATE *pControl = (DLGITEMTEMPLATE *) pNew;
06780
06781
06782 pControl->x += xOffset;
06783
06784
06785 pNew += SizeCtrlData(pControl);
06786 }
06787
06788
06789
06790
06791 UnlockResource(hGlobal[0]);
06792 FreeResource(hGlobal[0]);
06793
06794 UnlockResource(hGlobal[1]);
06795 FreeResource(hGlobal[1]);
06796
06797 return pHeader;
06798 #else
06799 return NULL;
06800 #endif
06801 }
06802
06803
06804
06805
06806
06807
06808
06809
06810
06811
06812
06813
06814
06815
06816
06817
06818
06819
06820 BOOL DialogManager::IsADialogWindow( wxWindow *pWnd )
06821 {
06822 return( DialogOp::IsADialogWindow( pWnd ) );
06823 }
06824
06825
06826
06827
06828
06829
06830
06831
06832
06833
06834
06835
06836
06837
06838
06839
06840
06841 BOOL DialogManager::ModalDialogOpen(DialogOp** pModal)
06842 {
06843
06844 List* DialogClassList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogOp));
06845 ENSURE(DialogClassList != NULL, "Could not find DialogOp message handler list");
06846
06847
06848 for (MessageHandler* pMsgHandler = (MessageHandler*)DialogClassList->GetHead();
06849 pMsgHandler != NULL;
06850 pMsgHandler = (MessageHandler*)DialogClassList->GetNext(pMsgHandler))
06851 {
06852 ENSURE(pMsgHandler->IsKindOf(CC_RUNTIME_CLASS(DialogOp)),
06853 "MessageHandler of DialogOp class list is not a DialogOp");
06854 if (pMsgHandler->IsKindOf(CC_RUNTIME_CLASS(DialogOp)))
06855 {
06856
06857 DialogOp* pDlgOp = (DialogOp*)pMsgHandler;
06858
06859 if (pDlgOp->WindowID != NULL)
06860 {
06861
06862 if (pDlgOp->IsModal() )
06863 {
06864 if (pModal != NULL)
06865 {
06866 *pModal = pDlgOp;
06867 }
06868 return TRUE;
06869 }
06870 }
06871 }
06872 }
06873 return FALSE;
06874 }
06875
06876
06877
06878
06879
06880
06881
06882
06883
06884
06885
06886
06887
06888
06889
06890
06891
06892 BOOL DialogManager::IsWindowVisible(CWindowID Win)
06893 {
06894 return ( (wxWindow *)Win )->IsShown();
06895 }
06896
06897
06898
06899
06900
06901
06902
06903
06904
06905
06906
06907
06908
06909
06910
06911
06912
06913 BOOL DialogManager::IsCustomComboDropdownVisible(CWindowID WindowID, CGadgetID Gadget)
06914 {
06915 PORTNOTETRACE("dialog","DialogManager::IsCustomComboDropdownVisible - do nothing");
06916 #ifndef EXCLUDE_FROM_XARALX
06917 String_256 ClassNameStr;
06918
06919 HWND hGadget = GetDlgItem((HWND)WindowID, (INT32)Gadget);
06920
06921 GetClassName(hGadget, (TCHAR*)ClassNameStr, 255);
06922
06923 if ((ClassNameStr == String_64(TEXT("cc_1dBitmapComboBoxEdit"))) ||
06924 (ClassNameStr == String_64(TEXT("cc_2dBitmapComboBoxEdit"))) )
06925 {
06926 BOOL RetVal = FALSE;
06927
06928 RetVal = SendMessage (hGadget, WM_CCQUERYDROPDOWN, (WPARAM) (0), (LPARAM) 0);
06929
06930 return (RetVal);
06931 }
06932 return (TRUE);
06933 ENSURE(FALSE, "Calling IsCustomComboDropdownVisible for an invalid control");
06934 #endif
06935 return FALSE;
06936 }
06937
06938
06939
06940
06941
06942
06943
06944
06945
06946
06947
06948
06949
06950
06951
06952
06953
06954
06955
06956 BOOL DialogManager::CloseDropdown (CWindowID WindowID, CGadgetID Gadget, BOOL CloseVal)
06957 {
06958 PORTNOTE("dialog","Programatic CB drop not supported by wx")
06959 return (TRUE);
06960 }
06961
06962
06963
06964
06965
06966
06967
06968
06969
06970
06971
06972
06973
06974
06975
06976
06977 wxPropertySheetDialog* DialogManager::GetPropertySheetFromOp( DialogTabOp* pDialogTabOp )
06978 {
06979 wxWindow * pWindow = pDialogTabOp->WindowID;
06980 return pWindow->IsKindOf(CLASSINFO(wxPropertySheetDialog))?(wxPropertySheetDialog*)pWindow:NULL;
06981 }
06982
06983
06984
06985
06986
06987
06988
06989
06990
06991
06992
06993
06994
06995
06996
06997
06998
06999
07000
07001
07002
07003 BOOL DialogManager::AddAPage(DialogTabOp* pDialogTabOp, CDlgResID DialogResID, CGadgetID Gadget)
07004 {
07005
07006
07007 wxBookCtrlBase* pNoteBook = GetBookControl(pDialogTabOp->WindowID, Gadget);
07008
07009
07010
07011 wxWindow* pNewPage;
07012 wxString ObjectName;
07013 try
07014 {
07015 const TCHAR* pDialogName=CamResource::GetObjectNameFail( DialogResID );
07016 ERROR1IF(pDialogName == NULL, FALSE, _R(IDE_CANNOT_CREATE_DIALOG));
07017 TRACEUSER( "jlh92", _T("Cre tab %s\n"), pDialogName );
07018 ObjectName = pDialogName;
07019
07020 pNewPage = wxXmlResource::Get()->LoadPanel( pNoteBook, pDialogName );
07021 ERROR1IF(pNewPage == NULL, FALSE, _R(IDE_CANNOT_CREATE_DIALOG));
07022 pNewPage->SetId( DialogResID );
07023
07024 CamArtProvider::Get()->EnsureChildBitmapsLoaded( pNewPage );
07025 }
07026 catch( CMemoryException )
07027 {
07028 ERROR1(FALSE, _R(IDS_OUT_OF_MEMORY));
07029 }
07030
07031
07032 ERROR1IF(pNewPage == NULL, FALSE, _R(IDS_OUT_OF_MEMORY));
07033
07034 wxString Title = wxEmptyString;
07035 if (pNewPage->IsKindOf(CLASSINFO(wxDialog)))
07036 Title=((wxDialog *)pNewPage)->GetTitle();
07037 if (Title.IsEmpty())
07038 Title = pNewPage->GetLabel();
07039 if( Title.IsEmpty() )
07040 {
07041 ResourceID NameResID = CamResource::GetResourceID( PCTSTR(ObjectName) );
07042 PCTSTR pszStringLookup = CamResource::GetTextFail( NameResID );
07043 if( NULL != pszStringLookup )
07044 {
07045 Title = pszStringLookup;
07046 TRACEUSER( "jlh92", _T("Page (FST) = \"%s\"\n"), pszStringLookup );
07047 }
07048 }
07049 if( Title.IsEmpty() )
07050 {
07051
07052
07053 wxToolTip* pTip = pNewPage->GetToolTip();
07054 if (pTip) Title=pTip->GetTip();
07055 }
07056
07057 wxImageList * pImageList = NULL;
07058 wxBitmap b;
07059
07060 if (pDialogTabOp->HasImages())
07061 {
07062
07063 pImageList = pNoteBook->GetImageList();
07064
07065 wxBitmap * pBitmap = CamArtProvider::Get()->FindBitmap(DialogResID);
07066 if (!pBitmap || (pBitmap==CamArtProvider::Get()->GetMissingBitmap()) || !pBitmap->Ok())
07067 {
07068 TRACEUSER("Phil", _T("Unable to use options tab icon %d\n"), DialogResID);
07069 int w=32;
07070 int h=32;
07071 if (pImageList)
07072 pImageList->GetSize(0, w, h);
07073 b = wxArtProvider::GetBitmap(wxART_HELP_SETTINGS, wxART_OTHER, wxSize(w, h));
07074 }
07075 else
07076 b= *pBitmap;
07077
07078
07079 if (!pImageList)
07080 {
07081 pImageList = new wxImageList(b.GetWidth(), b.GetHeight());
07082 if (pImageList)
07083 pNoteBook->AssignImageList(pImageList);
07084 }
07085
07086 }
07087
07088 if (pImageList)
07089 pImageList->Add(b);
07090 pNoteBook->AddPage( pNewPage, Title );
07091 if (pImageList)
07092 pNoteBook->SetPageImage(pNoteBook->GetPageCount()-1, pImageList->GetImageCount()-1);
07093
07094 return true;
07095 }
07096
07097
07098
07099
07100
07101
07102
07103
07104
07105
07106
07107
07108
07109
07110
07111
07112
07113
07114
07115
07116
07117 CWindowID DialogManager::GetPageWindow(CWindowID Win, CDlgResID PageID, INT32* PageIndex)
07118 {
07119 if (PageID == 0)
07120 {
07121 return Win;
07122 }
07123
07124 wxBookCtrlBase* pBookCtrl = GetBookControl(Win);
07125 if (!pBookCtrl)
07126 {
07127 ERROR3("No BookControl found");
07128 return Win;
07129 }
07130
07131 wxNotebookPage* pCurrentPage;
07132
07133
07134 for (UINT32 i = 0; i < pBookCtrl->GetPageCount(); i++)
07135 {
07136 pCurrentPage = (wxNotebookPage*)(pBookCtrl->GetPage(i));
07137 if (pCurrentPage->GetId() == INT32(PageID) )
07138 {
07139 if (PageIndex != NULL)
07140 {
07141 *PageIndex = i;
07142 }
07143
07144 return pCurrentPage;
07145 }
07146 }
07147 ERROR3("The page specified does not exist on this tabbed dialog");
07148 return Win;
07149 }
07150
07151
07152
07153
07154
07155
07156
07157
07158
07159
07160
07161
07162
07163
07164
07165
07166
07167 BOOL DialogManager::SetTitlebarName( CWindowID Win, String_256* Name )
07168 {
07169
07170 wxWindow * pTLW = (wxWindow *)(Win);
07171 while (pTLW && !pTLW->IsKindOf(CLASSINFO(wxTopLevelWindow)))
07172 pTLW = pTLW->GetParent();
07173
07174 if (pTLW)
07175 pTLW->SetLabel( (TCHAR *)(*Name) );
07176
07177 return true;
07178 }
07179
07180
07181
07182
07183
07184
07185
07186
07187
07188
07189
07190
07191
07192
07193
07194
07195
07196
07197
07198
07199
07200
07201
07202
07203
07204
07205
07206
07207
07208 UINT32 DialogManager::SetTimer( DialogOp *pDialogOp, CWindowID WindowID, UINT32 nIDEvent, UINT32 nElapse,
07209 void (* lpfnTimer)(void *), void * param, BOOL OneShot )
07210 {
07211 if (!pDialogOp || !pDialogOp->pEvtHandler)
07212 return 0;
07213
07214 return pDialogOp->pEvtHandler->AddTimer(pDialogOp, nIDEvent, nElapse, lpfnTimer, param, OneShot);
07215 }
07216
07217
07218
07219
07220
07221
07222
07223
07224
07225
07226
07227
07228
07229
07230
07231
07232
07233
07234
07235 BOOL DialogManager::KillTimer( DialogOp *pDialogOp, CWindowID Wnd, INT32 nIDEvent )
07236 {
07237 if (!pDialogOp || !pDialogOp->pEvtHandler)
07238 return 0;
07239
07240 return pDialogOp->pEvtHandler->DeleteTimer(nIDEvent);
07241 }
07242
07243
07244
07245
07246
07247
07248
07249
07250
07251
07252
07253
07254
07255
07256
07257 BOOL DialogManager::GetWindowPosition( CWindowID WindowID, wxRect *pRect )
07258 {
07259 *pRect = wxRect(WindowID->GetPosition(), WindowID->GetSize());
07260 return TRUE;
07261 }
07262
07263 BOOL DialogManager::GetWindowPosition( CWindowID WindowID, RECT *pRect )
07264 {
07265 wxRect Rect;
07266 if (!GetWindowPosition(WindowID, &Rect)) return FALSE;
07267 pRect->bottom=Rect.GetBottom();
07268 pRect->top=Rect.GetTop();
07269 pRect->left=Rect.GetLeft();
07270 pRect->right=Rect.GetRight();
07271 return TRUE;
07272 }
07273
07274
07275
07276
07277
07278
07279
07280
07281
07282
07283
07284
07285
07286
07287
07288
07289 BOOL DialogManager::GetGadgetPosition( CWindowID WindowID, CGadgetID Gadget, wxRect *pRect )
07290 {
07291 wxWindow * pGadget = GetGadget(WindowID, Gadget);
07292 if (!pGadget) return FALSE;
07293
07294
07295 if (pRect)
07296 *pRect = pGadget->GetSize();
07297
07298 return TRUE;
07299 }
07300
07301 BOOL DialogManager::GetGadgetPosition( CWindowID WindowID, CGadgetID Gadget, RECT *pRect )
07302 {
07303 wxRect Rect;
07304 if (!GetGadgetPosition(WindowID, Gadget, &Rect)) return FALSE;
07305 pRect->bottom=Rect.GetBottom();
07306 pRect->top=Rect.GetTop();
07307 pRect->left=Rect.GetLeft();
07308 pRect->right=Rect.GetRight();
07309 return TRUE;
07310 }
07311
07312
07313
07314
07315
07316
07317
07318
07319
07320
07321
07322
07323
07324
07325
07326
07327
07328
07329
07330
07331 BOOL DialogManager::SetWindowPosition(CWindowID WindowID, const wxRect &Rect)
07332 {
07333 WindowID->SetPosition(Rect.GetTopLeft());
07334 WindowID->SetSize(Rect.GetSize());
07335 return TRUE;
07336 }
07337
07338 BOOL DialogManager::SetWindowPosition( CWindowID WindowID, const RECT &Rect )
07339 {
07340 return SetWindowPosition( WindowID, wxRect(wxPoint(Rect.left, Rect.top), wxPoint(Rect.right, Rect.bottom)));
07341 }
07342
07343
07344
07345
07346
07347
07348
07349
07350
07351
07352
07353
07354
07355
07356
07357
07358 BOOL DialogManager::SetGadgetPosition( CWindowID WindowID, CGadgetID Gadget, const wxRect &Rect )
07359 {
07360 wxWindow * pGadget = GetGadget(WindowID, Gadget);
07361 if (!pGadget) return FALSE;
07362
07363 pGadget->SetSize( Rect );
07364 return TRUE;
07365 }
07366
07367 BOOL DialogManager::SetGadgetPosition( CWindowID WindowID, CGadgetID Gadget, const RECT &Rect )
07368 {
07369 return SetGadgetPosition( WindowID, Gadget, wxRect(wxPoint(Rect.left, Rect.top), wxPoint(Rect.right, Rect.bottom)));
07370 }
07371
07372
07373
07374
07375
07376
07377
07378
07379
07380
07381
07382
07383
07384 INT32 DialogManager::GetScreenDpi()
07385 {
07386
07387 wxScreenDC ScreenDC;
07388 PORTNOTE("dialog","Can't handle different DPIs, using X")
07389 return OSRenderRegion::GetFixedDCPPI(ScreenDC).x;
07390 }
07391
07392
07393
07394
07395
07396
07397
07398
07399
07400
07401
07402
07403
07404
07405
07406 BOOL DialogManager::GetScreenSize(INT32 * pWidth, INT32 * pHeight)
07407 {
07408 ERROR2IF(pWidth == NULL || pHeight == NULL,FALSE,"GetScreenSize Bad params!");
07409
07410
07411
07412 INT32 Width = wxSystemSettings::GetMetric( wxSYS_SCREEN_X );
07413 INT32 Height = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
07414
07415
07416 *pWidth = Width;
07417 *pHeight = Height;
07418
07419 return TRUE;
07420 }
07421
07422
07423
07424
07425
07426
07427
07428
07429
07430
07431
07432
07433
07434
07435
07436
07437
07438
07439
07440
07441
07442
07443 BOOL DialogManager::RecordActiveDialogState()
07444 {
07445
07446
07447 BOOL IsModal = !(ActiveDlgStack.GetTop() == NULL);
07448
07449 wxWindow * ActiveWindow = wxWindow::FindFocus();
07450
07451
07452 while (ActiveWindow && !ActiveWindow->IsKindOf(CLASSINFO(wxTopLevelWindow)) && ActiveWindow->GetParent())
07453 {
07454 ActiveWindow = ActiveWindow->GetParent();
07455 }
07456
07457
07458 ActiveDlgStateItem* pActiveDlgItem = new ActiveDlgStateItem;
07459 if (!pActiveDlgItem)
07460 return FALSE;
07461
07462 pActiveDlgItem->pActiveWindow = ActiveWindow;
07463 pActiveDlgItem->fIsAModalDialog = IsModal;
07464
07465 DialogManager::ActiveDlgStack.Push(pActiveDlgItem);
07466 return TRUE;
07467 }
07468
07469
07470
07471
07472
07473
07474
07475
07476
07477
07478
07479
07480
07481
07482
07483 void DialogManager::RestoreActiveDialogState()
07484 {
07485 ActiveDlgStateItem *pActiveDlgState = (ActiveDlgStateItem *)ActiveDlgStack.Pop();
07486 ERROR3IF(!pActiveDlgState, "RestoreActiveDialogState called when stack was empty");
07487 if (!pActiveDlgState)
07488 return;
07489
07490 wxFrame *MainFrame = GetMainFrame();
07491
07492 if( NULL != pActiveDlgState->pActiveWindow )
07493 {
07494
07495 if (MainFrame)
07496 {
07497 MainFrame->Enable( !pActiveDlgState->fIsAModalDialog );
07498 }
07499
07500
07501 pActiveDlgState->pActiveWindow->Enable( true );
07502
07503
07504 pActiveDlgState->pActiveWindow->SetFocus();
07505
07506 if( pActiveDlgState->fIsAModalDialog )
07507 {
07508
07509 EnableAllDialogs( FALSE, pActiveDlgState->pActiveWindow );
07510 }
07511 else
07512 {
07513
07514 EnableAllDialogs(TRUE);
07515 }
07516 }
07517 else
07518 {
07519 TRACE( wxT("There is no active window to restore. This is expected during startup before the MainFrame has been created\n") );
07520
07521
07522
07523 if( MainFrame )
07524 MainFrame->Enable( true );
07525
07526
07527 EnableAllDialogs( TRUE );
07528 }
07529 delete pActiveDlgState;
07530 return;
07531 }
07532
07533
07534
07535
07536
07537
07538
07539
07540
07541
07542
07543
07544
07545
07546
07547
07548
07549
07550
07551
07552
07553
07554
07555
07556 CDlgResID DialogManager::GetActivePage(CWindowID WindowID, CGadgetID Gadget )
07557 {
07558
07559 wxBookCtrlBase * pBookControl = GetBookControl(WindowID, Gadget);
07560 if (pBookControl == NULL)
07561 return CDlgResID(-1);
07562
07563 wxNotebookPage* pOurPage = pBookControl->GetCurrentPage();
07564 if (pOurPage == NULL)
07565 return CDlgResID(-1);
07566
07567 return pOurPage->GetId();
07568 }
07569
07570
07571
07572
07573
07574
07575
07576
07577
07578
07579
07580
07581
07582
07583
07584
07585
07586
07587
07588
07589
07590 void DialogManager::SetPropertyPageModified(BOOL Modified)
07591 {
07592 PORTNOTE( "dialog", "Removed RegisterWindowMessage usage" )
07593 #ifndef EXCLUDE_FROM_XARALX
07594 DlgTabOpToPropShtItem* pTabItem = (DlgTabOpToPropShtItem*)DlgTabOpToPropShtList.GetHead();
07595 if (pTabItem->pPropertySheet != NULL)
07596 {
07597 wxNotebookPage* pActivePage = pTabItem->pPropertySheet->GetActivePage();
07598 if (pActivePage != NULL)
07599 pActivePage->SetModified(Modified);
07600 }
07601 #endif
07602 }
07603
07604
07605
07606
07607
07608
07609
07610
07611
07612
07613
07614
07615
07616
07617
07618
07619
07620 ControlInfo::~ControlInfo()
07621 {
07622 }
07623
07624
07625
07626
07627
07628
07629
07630
07631
07632
07633
07634
07635
07636
07637
07638
07639
07640
07641
07642 BOOL DialogManager::CreateBar(DialogBarOp* DlgOp)
07643 {
07644 PORTNOTETRACE("dialog","DialogManager::CreateBar - do nothing");
07645 #ifndef EXCLUDE_FROM_XARALX
07646 BaseBar* DBWnd = NULL;
07647
07648 if ( DlgOp->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)) )
07649 {
07650 #ifdef EXCLUDE_GALS
07651 return FALSE;
07652 #else
07653 DBWnd = new GalleryBar();
07654 #endif
07655 }
07656 else
07657 {
07658 DBWnd = new DialogBar();
07659 }
07660
07661
07662 if (DBWnd != NULL)
07663 {
07664
07665 if(!(DBWnd->Create((DialogBarOp*)DlgOp)))
07666 {
07667 delete DBWnd;
07668 }
07669 }
07670 else
07671 {
07672
07673 ERROR1(FALSE, _R(IDS_OUT_OF_MEMORY));
07674 }
07675 #endif
07676 return TRUE;
07677 }
07678
07679
07680
07681
07682
07683
07684
07685
07686
07687
07688
07689
07690
07691
07692
07693
07694
07695 void DialogManager::RelayoutDialog( DialogTabOp* pDlgOp )
07696 {
07697 if (pDlgOp->WindowID->IsKindOf(CLASSINFO(wxPropertySheetDialog)))
07698 {
07699 ((wxPropertySheetDialog*)(pDlgOp->WindowID))->LayoutDialog();
07700 }
07701 else
07702 Layout(pDlgOp->WindowID);
07703 }
07704
07705
07706
07707
07708
07709
07710
07711
07712
07713
07714
07715
07716
07717
07718
07719
07720
07721
07722
07723
07724
07725
07726
07727 BOOL DialogManager::CreateTabbedDialog(DialogTabOp* pTabDlgOp, CDlgMode Mode, INT32 OpeningPage,
07728 CDlgResID mainDlgID )
07729 {
07730 wxBookCtrlBase * pBook = GetBookControl(pTabDlgOp->WindowID);
07731 if (!pBook)
07732 return TRUE;
07733
07734
07735
07736 if (!(pTabDlgOp->RegisterYourPagesInOrderPlease()))
07737 {
07738
07739 return FALSE;
07740 }
07741 #if 0
07742
07743 if (pBook->GetImageList())
07744 {
07745 wxImageList temp=*pBook->GetImageList();
07746 pBook->SetImageList(&temp);
07747 }
07748 #endif
07749
07750
07751 RelayoutDialog(pTabDlgOp);
07752
07753
07754 ::wxYield();
07755 pBook->SetSelection(pBook->GetPageCount()-1);
07756 pBook->SetSelection(0);
07757
07758
07759
07760
07761
07762 UINT32 ActivePageIndex = 0;
07763 if (OpeningPage != -1)
07764 {
07765
07766
07767 ActivePageIndex = OpeningPage;
07768 }
07769 else
07770 {
07771
07772 DialogPosition* pPosDetails = FindDialogPositionRecord( mainDlgID );
07773 if (pPosDetails != NULL)
07774 {
07775
07776 ActivePageIndex = pPosDetails->ActivePageIndex;
07777 }
07778 }
07779
07780
07781
07782 if (OpeningPage != -1)
07783 {
07784
07785 DialogPosition* pPosDetails = FindDialogPositionRecord( mainDlgID );
07786 if (pPosDetails != NULL)
07787 {
07788
07789
07790
07791
07792 ERROR3IF(pBook == NULL, "There is no current PropertySheet");
07793 wxNotebookPage* pPage = (wxNotebookPage*)(pBook->GetPage(OpeningPage));
07794 ERROR3IF(pPage == NULL, "There is no active page");
07795 pPosDetails->ActivePage = pPage->GetId();
07796 TRACEUSER( "MarkH", _T("CreateTabbedDialog ActivePage = %d\n"),pPosDetails->ActivePage);
07797
07798 pPosDetails->ActivePageIndex = OpeningPage;
07799
07800 }
07801 }
07802
07803 return TRUE;
07804 }
07805
07806
07807
07808
07809
07810
07811
07812
07813
07814
07815
07816
07817
07818
07819
07820
07821
07822
07823
07824 BOOL DialogManager::GetStatusLineText(String_256* ptext, CWindowID window)
07825 {
07826 if (!ptext)
07827 return FALSE;
07828 if (!window)
07829 window=::wxChildWindowFromPoint(wxGetMousePosition(), FALSE, -1);
07830 if (!window)
07831 return FALSE;
07832
07833 wxHelpProvider * hp = wxHelpProvider::Get();
07834
07835
07836
07837 wxString help;
07838 do
07839 {
07840 if (!window->IsKindOf(CLASSINFO(wxControl)))
07841 return FALSE;
07842
07843 if (hp)
07844 help = hp->GetHelp(window);
07845 else
07846 help = ((wxControl *)window)->GetHelpText();
07847
07848 if (help.IsEmpty())
07849 {
07850 wxToolTip* pTip = window->GetToolTip();
07851 if (pTip) help=pTip->GetTip();
07852 }
07853
07854 window=window->GetParent();
07855 } while (window && help.IsEmpty());
07856
07857 if (help.IsEmpty())
07858 return FALSE;
07859
07860 *ptext = help;
07861 return TRUE;
07862 }
07863
07864
07865
07866
07867
07868
07869
07870
07871
07872
07873
07874
07875
07876
07877
07878
07879
07880 CWindowID DialogManager::GetWindowUnderPointer(WinCoord * wc )
07881 {
07882 wxPoint pt=wxGetMousePosition();
07883 wxWindow * w=::wxChildWindowFromPoint(pt, FALSE, -1);
07884 if (wc && w)
07885 {
07886 pt = w->ScreenToClient(pt);
07887 wc->x=pt.x;
07888 wc->y=pt.y;
07889 }
07890 return w;
07891 }
07892
07893
07894 #if 0
07895
07896
07897
07898
07899
07900
07901
07902
07903
07904
07905
07906
07907
07908
07909
07910
07911
07912
07913
07914
07915
07916
07917
07918
07919
07920
07921
07922 BOOL CALLBACK EXPORT DialogManager::SendDialogMessage( wxWindow *pDlg,
07923 UINT32 Message,
07924 UINT32 wParam,
07925 INT32 lParam )
07926 {
07927 PORTNOTETRACE("dialog","DialogManager::SendDialogMessage - do nothing");
07928 #ifndef EXCLUDE_FROM_XARALX
07929 HandleMessage = FALSE;
07930
07931 INT32 DlgMsgParam = 0;
07932
07933
07934 Gadget = 0xFFFFFFF0;
07935
07936
07937
07938
07939 PageID = 0;
07940 HWND BroadcastWindow = hDlg;
07941
07942 wxWindow* pCWnd = CWnd::FromHandlePermanent(hDlg);
07943
07944 if (pCWnd != NULL)
07945 {
07946 if (pCWnd->IsKindOf(RUNTIME_CLASS(wxNotebookPage)))
07947 {
07948 wxWindow* pPropertySheet = pCWnd->GetParent();
07949 if (pPropertySheet)
07950 {
07951 ERROR2IF(!(pPropertySheet->IsKindOf(RUNTIME_CLASS(wxPropertySheetDialog))), FALSE,"Property page parent not a property sheet");
07952 BroadcastWindow = pPropertySheet->GetSafeHwnd();
07953 ERROR2IF(BroadcastWindow == NULL, FALSE, "Property sheet window handle is NULL");
07954
07955 PageID = ((wxNotebookPage*)pCWnd)->GetPageID();
07956 }
07957 else
07958 {
07959
07960 return FALSE;
07961 }
07962 }
07963 }
07964
07965
07966 BOOL RemoveFocus = FALSE;
07967
07968
07969
07970
07971 #if WIN16
07972 WORD Ctl = HIWORD(lParam);
07973
07974 if (Message == WM_CTLCOLOUR && Ctl == CTLCOLOR_EDIT)
07975 Message = WM_CTLCOLOREDIT;
07976 #endif
07977
07978
07979
07980 Document::GetSelected()->SetCurrent();
07981 DocView::GetSelected()->SetCurrent();
07982
07983 switch (Message)
07984 {
07985 case WM_MOVE:
07986 {
07987
07988 HandleMessage = TRUE;
07989 DIM = DIM_DLG_MOVED;
07990 }
07991 break;
07992
07993
07994 case WM_GRIDBN_PRESSED:
07995 DIM = DIM_GRID_BUTTON_DOWN;
07996 HandleMessage = TRUE;
07997 Gadget = LOWORD(lParam);
07998 DlgMsgParam = (INT32) HIWORD(lParam);
07999 break;
08000
08001 case WM_ACTIVATE:
08002
08003
08004 if (wParam == 0)
08005 {
08006
08007 hDlgCurrent = NULL;
08008 }
08009 else
08010 {
08011 hDlgCurrent = hDlg;
08012 }
08013 return TRUE;
08014
08015 case WM_QUERYNEWPALETTE:
08016
08017
08018
08019 PaletteManager::EnsurePalette(BroadcastWindow, FALSE);
08020 return(TRUE);
08021
08022 case WM_PALETTECHANGED:
08023
08024
08025 if (hDlg != (HWND)wParam)
08026 PaletteManager::EnsurePalette(BroadcastWindow, TRUE);
08027 break;
08028
08029
08030 case WM_COMMAND:
08031 Gadget = GET_WM_COMMAND_ID(wParam, lParam);
08032
08033
08034
08035
08036
08037 if (Gadget == _R(ID_APPLY_NOW))
08038 {
08039 Gadget = _R(ID_CC_APPLY_NOW);
08040 }
08041
08042
08043 if (!CustomControlMsg(hDlg, wParam, lParam))
08044 {
08045 DialogManager::Dlg_OnCommand( hDlg,
08046 (short)Gadget,
08047 GET_WM_COMMAND_HWND(wParam, lParam),
08048 (short)GET_WM_COMMAND_CMD(wParam, lParam)
08049 );
08050
08051 if (HandleMessage && DIM == DIM_SELECTION_CHANGED)
08052 RemoveFocus = TRUE;
08053 }
08054 break;
08055
08056 case CBN_CAM_SELCHANGE:
08057
08058 DIM = (CDlgMessage) wParam;
08059 Gadget = (CGadgetID) lParam;
08060 HandleMessage = TRUE;
08061 break;
08062
08063 case WM_CTL_COMMIT:
08064
08065 Gadget = wParam;
08066 DIM = DIM_SELECTION_CHANGED;
08067
08068
08069
08070 if (lParam == CAMKEY(RETURN)) DlgMsgParam = ENTER_COMMIT;
08071 else if (lParam == CAMKEY(TAB)) DlgMsgParam = TAB_COMMIT;
08072 else DlgMsgParam = NO_COMMIT;
08073
08074 HandleMessage = TRUE;
08075 RemoveFocus = TRUE;
08076 break;
08077
08078 case WM_SIZEPARENT:
08079
08080 CMainFrame::pInfoBar->OnSizeParent(wParam, lParam);
08081 break;
08082
08083 case WM_INITDIALOG:
08084 if (!lParam)
08085 {
08086 if (!PostCreate(hDlg))
08087 {
08088
08089 EndDialog(hDlg,FALSE);
08090 }
08091 }
08092 return !FocusSetDuringInit;
08093
08094
08095
08096
08097
08098
08099 case WM_VSCROLL:
08100 case WM_HSCROLL:
08101 Gadget = GetDlgCtrlID( GET_WM_HSCROLL_HWND(wParam,lParam) );
08102 HANDLE_WM_VSCROLL(hDlg, wParam, lParam, DialogManager::Dlg_OnScroll);
08103 break;
08104
08105
08106
08107
08108 case WM_LBUTTONDOWN:
08109 {
08110 INT32 xPos = LOWORD(lParam);
08111 INT32 yPos = HIWORD(lParam);
08112 POINT point = { xPos, yPos };
08113 HWND HitWnd = ChildWindowFromPoint(hDlg, point);
08114 if (HitWnd != NULL)
08115 Gadget = GetDlgCtrlID(HitWnd);
08116 HandleMessage = TRUE;
08117 DIM = DIM_LFT_BN_DOWN;
08118 break;
08119 }
08120 case WM_LBUTTONUP:
08121 {
08122 INT32 xPos = LOWORD(lParam);
08123 INT32 yPos = HIWORD(lParam);
08124 POINT point = { xPos, yPos };
08125 HWND HitWnd = ChildWindowFromPoint(hDlg, point);
08126 if (HitWnd != NULL)
08127 Gadget = GetDlgCtrlID(HitWnd);
08128 HandleMessage = TRUE;
08129 DIM = DIM_LFT_BN_UP;
08130
08131 break;
08132 }
08133
08134
08135 case WM_RBUTTONDOWN:
08136 HandleMessage = TRUE;
08137 DIM = DIM_RGT_BN_DOWN;
08138
08139 break;
08140 case WM_RBUTTONUP:
08141 HandleMessage = TRUE;
08142 DIM = DIM_RGT_BN_UP;
08143
08144 break;
08145
08146 case WM_MOUSEWHEEL:
08147 {
08148 INT32 xPos = LOWORD(lParam);
08149 INT32 yPos = HIWORD(lParam);
08150 POINT point = { xPos, yPos };
08151 HWND HitWnd = ChildWindowFromPoint(hDlg, point);
08152 if (HitWnd != NULL)
08153 Gadget = GetDlgCtrlID(HitWnd);
08154 HandleMessage = TRUE;
08155 if ((short)HIWORD(wParam) > 0)
08156 {
08157 DIM = DIM_MOUSEWHEEL_UP;
08158 }
08159 else
08160 {
08161 DIM = DIM_MOUSEWHEEL_DOWN;
08162 }
08163 break;
08164 }
08165
08166
08167
08168
08169 case WMN_POSITION_CHANGING:
08170 Gadget = GetWindowID((HWND)wParam);
08171 HandleMessage = TRUE;
08172 DIM = DIM_SLIDER_POS_CHANGING;
08173 DlgMsgParam = lParam;
08174 break;
08175 case WMN_POSITION_IDLE:
08176 Gadget = GetWindowID((HWND)wParam);
08177 HandleMessage = TRUE;
08178 DIM = DIM_SLIDER_POS_IDLE;
08179 DlgMsgParam = lParam;
08180 break;
08181 case WMN_POSITION_SET:
08182 Gadget = GetWindowID((HWND)wParam);
08183 HandleMessage = TRUE;
08184 DIM = DIM_SLIDER_POS_SET;
08185 DlgMsgParam = lParam;
08186 break;
08187
08188
08189
08190
08191
08192
08193 case WM_FONTCHANGE:
08194 HandleMessage = TRUE;
08195 DIM = DIM_FONTCHANGE;
08196 break;
08197
08198
08199 case WM_TIMER:
08200
08201
08202
08203 DlgMsgParam = wParam;
08204 HandleMessage = TRUE;
08205 DIM = DIM_TIMER;
08206 break;
08207
08208
08209
08210
08211
08212
08213
08214
08215
08216
08217
08218
08219
08220
08221
08222
08223
08224
08225
08226
08227
08228
08229 case WM_MOUSEMOVE:
08230 {
08231 if (!(wParam & (MK_LBUTTON | MK_RBUTTON | MK_MBUTTON)))
08232 {
08233 HandleMessage = TRUE;
08234 DIM = DIM_MOUSE_MOVE;
08235 }
08236 break;
08237 }
08238
08239 case WM_NOTIFY:
08240 {
08241 HWND hChild = GetDlgItem(hDlg, INT32(wParam));
08242 TCHAR buffer[32];
08243 GetClassName(hChild, buffer, sizeof(buffer));
08244 if (String_32(buffer) == String_32(TEXT("SysTreeView32")))
08245 {
08246 LPNMHDR pNMHDR = (LPNMHDR) lParam;
08247 switch (pNMHDR->code)
08248 {
08249
08250 case TVN_SELCHANGED:
08251 {
08252 HandleMessage = TRUE;
08253 Gadget = wParam;
08254 DIM = DIM_SELECTION_CHANGED;
08255 DlgMsgParam = lParam;
08256 }
08257 }
08258 }
08259
08260 if (String_32(buffer) == (LPCTSTR)CCustomList::WNDCLASSNAME)
08261 {
08262 LPNMHDR pNMHDR = (LPNMHDR) lParam;
08263 CCustomList* pListGadget = CCustomList::GetGadget((CWindowID) hDlg, (CGadgetID) pNMHDR->idFrom);
08264 BOOL DoubleClick = FALSE;
08265
08266 if (pListGadget)
08267 {
08268
08269 HandleMessage = TRUE;
08270 Gadget = wParam;
08271 if(pNMHDR->code == NM_DBLCLK)
08272 {
08273 DIM = DIM_SELECTION_CHANGED_COMMIT;
08274
08275 }
08276 else
08277 {
08278 DIM = DIM_SELECTION_CHANGED;
08279 }
08280 }
08281 else
08282 {
08283 ERROR3("Failed to find list gadget");
08284 }
08285 }
08286
08287 if (String_32(buffer) == String_32(TEXT("msctls_updown32")))
08288 {
08289 NM_UPDOWN* pnmud = (NM_UPDOWN FAR *) lParam;
08290
08291 if (pnmud->iDelta > 0)
08292 {
08293 SpinControlMessageUp = TRUE;
08294 HandleMessage = FALSE;
08295 }
08296 else if (pnmud->iDelta < 0)
08297 {
08298 SpinControlMessageDown = TRUE;
08299 HandleMessage = FALSE;
08300 }
08301 else
08302 {
08303 ERROR3 ("A Fatal error has occured within the OS!");
08304 }
08305 }
08306 }
08307 break;
08308
08309
08310
08311
08312
08313
08314
08315
08316
08317
08318
08319 case WM_SYSCOLORCHANGE:
08320 {
08321 HWND hChild = GetDlgItem(hDlg, INT32(wParam));
08322 if(hChild)
08323 {
08324 ::SendMessage(hChild, WM_SYSCOLORCHANGE, 0, 0);
08325 }
08326 return TRUE;
08327 break;
08328 }
08329
08330 case WM_DLGDRAWEVENT:
08331 {
08332 DlgDrawEventInfo *Info = (DlgDrawEventInfo *) lParam;
08333 ERROR3IF(Info == NULL, "NULL DilaogDraw EventInfo passed to DialogMgr?!");
08334
08335 switch(Info->msg)
08336 {
08337 case WM_LBUTTONDOWN:
08338 DIM = DIM_LFT_BN_DOWN;
08339 break;
08340
08341 case WM_LBUTTONUP:
08342 DIM = DIM_LFT_BN_UP;
08343 break;
08344
08345 case WM_RBUTTONDOWN:
08346 DIM = DIM_RGT_BN_DOWN;
08347 break;
08348
08349 case WM_RBUTTONUP:
08350 DIM = DIM_RGT_BN_UP;
08351 break;
08352
08353 case WM_MOUSEMOVE:
08354 if (Info->wParam & MK_LBUTTON)
08355 DIM = DIM_MOUSE_DRAG;
08356 else
08357 DIM = DIM_MOUSE_MOVE;
08358 break;
08359
08360 case WM_MOUSEWHEEL:
08361 if ((short) HIWORD(Info->wParam) > 0)
08362 {
08363
08364 DIM = DIM_MOUSEWHEEL_UP;
08365 }
08366 else
08367 {
08368
08369 DIM = DIM_MOUSEWHEEL_DOWN;
08370 }
08371 break;
08372
08373 default:
08374 ERROR3("Unknown Event type passed in WM_DLGDRAWEVENT message");
08375 break;
08376 }
08377
08378
08379
08380 ReDrawInfoType ExtraInfo;
08381
08382 ExtraInfo.pDC = NULL;
08383 ExtraInfo.pClipRect = NULL;
08384
08385
08386 HDC ScreenDC = CreateCompatibleDC(NULL);
08387 if (ScreenDC == NULL)
08388 {
08389 ERROR2RAW("DialogManager::SendDialogMessage: Unable to create screen DC");
08390 break;
08391 }
08392 ExtraInfo.Dpi = GetDeviceCaps(ScreenDC, LOGPIXELSY);
08393 DeleteDC(ScreenDC);
08394
08395
08396 RECT WindowSize;
08397 if (!GetClientRect(Info->hwnd, &WindowSize))
08398 {
08399 ERROR2RAW("GetClientRect failed in DialogManager::SendDialogMessage");
08400 break;
08401 }
08402
08403 ExtraInfo.dx = (((INT32)WindowSize.right)*72000) / ExtraInfo.Dpi;
08404 ExtraInfo.dy = (((INT32)WindowSize.bottom)*72000) / ExtraInfo.Dpi;
08405
08406
08407
08408 INT32 XPos = (INT32) MAKEPOINTS(Info->lParam).x;
08409 INT32 YPos = (INT32) MAKEPOINTS(Info->lParam).y;
08410
08411 DocCoord MousePos;
08412 MousePos.x = (XPos * 72000) / ExtraInfo.Dpi;
08413 MousePos.y = ExtraInfo.dy - ((YPos * 72000) / ExtraInfo.Dpi);
08414 ExtraInfo.pMousePos = &MousePos;
08415
08416
08417
08418
08419
08420 BROADCAST_TO_CLASS(DialogMsg(BroadcastWindow, DIM, Info->ControlID, (INT32)&ExtraInfo, PageID), DialogOp);
08421 break;
08422 }
08423
08424
08425 case WM_REDRAW :
08426 {
08427 if (CCamApp::IsDisabled())
08428 {
08429 TRACE( _T("kernel-rendered gadget repaint has been aborted: the system is disabled (due to an error/ensure?)\n"));
08430 HandleMessage = FALSE;
08431 break;
08432 }
08433
08434
08435 RedrawInfo* pInfo = (RedrawInfo*) lParam;
08436
08437 HDC hDC = pInfo->PaintInfo.hdc;
08438 HPALETTE OldPalette = PaletteManager::StartPaintPalette(hDC);
08439
08440 ReDrawInfoType ExtraInfo;
08441
08442 ExtraInfo.pMousePos = NULL;
08443
08444
08445
08446 CCDC MyDc(RENDERTYPE_SCREEN);
08447 MyDc.Attach(pInfo->PaintInfo.hdc);
08448 ExtraInfo.pDC = &MyDc;
08449
08450
08451 ExtraInfo.Dpi = MyDc.GetDeviceCaps(LOGPIXELSY);
08452
08453
08454 RECT WindowSize;
08455 if (GetClientRect((HWND)wParam, &WindowSize))
08456 {
08457 ExtraInfo.dx = (((INT32)WindowSize.right)*72000) / ExtraInfo.Dpi;
08458 ExtraInfo.dy = (((INT32)WindowSize.bottom)*72000) / ExtraInfo.Dpi;
08459 }
08460
08461
08462 RECT* ClipRect = &pInfo->PaintInfo.rcPaint;
08463 DocRect DocClipRect;
08464
08465
08466
08467 DocClipRect.lo.x = (ClipRect->left * 72000) / ExtraInfo.Dpi;
08468 DocClipRect.lo.y = ExtraInfo.dy - ((ClipRect->bottom * 72000) / ExtraInfo.Dpi);
08469
08470 DocClipRect.hi.x = (ClipRect->right * 72000) / ExtraInfo.Dpi;
08471 DocClipRect.hi.y = ExtraInfo.dy - ((ClipRect->top * 72000) / ExtraInfo.Dpi);
08472
08473
08474 ExtraInfo.pClipRect = &DocClipRect;
08475
08476
08477
08478
08479 BROADCAST_TO_CLASS(DialogMsg(BroadcastWindow, DIM_REDRAW, pInfo->ControlID, (INT32) &ExtraInfo, PageID), DialogOp);
08480
08481
08482 MyDc.Detach();
08483
08484 if (OldPalette)
08485 PaletteManager::StopPaintPalette(hDC, OldPalette);
08486 break;
08487 }
08488
08489 case WM_DRAWITEM:
08490 {
08491
08492 if (DropDown::HandleDrawItem(hDlg, wParam, lParam))
08493 return(TRUE);
08494
08495 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT) lParam;
08496
08497
08498
08499 if (SendMessage( lpdis->hwndItem,
08500 DialogManager::MsgSlaveDrawItem, wParam, lParam ))
08501 return(TRUE);
08502 }
08503 break;
08504
08505 case WM_MEASUREITEM:
08506 {
08507
08508
08509
08510
08511 if (DropDown::HandleMeasureItem(hDlg, wParam, lParam))
08512 return(TRUE);
08513 }
08514 break;
08515
08516
08517
08518
08519
08520
08521
08522
08523
08524
08525
08526
08527
08528
08529
08530
08531
08532
08533
08534
08535
08536
08537
08538
08539
08540
08541
08542
08543 case WM_MOUSEACTIVATE:
08544 if (((INT32) LOWORD(lParam)) != HTCAPTION)
08545 return(FALSE);
08546 else
08547 return (MA_NOACTIVATE);
08548
08549
08550 case WM_EXITSIZEMOVE:
08551 DIM = DIM_TITLEFOCUSWARN;
08552 BROADCAST_TO_CLASS( DialogMsg(BroadcastWindow, DIM, Gadget, DlgMsgParam, PageID), DialogOp );
08553
08554 return (TRUE);
08555
08556
08557
08558 break;
08559
08560
08561 case WM_KEYDOWN:
08562 {
08563
08564
08565 if (::GetDlgItem(hDlg, _R(IDC_FONT_COMBO)) != NULL &&
08566 (TCHAR)wParam >= 'A' &&
08567 (TCHAR)wParam <= 'Z')
08568 {
08569
08570
08571 static DWORD dwTime = 0;
08572 static String_256 strCharsTyped = "";
08573
08574 DWORD dwNow = ::GetTickCount();
08575 if ((dwNow - dwTime) > 1000 || strCharsTyped.Length() > 255)
08576 strCharsTyped.Empty();
08577
08578 strCharsTyped += (TCHAR)wParam;
08579
08580
08581
08582 BOOL bMatch = FALSE;
08583 FontDropItem* fontItem = NULL;
08584 HWND hwndCombo = ::GetDlgItem(hDlg, _R(IDC_FONT_COMBO));
08585 INT32 numItems = ComboBox_GetCount(hwndCombo);
08586 for (INT32 i = 0; !bMatch && i < numItems; i ++)
08587 {
08588 fontItem = (FontDropItem*)ComboBox_GetItemData(hwndCombo, i);
08589 if (fontItem != NULL)
08590 {
08591 bMatch = (camStrnicmp(fontItem->GetFontName(),
08592 strCharsTyped,
08593 camStrlen(strCharsTyped)) == 0);
08594 }
08595 }
08596
08597
08598 if (bMatch)
08599 ::SendMessage(hwndCombo, CB_SETCURSEL, i - 1, 0);
08600 else
08601 strCharsTyped.Empty();
08602
08603
08604 dwTime = ::GetTickCount();
08605
08606 return TRUE;
08607 }
08608 }
08609 break;
08610 }
08611
08612
08613 static LPDRAGLISTINFO lpdli;
08614 static UINT32 iItemToMove, iItem;
08615
08616 if (Message == DialogManager::MsgDragList)
08617 {
08618 #if USE_COMMON_CONTROLS
08619 lpdli = (LPDRAGLISTINFO)lParam;
08620 switch (lpdli->uNotification)
08621 {
08622 case DL_BEGINDRAG:
08623 iItemToMove = LBItemFromPt(lpdli->hWnd, lpdli->ptCursor, TRUE);
08624 return DL_MOVECURSOR;
08625 case DL_DRAGGING:
08626 iItem = LBItemFromPt(lpdli->hWnd, lpdli->ptCursor, TRUE);
08627 DrawInsert(hDlg, lpdli->hWnd, iItem);
08628 if (iItem!=-1)
08629 return DL_MOVECURSOR;
08630 return DL_STOPCURSOR;
08631 case DL_DROPPED:
08632 iItem = LBItemFromPt(lpdli->hWnd, lpdli->ptCursor, TRUE);
08633
08634
08635
08636
08637
08638
08639 DrawInsert(hDlg, lpdli->hWnd, -1);
08640 return DL_CURSORSET;
08641 default:
08642 if (IsUserName("Simon"))
08643 TRACE( _T("Unknown draglist message 0x%x\n"), lpdli->uNotification);
08644
08645 }
08646 #endif
08647 }
08648
08649
08650 if (HandleMessage)
08651 {
08652 BROADCAST_TO_CLASS( DialogMsg(BroadcastWindow, DIM, Gadget, DlgMsgParam, PageID), DialogOp );
08653 }
08654 #endif
08655 return HandleMessage;
08656 }
08657
08658
08659
08660
08661
08662
08663
08664
08665
08666
08667
08668
08669
08670
08671 void DialogManager::Dlg_OnCommand( wxWindow *pWnd, INT32 id, wxWindow *pWndCtl, INT32 codeNotify )
08672 {
08673 PORTNOTETRACE("dialog","DialogManager::Dlg_OnCommand - do nothing");
08674 #ifndef EXCLUDE_FROM_XARALX
08675 String_256 ClassNameStr;
08676 GetClassName(hwndCtl, (TCHAR*)ClassNameStr, 255);
08677
08678
08679
08680
08681
08682 if (id == IDOK)
08683 {
08684 if (codeNotify == BN_RGT_CLICKED)
08685 {
08686 DialogManager::DIM = DIM_SOFT_COMMIT;
08687 DialogManager::HandleMessage = TRUE;
08688 return;
08689 }
08690 else
08691 {
08692
08693 DialogManager::DIM = DIM_COMMIT;
08694 DialogManager::HandleMessage = TRUE;
08695 SetGadgetIDToFocus(hwnd);
08696
08697 PostMessage(hwnd, WM_NEXTDLGCTL, 0, 0L) ;
08698 return;
08699 }
08700 }
08701 else if (id == _R(ID_CC_APPLY_NOW))
08702 {
08703
08704 DialogManager::DIM = DIM_SOFT_COMMIT;
08705 DialogManager::HandleMessage = TRUE;
08706 return;
08707
08708 }
08709 else if (id == IDCANCEL)
08710 {
08711 DialogManager::DIM = DIM_CANCEL;
08712 DialogManager::HandleMessage = TRUE;
08713 SetGadgetIDToFocus(hwnd);
08714 return;
08715 }
08716
08717
08718
08719 if ((ClassNameStr == String_8(TEXT("Button"))))
08720 {
08721 switch (codeNotify)
08722 {
08723 case BN_RGT_CLICKED:
08724 DialogManager::DIM = DIM_RGT_BN_CLICKED;
08725 DialogManager::HandleMessage = TRUE;
08726 break;
08727
08728 case BN_CLICKED:
08729 DialogManager::DIM = DIM_LFT_BN_CLICKED;
08730 DialogManager::HandleMessage = TRUE;
08731 break;
08732 }
08733 }
08734 else if ( (ClassNameStr == String_8(TEXT("ListBox"))) ||
08735 (ClassNameStr == String_16(TEXT("cc_CheckList")))
08736 )
08737 {
08738 switch (codeNotify)
08739 {
08740 case LBN_ERRSPACE:
08741 DialogManager::DIM = DIM_OUT_OF_SPACE;
08742 DialogManager::HandleMessage = TRUE;
08743 break;
08744 case LBN_SELCHANGE:
08745 DialogManager::DIM = DIM_SELECTION_CHANGED;
08746 DialogManager::HandleMessage = TRUE;
08747
08748
08749 break;
08750 case LBN_DBLCLK:
08751 DialogManager::DIM = DIM_SELECTION_CHANGED_COMMIT;
08752 DialogManager::HandleMessage = TRUE;
08753 break;
08754 case LBN_SELCANCEL:
08755 DialogManager::DIM = DIM_SELECTION_CANCELED;
08756 DialogManager::HandleMessage = TRUE;
08757 break;
08758 }
08759 }
08760 else if ( (ClassNameStr == String_8(TEXT("ComboBox"))) ||
08761 (ClassNameStr == String_64(TEXT("cc_1dBitmapComboBoxEdit"))) ||
08762 (ClassNameStr == String_64(TEXT("cc_2dBitmapComboBoxEdit")))
08763 )
08764 {
08765
08766 switch (codeNotify)
08767 {
08768 case CBN_KILLFOCUS:
08769
08770
08771
08772
08773
08774
08775 DialogManager::DIM = DIM_FOCUS_LOST;
08776 DialogManager::HandleMessage = TRUE;
08777 break;
08778 case CBN_DROPDOWN:
08779
08780
08781
08782
08783
08784
08785 DialogManager::DIM = DIM_LISTDROPPED;
08786 DialogManager::HandleMessage = TRUE;
08787 break;
08788 case CBN_ERRSPACE:
08789 DialogManager::DIM = DIM_OUT_OF_SPACE;
08790 DialogManager::HandleMessage = TRUE;
08791 break;
08792 case CBN_SELCHANGE:
08793 ::PostMessage(hwnd, CBN_CAM_SELCHANGE,
08794 (WPARAM) DIM_SELECTION_CHANGED,
08795 (LPARAM) Gadget);
08796
08797
08798
08799 break;
08800
08801 case CBN_DBLCLK:
08802 case CBN_SELENDOK:
08803 case CBN_CLOSEUP:
08804 ::PostMessage(hwnd, CBN_CAM_SELCHANGE,
08805 (WPARAM) DIM_SELECTION_CHANGED_COMMIT,
08806 (LPARAM) Gadget);
08807 break;
08808
08809 case CBN_EDITCHANGE:
08810 DialogManager::DIM = DIM_TEXT_CHANGED;
08811 DialogManager::HandleMessage = TRUE;
08812 break;
08813 }
08814 }
08815
08816 else if (ClassNameStr == String_8(TEXT("Edit")))
08817 {
08818 switch (codeNotify)
08819 {
08820 case EN_CHANGE:
08821 DialogManager::DIM = DIM_TEXT_CHANGED;
08822 DialogManager::HandleMessage = TRUE;
08823 break;
08824
08825 case EN_SETFOCUS:
08826 DialogManager::DIM = DIM_SET_FOCUS;
08827 DialogManager::HandleMessage = TRUE;
08828 break;
08829
08830 case EN_KILLFOCUS:
08831 DialogManager::DIM = DIM_KILL_FOCUS;
08832 DialogManager::HandleMessage = TRUE;
08833 break;
08834 }
08835 }
08836 #endif
08837 }
08838
08839
08840
08841
08842
08843
08844
08845
08846
08847
08848
08849
08850
08851
08852 void DialogManager::Dlg_OnScroll( wxWindow *pWnd, wxWindow *pWndCtl, UINT32 code, INT32 pos )
08853 {
08854 PORTNOTETRACE("dialog","DialogManager::Dlg_OnScroll - do nothing");
08855 #ifndef EXCLUDE_FROM_XARALX
08856
08857 String_256 ClassNameStr;
08858 GetClassName(hwndCtl, (TCHAR*)ClassNameStr, 255);
08859 BOOL ScrollControl = (ClassNameStr == String_16(TEXT("ScrollBar")));
08860 BOOL SpinControl = (ClassNameStr == String_32(TEXT("msctls_updown32")));
08861
08862 INT32 Page;
08863
08864 if (!SpinControl)
08865 {
08866
08867 ScrollPageInc* PgInc = (ScrollPageInc*)(ScrollPageIncList.GetHead());
08868 BOOL FoundPageIncDetails = FALSE;
08869 while (PgInc != NULL)
08870 {
08871 if (PgInc->ScrollBarWnd == hwndCtl)
08872 {
08873 FoundPageIncDetails = TRUE;
08874 Page = PgInc->PageInc;
08875 }
08876 PgInc = (ScrollPageInc*)ScrollPageIncList.GetNext((ListItem*)PgInc);
08877 }
08878 ENSURE(FoundPageIncDetails, "Scroll bar has not has its range of values set");
08879 }
08880
08881
08882 INT32 ScrollMin;
08883 INT32 ScrollMax;
08884
08885 WORD CurrentThumbPos;
08886
08887 if (ScrollControl)
08888 {
08889 GetScrollRange(hwndCtl, SB_CTL, &ScrollMin, &ScrollMax);
08890 CurrentThumbPos = (WORD)GetScrollPos(hwndCtl, SB_CTL);
08891 }
08892 else if (SpinControl)
08893 {
08894 DWORD ScrollRange = SendMessage (hwndCtl, UDM_GETRANGE, 0, 0);
08895 ScrollMin = HIWORD (ScrollRange);
08896 ScrollMax = LOWORD (ScrollRange);
08897 CurrentThumbPos = (INT32) SendMessage(hwndCtl, UDM_GETPOS, 0, 0);
08898
08899 if (SpinControlMessageUp)
08900 {
08901 code = SB_LINEUP;
08902 }
08903 else if (SpinControlMessageDown)
08904 {
08905 code = SB_LINEDOWN;
08906 }
08907 else
08908 {
08909 return;
08910 }
08911
08912
08913
08914
08915 }
08916 else
08917 {
08918 ScrollMin = (INT32) SendMessage(hwndCtl, TBM_GETRANGEMIN, 0, 0);
08919 ScrollMax = (INT32) SendMessage(hwndCtl, TBM_GETRANGEMAX, 0, 0);
08920 CurrentThumbPos = (WORD) SendMessage(hwndCtl, TBM_GETPOS, 0, 0);
08921 }
08922
08923 INT32 ScrollBarInc = 0;
08924 INT32 NewPos;
08925
08926 switch (code)
08927 {
08928 case SB_TOP:
08929 ScrollBarInc = -(INT32)(CurrentThumbPos - ScrollMin);
08930 break;
08931 case SB_BOTTOM:
08932 ScrollBarInc = ScrollMax - CurrentThumbPos;
08933 break;
08934 case SB_LINEUP:
08935 ScrollBarInc = -1;
08936 break;
08937 case SB_LINEDOWN:
08938 ScrollBarInc = 1;
08939 break;
08940 case SB_PAGEUP:
08941 ScrollBarInc = -Page;
08942 break;
08943 case SB_PAGEDOWN:
08944 ScrollBarInc = Page;
08945 break;
08946 case SB_THUMBTRACK:
08947 ScrollBarInc = pos - CurrentThumbPos;
08948 break;
08949 case SB_THUMBPOSITION:
08950
08951 break;
08952 }
08953
08954 NewPos = CurrentThumbPos + ScrollBarInc;
08955 NewPos = max(ScrollMin, min(NewPos, ScrollMax));
08956
08957 if (ScrollBarInc != 0)
08958 {
08959 if (ScrollControl)
08960 {
08961 SetScrollPos(hwndCtl, SB_CTL, NewPos, TRUE);
08962 }
08963 else if (!SpinControl)
08964 {
08965 SendMessage(hwndCtl, TBM_SETPOS,1,(INT32)NewPos );
08966 }
08967
08968
08969
08970
08971
08972
08973
08974
08975
08976 if (ScrollControl)
08977 {
08978 DIM = DIM_SELECTION_CHANGED;
08979 }
08980 else if (SpinControl)
08981 {
08982 if (SpinControlMessageUp)
08983 {
08984 DIM = DIM_SPINCONTROLUP;
08985 SpinControlMessageUp = FALSE;
08986 }
08987 else
08988 {
08989 SpinControlMessageDown = FALSE;
08990 DIM = DIM_SPINCONTROLDOWN;
08991 }
08992 }
08993 else
08994 {
08995 DIM = DIM_SELECTION_CHANGED;
08996 }
08997
08998 HandleMessage = TRUE;
08999 }
09000 #endif
09001 }
09002
09003
09004 #endif
09005
09006
09007
09008
09009
09010
09011
09012
09013
09014
09015
09016
09017
09018
09019
09020
09021
09022
09023
09024
09025
09026
09027
09028
09029
09030
09031
09032
09033
09034
09035
09036 CTreeItemID DialogManager::SetTreeGadgetItem(CWindowID wnd,
09037 CGadgetID Gadget,
09038 CTreeItemID hParent,
09039 const StringBase& str,
09040 CTreeItemID hInsAfter,
09041 INT32 iImage,
09042 CCObject* pObj)
09043 {
09044 wxWindow * pGadget = GetGadget(wnd, Gadget);
09045 if (!pGadget) return CTreeItemID();
09046
09047 wxString String = str;
09048
09049 if ( pGadget->IsKindOf(CLASSINFO(wxTreeCtrl))
09050 )
09051 {
09052 CamelotTreeItemData* pData = NULL;
09053 if (pObj)
09054 pData = new CamelotTreeItemData(pObj);
09055
09056 return ((wxTreeCtrl*)pGadget)->InsertItem(hParent, hInsAfter, String, iImage, -1, pData);
09057 }
09058
09059 ERROR3("SetTreeGadgetItem called on non-tree gadget");
09060
09061 return CTreeItemID();
09062 }
09063
09064
09065
09066
09067
09068
09069
09070
09071
09072
09073
09074
09075
09076
09077
09078
09079
09080
09081
09082
09083
09084
09085
09086
09087 CCObject* DialogManager::GetTreeGadgetItemData(CWindowID wnd, CGadgetID Gadget, CTreeItemID hItem)
09088 {
09089 wxWindow* pGadget = GetGadget(wnd, Gadget);
09090 if (!pGadget) return NULL;
09091
09092 if ( pGadget->IsKindOf(CLASSINFO(wxTreeCtrl))
09093 )
09094 {
09095 wxTreeItemData* pData = ((wxTreeCtrl*)pGadget)->GetItemData(hItem);
09096 if (pData)
09097 return ((CamelotTreeItemData*)pData)->GetObject();
09098
09099 return NULL;
09100 }
09101
09102 ERROR3("SetTreeGadgetItem called on non-tree gadget");
09103
09104 return NULL;
09105 }
09106
09107
09108
09109
09110
09111
09112
09113
09114
09115
09116
09117
09118
09119
09120
09121
09122
09123
09124
09125
09126
09127 BOOL DialogManager::SelectTreeGadgetItem(CWindowID wnd, CGadgetID Gadget, CTreeItemID hItem, BOOL bNewState)
09128 {
09129 wxWindow* pGadget = GetGadget(wnd, Gadget);
09130 if (!pGadget) return FALSE;
09131
09132 if ( pGadget->IsKindOf(CLASSINFO(wxTreeCtrl))
09133 )
09134 {
09135 ((wxTreeCtrl*)pGadget)->SelectItem(hItem, FALSE != bNewState);
09136 return TRUE;
09137 }
09138
09139 ERROR3("SetTreeGadgetItem called on non-tree gadget");
09140 return FALSE;
09141 }
09142
09143
09144
09145
09146
09147
09148
09149
09150
09151
09152
09153
09154
09155
09156
09157
09158
09159
09160 CTreeItemID DialogManager::GetTreeGadgetRootItem(CWindowID wnd, CGadgetID Gadget)
09161 {
09162 wxWindow* pGadget = GetGadget(wnd, Gadget);
09163 if (!pGadget) return CTreeItemID();
09164
09165 if ( pGadget->IsKindOf(CLASSINFO(wxTreeCtrl))
09166 )
09167 {
09168 return ((wxTreeCtrl*)pGadget)->GetRootItem();
09169
09170 return CTreeItemID();
09171 }
09172
09173 ERROR3("SetTreeGadgetItem called on non-tree gadget");
09174 return CTreeItemID();
09175 }
09176
09177
09178
09179
09180
09181
09182
09183
09184
09185
09186
09187
09188
09189
09190
09191
09192
09193
09194
09195 CTreeItemID DialogManager::GetTreeGadgetFirstSelectedItem(CWindowID wnd, CGadgetID Gadget)
09196 {
09197 wxWindow* pGadget = GetGadget(wnd, Gadget);
09198 if (!pGadget) return CTreeItemID();
09199
09200 if ( pGadget->IsKindOf(CLASSINFO(wxTreeCtrl))
09201 )
09202 {
09203 return ((wxTreeCtrl*)pGadget)->GetSelection();
09204 }
09205
09206 ERROR3("SetTreeGadgetItem called on non-tree gadget");
09207 return CTreeItemID();
09208 }
09209
09210
09211
09212
09213
09214
09215
09216
09217
09218
09219
09220
09221
09222
09223
09224
09225
09226
09227
09228
09229
09230 BOOL DialogManager::TreeGadgetExpandItem(CWindowID wnd, CGadgetID Gadget, CTreeItemID hItem)
09231 {
09232 wxWindow* pGadget = GetGadget(wnd, Gadget);
09233 if (!pGadget) return FALSE;
09234
09235 if ( pGadget->IsKindOf(CLASSINFO(wxTreeCtrl))
09236 )
09237 {
09238 ((wxTreeCtrl*)pGadget)->Expand(hItem);
09239 return TRUE;
09240 }
09241
09242 ERROR3("SetTreeGadgetItem called on non-tree gadget");
09243 return FALSE;
09244 }
09245
09246
09247
09248
09249
09250
09251
09252
09253
09254
09255
09256
09257
09258
09259
09260
09261
09262
09263
09264 CTreeItemID DialogManager::GetTreeGadgetNextVisItem(CWindowID wnd, CGadgetID Gadget, CTreeItemID hItem)
09265 {
09266 wxWindow* pGadget = GetGadget(wnd, Gadget);
09267 if (!pGadget) return CTreeItemID();
09268
09269 if ( pGadget->IsKindOf(CLASSINFO(wxTreeCtrl))
09270 )
09271 {
09272 return ((wxTreeCtrl*)pGadget)->GetNextVisible(hItem);
09273 }
09274
09275 ERROR3("SetTreeGadgetItem called on non-tree gadget");
09276 return CTreeItemID();
09277 }
09278
09279
09280
09281
09282
09283
09284
09285
09286
09287
09288
09289
09290
09291
09292
09293
09294
09295
09296
09297 CTreeItemID DialogManager::GetTreeGadgetFirstChildItem(CWindowID wnd, CGadgetID Gadget, CTreeItemID hItem)
09298 {
09299 wxWindow* pGadget = GetGadget(wnd, Gadget);
09300 if (!pGadget) return CTreeItemID();
09301
09302 if ( pGadget->IsKindOf(CLASSINFO(wxTreeCtrl))
09303 )
09304 {
09305 wxTreeItemIdValue sessioncookie;
09306 return ((wxTreeCtrl*)pGadget)->GetFirstChild(hItem, sessioncookie);
09307 }
09308
09309 ERROR3("SetTreeGadgetItem called on non-tree gadget");
09310 return CTreeItemID();
09311 }
09312
09313
09314
09315
09316
09317
09318
09319
09320
09321
09322
09323
09324
09325
09326
09327
09328
09329
09330
09331
09332 UINT32 DialogManager::GetTreeGadgetChildrenCount(CWindowID wnd, CGadgetID Gadget, CTreeItemID hItem, BOOL bRecursive)
09333 {
09334 wxWindow* pGadget = GetGadget(wnd, Gadget);
09335 if (!pGadget) return 0;
09336
09337 if( pGadget->IsKindOf( CLASSINFO(wxTreeCtrl) ) )
09338 {
09339 return UINT32( ((wxTreeCtrl*)pGadget)->GetChildrenCount( hItem, FALSE != bRecursive ) );
09340 }
09341
09342 ERROR3("SetTreeGadgetItem called on non-tree gadget");
09343 return 0;
09344 }
09345
09346
09347
09348
09349
09350
09351
09352
09353
09354
09355
09356
09357
09358
09359
09360
09361
09362
09363 UINT32 DialogManager::GetGadgetImageCount(CWindowID wnd, CGadgetID Gadget)
09364 {
09365 ERROR3("Unimplemented!");
09366 return 0;
09367 }
09368
09369
09370
09371
09372
09373
09374
09375
09376
09377
09378
09379
09380 CGadgetImageList::~CGadgetImageList()
09381 {
09382 m_BitmapIDList.DeleteAll();
09383 }
09384
09385
09386
09387
09388
09389
09390
09391
09392
09393
09394
09395
09396
09397 UINT32 CGadgetImageList::Add(CDlgResID resID)
09398 {
09399 m_BitmapIDList.AddTail(new ResIDListItem(resID));
09400 return m_BitmapIDList.GetCount()-1;
09401 }
09402
09403
09404
09405
09406
09407
09408
09409
09410
09411
09412
09413
09414
09415
09416
09417 ListItem* CGadgetImageList::FindFirstBitmap(ResourceID* presID) const
09418 {
09419 ResIDListItem* pItem = (ResIDListItem*)m_BitmapIDList.GetHead();
09420 if (presID && pItem)
09421 *presID = pItem->m_ResID;
09422
09423 return (ListItem*)pItem;
09424 }
09425
09426
09427
09428
09429
09430
09431
09432
09433
09434
09435
09436
09437
09438
09439
09440
09441
09442 ListItem* CGadgetImageList::FindNextBitmap(ListItem* pContextItem, ResourceID* presID) const
09443 {
09444 ResIDListItem* pItem = (ResIDListItem*)m_BitmapIDList.GetNext(pContextItem);
09445 if (presID && pItem)
09446 *presID = pItem->m_ResID;
09447
09448 return (ListItem*)pItem;
09449 }
09450
09451