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 #include "camtypes.h"
00100 #include "palmenu.h"
00101
00102 #include "bmpalctrl.h"
00103 #include "bmapprev.h"
00104
00105 DECLARE_SOURCE("$Revision: 1088 $");
00106
00107
00108 CC_IMPLEMENT_DYNCREATE(OpPalettePopupCommand, Operation)
00109
00110
00111 BitmapExportPaletteControl *OpPalettePopupCommand::m_pPaletteControl = 0;
00112 BmapPrevDlg *OpPalettePopupCommand::m_pBmapPrevDlg = 0;
00113
00114
00115
00116 #define new CAM_DEBUG_NEW
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 BOOL PaletteContextMenu::Build()
00128 {
00129
00130
00131 BOOL ok = TRUE;
00132
00133
00134 if( ok )
00135 ok = ok && BuildCommand( OPTOKEN_PALETTE_LOCKED );
00136 if( ok )
00137 ok = ok && BuildCommand( OPTOKEN_PALETTE_WEB_SAFE );
00138 if( ok )
00139 ok = ok && BuildCommand( OPTOKEN_PALETTE_TRANSPARENT_BACKGROUND );
00140 if( ok )
00141 ok = ok && BuildCommand( OPTOKEN_PALETTE_TRANSPARENT, TRUE );
00142
00143
00144 if( ok )
00145 ok = ok && BuildCommand( OPTOKEN_PALETTE_RESTORE );
00146 if( ok )
00147 ok = ok && BuildCommand( OPTOKEN_PALETTE_DELETE, TRUE);
00148
00149 if( ok )
00150 ok = ok && BuildCommand( OPTOKEN_PALETTE_SYSTEM_COLOURS, TRUE );
00151
00152 if( ok )
00153 ok = ok && BuildCommand( OPTOKEN_PALETTE_SORT_BY_USE );
00154 if( ok )
00155 ok = ok && BuildCommand( OPTOKEN_PALETTE_SORT_BY_LUMINANCE );
00156 if( ok )
00157 ok = ok && BuildCommand( OPTOKEN_PALETTE_SORT_BY_HUE );
00158
00159 return ok;
00160 }
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 BOOL OpPalettePopupCommand::InitPolymorphicCommand( TCHAR *OpToken, UINT32 MenuTextID )
00181 {
00182 return(RegisterOpDescriptor(0,
00183 MenuTextID,
00184 CC_RUNTIME_CLASS(OpPalettePopupCommand),
00185 OpToken,
00186 OpPalettePopupCommand::GetCommandState,
00187 0,
00188 0,
00189 0,
00190 0,
00191 SYSTEMBAR_ILLEGAL,
00192 FALSE,
00193 FALSE,
00194 TRUE,
00195 NULL,
00196 0,
00197 DONT_GREY_WHEN_SELECT_INSIDE
00198 ));
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 BOOL OpPalettePopupCommand::Init(BitmapExportPaletteControl *pPaletteControl, BmapPrevDlg *pBmapPrevDlg)
00211 {
00212 m_pPaletteControl = pPaletteControl;
00213 m_pBmapPrevDlg = pBmapPrevDlg;
00214
00215 InitPolymorphicCommand( OPTOKEN_PALETTE_LOCKED, _R(IDS_MENU_LOCKED) );
00216 InitPolymorphicCommand( OPTOKEN_PALETTE_WEB_SAFE, _R(IDS_MENU_WEB_SAFE) );
00217 InitPolymorphicCommand( OPTOKEN_PALETTE_TRANSPARENT_BACKGROUND, _R(IDS_MENU_TRANSPARENT_BACK) );
00218 InitPolymorphicCommand( OPTOKEN_PALETTE_TRANSPARENT, _R(IDS_MENU_TRANSPARENT) );
00219
00220 InitPolymorphicCommand( OPTOKEN_PALETTE_RESTORE, _R(IDS_MENU_RESTORE) );
00221 InitPolymorphicCommand( OPTOKEN_PALETTE_DELETE, _R(IDS_MENU_DELETE) );
00222
00223 InitPolymorphicCommand( OPTOKEN_PALETTE_SYSTEM_COLOURS, _R(IDS_MENU_SYSTEM_COLOURS) );
00224
00225 InitPolymorphicCommand( OPTOKEN_PALETTE_SORT_BY_USE, _R(IDS_MENU_SORT_BY_USE) );
00226 InitPolymorphicCommand( OPTOKEN_PALETTE_SORT_BY_LUMINANCE, _R(IDS_MENU_SORT_BY_LUMINANCE) );
00227 InitPolymorphicCommand( OPTOKEN_PALETTE_SORT_BY_HUE, _R(IDS_MENU_SORT_BY_HUE) );
00228
00229 return TRUE;
00230 }
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 OpState OpPalettePopupCommand::GetCommandState( String_256 *UIDescription, OpDescriptor *pOpDesc )
00243 {
00244 OpState OpSt;
00245 OpSt.Greyed = FALSE;
00246
00247
00248 BOOL bLocked = m_pPaletteControl->GetSelectedColourLocked();
00249 BOOL bDeleted = m_pPaletteControl->GetSelectedColourDeleted();
00250 BOOL bWebSafe = m_pPaletteControl->GetSelectedColourWebSafe();
00251 BOOL bTransparentBackground = BmapPrevDlg::m_pExportOptions->IsBackgroundTransparent();
00252 BOOL bTransparent = m_pPaletteControl->GetSelectedColourTransparent();
00253 BOOL bSupportsTransp = BmapPrevDlg::m_pExportOptions->GetSupportsTransparency();
00254
00255
00256 if( pOpDesc->Token == String_256( OPTOKEN_PALETTE_LOCKED ) )
00257 {
00258 if (bDeleted)
00259 OpSt.Greyed = TRUE;
00260 else if (bLocked)
00261 OpSt.Ticked = TRUE;
00262 }
00263
00264
00265 if( pOpDesc->Token == String_256( OPTOKEN_PALETTE_WEB_SAFE ) )
00266 {
00267 if (bTransparent || bDeleted || bWebSafe)
00268 OpSt.Greyed = TRUE;
00269 }
00270
00271
00272 if( pOpDesc->Token == String_256( OPTOKEN_PALETTE_TRANSPARENT_BACKGROUND ) )
00273 {
00274 if (bDeleted || !bSupportsTransp)
00275 OpSt.Greyed = TRUE;
00276 else if (bTransparentBackground)
00277 OpSt.Ticked = TRUE;
00278 }
00279
00280
00281 if( pOpDesc->Token == String_256( OPTOKEN_PALETTE_TRANSPARENT ) )
00282 {
00283 if (bDeleted || !bSupportsTransp)
00284 OpSt.Greyed = TRUE;
00285 else if (bTransparent)
00286 OpSt.Ticked = TRUE;
00287 }
00288
00289
00290 if( pOpDesc->Token == String_256( OPTOKEN_PALETTE_DELETE ) )
00291 {
00292 if(bDeleted)
00293 OpSt.RemoveFromMenu = TRUE;
00294 }
00295
00296
00297 if( pOpDesc->Token == String_256( OPTOKEN_PALETTE_RESTORE ) )
00298 {
00299 if(!bDeleted)
00300 OpSt.RemoveFromMenu = TRUE;
00301 }
00302
00303
00304 if( pOpDesc->Token == String_256( OPTOKEN_PALETTE_SORT_BY_USE ) )
00305 if (m_pPaletteControl->GetCurrentSortType() == BitmapExportPaletteInterface::SORT_USE)
00306 OpSt.Ticked = TRUE;
00307
00308 if( pOpDesc->Token == String_256( OPTOKEN_PALETTE_SORT_BY_LUMINANCE ) )
00309 if (m_pPaletteControl->GetCurrentSortType() == BitmapExportPaletteInterface::SORT_LUMINANCE)
00310 OpSt.Ticked = TRUE;
00311
00312 if( pOpDesc->Token == String_256( OPTOKEN_PALETTE_SORT_BY_HUE ) )
00313 if (m_pPaletteControl->GetCurrentSortType() == BitmapExportPaletteInterface::SORT_HUE)
00314 OpSt.Ticked = TRUE;
00315
00316
00317
00318
00319
00320
00321
00322 return OpSt;
00323 }
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342 void OpPalettePopupCommand::Do( OpDescriptor* pOpDesc )
00343 {
00344 ERROR3IF(!m_pPaletteControl, "Help, I am the palette right click menu and I can't talk to the palette");
00345 ERROR3IF(!m_pBmapPrevDlg, "Help, I am the palette right click menu and I can't talk to the preview dialog");
00346
00347
00348 String_256 s(pOpDesc->Token);
00349
00350
00351 if (s.IsIdentical((TCHAR *)OPTOKEN_PALETTE_LOCKED))
00352 m_pPaletteControl->SetSelectedColourToggleLocked();
00353 else if (s.IsIdentical((TCHAR *)OPTOKEN_PALETTE_WEB_SAFE))
00354 m_pPaletteControl->SetSelectedColourWebSafe();
00355 else if (s.IsIdentical((TCHAR *)OPTOKEN_PALETTE_TRANSPARENT_BACKGROUND))
00356 {
00357 BmapPrevDlg::m_pExportOptions->SetBackgroundTransparency(!BmapPrevDlg::m_pExportOptions->IsBackgroundTransparent());
00358 m_pBmapPrevDlg->DoPreview();
00359 }
00360 else if (s.IsIdentical((TCHAR *)OPTOKEN_PALETTE_TRANSPARENT))
00361 m_pPaletteControl->SetSelectedColourToggleTransparent();
00362 else if (s.IsIdentical((TCHAR *)OPTOKEN_PALETTE_DELETE))
00363 m_pPaletteControl->SetSelectedColourToggleDeleted();
00364 else if (s.IsIdentical((TCHAR *)OPTOKEN_PALETTE_RESTORE))
00365 m_pPaletteControl->SetSelectedColourToggleDeleted();
00366 else if (s.IsIdentical((TCHAR *)OPTOKEN_PALETTE_SYSTEM_COLOURS))
00367 BmapPrevDlg::m_pExportOptions->SetToUseSystemPalette(!BmapPrevDlg::m_pExportOptions->IsUsingSystemPalette());
00368 else if (s.IsIdentical((TCHAR *)OPTOKEN_PALETTE_SORT_BY_USE))
00369 {
00370 m_pPaletteControl->SetCurrentSortType(BitmapExportPaletteInterface::SORT_USE);
00371 m_pPaletteControl->RenderSoon();
00372 }
00373 else if (s.IsIdentical((TCHAR *)OPTOKEN_PALETTE_SORT_BY_LUMINANCE))
00374 {
00375 m_pPaletteControl->SetCurrentSortType(BitmapExportPaletteInterface::SORT_LUMINANCE);
00376 m_pPaletteControl->RenderSoon();
00377 }
00378 else if (s.IsIdentical((TCHAR *)OPTOKEN_PALETTE_SORT_BY_HUE))
00379 {
00380 m_pPaletteControl->SetCurrentSortType(BitmapExportPaletteInterface::SORT_HUE);
00381 m_pPaletteControl->RenderSoon();
00382 }
00383
00384 BmapPrevDlg::m_pExportOptions->InvalidatePalette();
00385 m_pBmapPrevDlg->UpdateCurrentTab();
00386 m_pBmapPrevDlg->DoPreview();
00387
00388 End();
00389 }
00390